test_create_fake_followers_command.py 915 B

1234567891011121314151617181920212223242526272829
  1. from io import StringIO
  2. from django.core.management import call_command
  3. from ..management.commands import createfakefollowers
  4. from ..users import get_fake_user
  5. def test_management_command_creates_fake_followers_for_two_users(user, other_user):
  6. call_command(createfakefollowers.Command(), stdout=StringIO())
  7. def test_management_command_creates_fake_followers_for_multiple_users(db, fake):
  8. [get_fake_user(fake) for i in range(10)]
  9. call_command(createfakefollowers.Command(), stdout=StringIO())
  10. def test_management_command_displays_error_if_no_users_exist(db):
  11. stderr = StringIO()
  12. call_command(createfakefollowers.Command(), stderr=stderr)
  13. stderr.seek(0)
  14. assert stderr.read()
  15. def test_management_command_displays_error_if_only_one_user_exist(user):
  16. stderr = StringIO()
  17. call_command(createfakefollowers.Command(), stderr=stderr)
  18. stderr.seek(0)
  19. assert stderr.read()