test_profile.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from base import BaseTestCase, Profile
  2. from parameterized import parameterized
  3. profiles = [
  4. ['Test account', 'mobile_test',
  5. 'Test Account. test test Testing username with @mobile_test_2 and a #hashtag'],
  6. ['mobile test 2', 'mobile_test_2', '']
  7. ]
  8. verified = [['jack'], ['elonmusk']]
  9. protected = [
  10. ['mobile test 7', 'mobile_test_7', ''],
  11. ['Randy', 'Poop', 'Social media fanatic.']
  12. ]
  13. invalid = [['thisprofiledoesntexist'], ['%']]
  14. class TestProfile(BaseTestCase):
  15. @parameterized.expand(profiles)
  16. def test_data(self, fullname, username, bio):
  17. self.open_nitter(username)
  18. self.assert_exact_text(fullname, Profile.fullname)
  19. self.assert_exact_text(f'@{username}', Profile.username)
  20. if len(bio) > 0:
  21. self.assert_exact_text(bio, Profile.bio)
  22. else:
  23. self.assert_element_absent(Profile.bio)
  24. @parameterized.expand(verified)
  25. def test_verified(self, username):
  26. self.open_nitter(username)
  27. self.assert_element_visible(Profile.verified)
  28. @parameterized.expand(protected)
  29. def test_protected(self, fullname, username, bio):
  30. self.open_nitter(username)
  31. self.assert_element_visible(Profile.protected)
  32. self.assert_exact_text(fullname, Profile.fullname)
  33. self.assert_exact_text(f'@{username}', Profile.username)
  34. self.assert_text('Tweets are protected')
  35. if len(bio) > 0:
  36. self.assert_text(bio, Profile.bio)
  37. else:
  38. self.assert_element_absent(Profile.bio)
  39. @parameterized.expand(invalid)
  40. def test_invalid_username(self, username):
  41. self.open_nitter(username)
  42. self.assert_text(f'User "{username}" not found')
  43. def test_suspended(self):
  44. # TODO: detect suspended
  45. self.open_nitter('test')
  46. self.assert_text(f'User "test" not found')