Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

61 Zeilen
2.2 KiB

vor 4 Jahren
  1. # -*- coding: utf-8 -*-
  2. """
  3. :author: Grey Li ()
  4. :url: http://greyli.com
  5. :copyright: © 2018 Grey Li <withlihui@gmail.com>
  6. :license: MIT, see LICENSE for more details.
  7. """
  8. from albumy.extensions import db
  9. from albumy.models import Comment, Role, User, Photo, Tag
  10. from tests.base import BaseTestCase
  11. class CLITestCase(BaseTestCase):
  12. def setUp(self):
  13. super(CLITestCase, self).setUp()
  14. db.drop_all()
  15. def test_initdb_command(self):
  16. result = self.runner.invoke(args=['initdb'])
  17. self.assertIn('Initialized database.', result.output)
  18. def test_initdb_command_with_drop(self):
  19. result = self.runner.invoke(args=['initdb', '--drop'], input='y\n')
  20. self.assertIn('This operation will delete the database, do you want to continue?', result.output)
  21. self.assertIn('Drop tables.', result.output)
  22. def test_init_command(self):
  23. result = self.runner.invoke(args=['init'])
  24. self.assertIn('Initializing the database...', result.output)
  25. self.assertIn('Initializing the roles and permissions...', result.output)
  26. self.assertIn('Done.', result.output)
  27. self.assertEqual(Role.query.count(), 4)
  28. def test_forge_command(self):
  29. pass # it will take too long time
  30. def test_forge_command_with_count(self):
  31. result = self.runner.invoke(args=['forge', '--user', '5', '--follow', '10',
  32. '--photo', '10', '--tag', '10', '--collect', '10',
  33. '--comment', '10'])
  34. self.assertIn('Initializing the roles and permissions...', result.output)
  35. self.assertEqual(User.query.count(), 6)
  36. self.assertIn('Generating the administrator...', result.output)
  37. self.assertIn('Generating 10 follows...', result.output)
  38. self.assertEqual(Photo.query.count(), 10)
  39. self.assertIn('Generating 10 photos...', result.output)
  40. self.assertEqual(Tag.query.count(), 10)
  41. self.assertIn('Generating 10 tags...', result.output)
  42. self.assertIn('Generating 10 collects...', result.output)
  43. self.assertEqual(Comment.query.count(), 10)
  44. self.assertIn('Generating 10 comments...', result.output)
  45. self.assertIn('Done.', result.output)