class ShowModelsCommandTestCase(TestCase): fixtures = ['initial_data.json'] def setUp(self): self.cmd = Command() self.options = {'no_color': False} def test_if_command_exists(self): self.assertIsInstance(self.cmd, BaseCommand, "Command class must be instanciated from BaseCommand class") self.assertTrue(callable(self.cmd.handle)) def test_command_output_is_valid(self): output = self.cmd._collect_data(**self.options) self.assertTrue(len(output), 9) self.assertTrue(any('Contact' in _m for _m in output)) for line in output: model_name, count = line.split('\t') self.assertIsInstance(model_name, types.StringType) self.assertTrue(count.isdigit()) def test_correct_number_of_objects_count(self): output = self.cmd._collect_data(**self.options) contact_row = filter(lambda x: 'Contact' in x, output)[0] model_name, count = contact_row.split('\t') self.assertTrue('Contact' in model_name) self.assertTrue('1' in count, "Incorrect number of objects for Count model %s != 0" % count)
def setUp(self): self.cmd = Command() self.options = {'no_color': False}