from selenium.webdriver.common.by import By from .base import FunctionalTest from apps.lyric.models import User class AdminLoginTest(FunctionalTest): def setUp(self): super().setUp() self.superuser = User.objects.create_superuser( email="admin@example.com", password="correct-password", ) def test_can_access_admin(self): self.browser.get(self.live_server_url + "/admin/") self.wait_for(lambda: self.browser.find_element(By.ID, "id_username")) self.browser.find_element(By.ID, "id_username").send_keys("admin@example.com") self.browser.find_element(By.ID, "id_password").send_keys("correct-password") self.browser.find_element(By.CSS_SELECTOR, "input[type=submit]").click() body = self.wait_for( lambda: self.browser.find_element(By.TAG_NAME, "body") ) self.assertIn("Site administration", body.text) self.assertIn("Users", body.text) self.assertIn("Tokens", body.text)