def test_add_new_tests_to_class_none(self): with mock.patch('tddtags.core.UTModuleContainer.add_class_method', spec=True): container = UTModuleContainer(module_path=self.tmp_file) updater = ModuleUpdater(ut_module=self.ut_module) reply = updater._add_new_tests_to_class(container, 'class_name', []) self.assertTrue(reply) self.assertEqual(container.add_class_method.call_count, 0)
def test_add_new_tests_to_class_container_fail(self): with mock.patch('tddtags.core.UTModuleContainer.add_class_method', spec=True) as ModCon: # ModCon.add_class_method.side_effect = False container = UTModuleContainer(module_path=self.tmp_file) container.add_class_method.side_effect = self.return_false updater = ModuleUpdater(ut_module=self.ut_module) reply = updater._add_new_tests_to_class(container, 'ChildSampleTests', ['test_something_else']) self.assertFalse(reply) self.assertEqual(container.add_class_method.call_count, 1)
def test_add_new_tests_to_class(self): with mock.patch('tddtags.core.UTModuleContainer.add_class_method', spec=True) as ModCon: # ModCon.add_class_method.side_effect = False container = UTModuleContainer(module_path=self.tmp_file) container.add_class_method.side_effect = self.return_true updater = ModuleUpdater(ut_module=self.ut_module) reply = updater._add_new_tests_to_class(container, 'ChildSampleTests', ['test_something_else']) self.assertTrue(reply) self.assertEqual(container.add_class_method.call_count, 1) parm_info = [('class_name', 0), ('method_name', 1)] kwargs = self.get_patched_call_parms(parm_info, container.add_class_method, 0) self.assertEqual(kwargs['class_name'], 'ChildSampleTests') self.assertEqual(kwargs['method_name'], 'test_something_else')