Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Apr 4, 2018
1 parent 9dcfa68 commit 2cebb32
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test_quickcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,44 @@ def test_cli_load_file_bulk(self):
# TODO re-running same file adds images even though they have same URL
# bug in mongomock (ignoring unique)???

def test_cli_categories(self):
runner = CliRunner()

self.assertEqual(Category.objects.count(), 0)

result = runner.invoke(cli.categories, ['cat A'], input='y\n')
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, '''\
Existing categories will be removed and these will be added
cat A
Continue? [y/N]: y
Categories recreated
''')
self.assertEqual(Category.objects.count(), 1)
self.assertEqual(Category.objects.first().name, 'cat A')

result = runner.invoke(cli.categories, ['cat B', 'cat C'], input='n\n')
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, '''\
Existing categories will be removed and these will be added
cat B, cat C
Continue? [y/N]: n
''')
self.assertEqual(Category.objects.count(), 1)
self.assertEqual(Category.objects.first().name, 'cat A')

result = runner.invoke(cli.categories, ['cat B', 'cat C'], input='y\n')
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, '''\
Existing categories will be removed and these will be added
cat B, cat C
Continue? [y/N]: y
Categories recreated
''')
self.assertEqual(Category.objects.count(), 2)
self.assertEqual(Category.objects.all()[0].name, 'cat B')
self.assertEqual(Category.objects.all()[1].name, 'cat C')


if __name__ == '__main__':
unittest.main()

0 comments on commit 2cebb32

Please sign in to comment.