UPD: more and better tests.

This commit is contained in:
2019-03-22 17:32:08 +01:00
parent dc37c110df
commit e20f536b1b
6 changed files with 187 additions and 55 deletions

22
dav_auth/tests/generic.py Normal file
View File

@@ -0,0 +1,22 @@
from django.urls import reverse
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
class SeleniumAuthMixin(object):
def login(self, driver, username, password):
driver.get(self.complete_url(reverse('dav_auth:login')))
username_field = self.wait_on_presence(driver, (By.ID, 'id_username'))
username_field.clear()
username_field.send_keys(username)
password_field = driver.find_element_by_id('id_password')
password_field.clear()
password_field.send_keys(password)
password_field.send_keys(Keys.RETURN)
self.wait_on_presence(driver, (By.CSS_SELECTOR, "#messages .alert-success"))
return driver
def logout(self, driver):
driver.get(self.complete_url(reverse('dav_auth:logout')))
self.wait_on_presence(driver, (By.CSS_SELECTOR, "#messages .alert-success"))
return driver