Cloud computing coursework:Saas 图片社交网站
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
2.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from phshare.extensions import db
  3. from phshare.models import Comment, Role, User, Photo, Tag
  4. from tests.base import BaseTestCase
  5. class CLITestCase(BaseTestCase):
  6. def setUp(self):
  7. super(CLITestCase, self).setUp()
  8. db.drop_all()
  9. def test_initdb_command(self):
  10. result = self.runner.invoke(args=['initdb'])
  11. self.assertIn('Initialized database.', result.output)
  12. def test_initdb_command_with_drop(self):
  13. result = self.runner.invoke(args=['initdb', '--drop'], input='y\n')
  14. self.assertIn('This operation will delete the database, do you want to continue?', result.output)
  15. self.assertIn('Drop tables.', result.output)
  16. def test_init_command(self):
  17. result = self.runner.invoke(args=['init'])
  18. self.assertIn('Initializing the database...', result.output)
  19. self.assertIn('Initializing the roles and permissions...', result.output)
  20. self.assertIn('Done.', result.output)
  21. self.assertEqual(Role.query.count(), 4)
  22. def test_forge_command(self):
  23. pass # it will take too long time
  24. def test_forge_command_with_count(self):
  25. result = self.runner.invoke(args=['forge', '--user', '5', '--follow', '10',
  26. '--photo', '10', '--tag', '10', '--collect', '10',
  27. '--comment', '10'])
  28. self.assertIn('Initializing the roles and permissions...', result.output)
  29. self.assertEqual(User.query.count(), 6)
  30. self.assertIn('Generating the administrator...', result.output)
  31. self.assertIn('Generating 10 follows...', result.output)
  32. self.assertEqual(Photo.query.count(), 10)
  33. self.assertIn('Generating 10 photos...', result.output)
  34. self.assertEqual(Tag.query.count(), 10)
  35. self.assertIn('Generating 10 tags...', result.output)
  36. self.assertIn('Generating 10 collects...', result.output)
  37. self.assertEqual(Comment.query.count(), 10)
  38. self.assertIn('Generating 10 comments...', result.output)
  39. self.assertIn('Done.', result.output)