test_about_account.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. from base import BaseTestCase, Profile
  2. from parameterized import parameterized
  3. class AboutAccount(object):
  4. header = '.about-account-header'
  5. name = '.about-account-name'
  6. body = '.about-account-body'
  7. row = '.about-account-row'
  8. label = '.about-account-label'
  9. value = '.about-account-value'
  10. # (username, expected_labels)
  11. # Each label is checked for presence in the page text
  12. about_data = [
  13. ['jack', ['Date joined', 'Account based in', 'Connected via']],
  14. ['NASA', ['Date joined']],
  15. ['elonmusk', ['Date joined']],
  16. ]
  17. about_verified = [
  18. ['jack', 'Verified', 'Since '],
  19. ]
  20. about_affiliate = [
  21. ['jack', 'An affiliate of', 'Square'],
  22. ['elonmusk', 'An affiliate of', 'X'],
  23. ]
  24. class AboutAccountTest(BaseTestCase):
  25. @parameterized.expand(about_data)
  26. def test_about_page_has_labels(self, username, expected_labels):
  27. """About page shows expected info labels"""
  28. self.open_nitter(f'{username}/about')
  29. self.assert_element_visible(AboutAccount.header)
  30. self.assert_element_visible(AboutAccount.body)
  31. for label in expected_labels:
  32. self.assert_text(label, AboutAccount.body)
  33. @parameterized.expand(about_verified)
  34. def test_about_verified(self, username, label, value_prefix):
  35. """About page shows verification info for verified accounts"""
  36. self.open_nitter(f'{username}/about')
  37. self.assert_text(label, AboutAccount.body)
  38. self.assert_text(value_prefix, AboutAccount.body)
  39. @parameterized.expand(about_affiliate)
  40. def test_about_affiliate(self, username, label, affiliate):
  41. """About page shows affiliate info"""
  42. self.open_nitter(f'{username}/about')
  43. self.assert_text(label, AboutAccount.body)
  44. self.assert_text(f'@{affiliate}', AboutAccount.body)
  45. def test_about_page_title(self):
  46. """Title contains account name"""
  47. self.open_nitter('jack/about')
  48. self.assert_text('jack', AboutAccount.name)
  49. def test_about_join_date(self):
  50. """About page always shows join date"""
  51. self.open_nitter('jack/about')
  52. self.assert_text('Date joined', AboutAccount.body)
  53. self.assert_text('March 2006', AboutAccount.body)
  54. def test_about_invalid_user(self):
  55. """About page for non-existent user shows error"""
  56. self.open_nitter('thisprofiledoesntexist/about')
  57. self.assert_text('User "thisprofiledoesntexist" not found')
  58. def test_joindate_links_to_about(self):
  59. """Join date on profile page links to about page"""
  60. self.open_nitter('jack')
  61. link = self.find_element(Profile.joinDate + ' a')
  62. self.assertIn('/jack/about', link.get_attribute('href'))