def _journalist_logs_in(self): # Create a test user for logging in self.user, self.user_pw = db_helper.init_journalist() self._login_user(self.user.username, self.user_pw, 'mocked') headline = self.driver.find_element_by_css_selector('span.headline') self.assertIn('Sources', headline.text)
def _journalist_logs_in(self): # Create a test user for logging in self.user, self.user_pw = db_helper.init_journalist() self._login_user(self.user.username, self.user_pw, 'mocked') headline = self.driver.find_element_by_css_selector('span.headline') if not hasattr(self, 'accept_languages'): assert 'Sources' in headline.text
def _admin_logs_in(self): self.admin, self.admin_pw = db_helper.init_journalist(is_admin=True) self._login_user(self.admin.username, self.admin_pw, 'mocked') # Admin user should log in to the same interface as a normal user, # since there may be users who wish to be both journalists and admins. headline = self.driver.find_element_by_css_selector('span.headline') self.assertIn('Sources', headline.text) # Admin user should have a link that take them to the admin page links = self.driver.find_elements_by_tag_name('a') self.assertIn('Admin', [el.text for el in links])
def _admin_logs_in(self): self.admin, self.admin_pw = db_helper.init_journalist(is_admin=True) self._login_user(self.admin.username, self.admin_pw, 'mocked') if not hasattr(self, 'accept_languages'): # Admin user should log in to the same interface as a # normal user, since there may be users who wish to be # both journalists and admins. headline = self.driver.find_element_by_css_selector( 'span.headline') assert 'Sources' in headline.text # Admin user should have a link that take them to the admin page links = self.driver.find_elements_by_tag_name('a') assert 'Admin' in [el.text for el in links]
def _journalist_fail_login_many(self): self.user, self.user_pw = db_helper.init_journalist() for _ in range(Journalist._MAX_LOGIN_ATTEMPTS_PER_PERIOD + 1): self._try_login_user(self.user.username, 'worse', 'mocked')
def _journalist_fail_login(self): self.user, self.user_pw = db_helper.init_journalist() self._try_login_user(self.user.username, 'worse', 'mocked')