示例#1
0
    def test_save_no_changes(self):
        with mock.patch('tddtags.core.UTModuleContainer.save_module', spec=True) as ModCon:
            # --> Prep. This time we need a container, but no changes
            container = UTModuleContainer(module_path=self.tmp_file)
            updater = ModuleUpdater(ut_module=self.ut_module)
            self.assertFalse(container.dirty_flag)
            ret = updater._save(container=container)
            self.assertTrue(ret)

            self.assertEqual(container.save_module.call_count, 0)
示例#2
0
    def test_save_different_name(self):

        with mock.patch('tddtags.core.UTModuleContainer.save_module', spec=True) as ModCon:
            # --> Prep. This time we need a container, and a changed filename
            tddtags.core.tddtags_config['save_to_name'] = 'changed.py'
            container = UTModuleContainer(module_path=self.tmp_file)
            updater = ModuleUpdater(ut_module=self.ut_module)
            container.dirty_flag = True
            ret = updater._save(container=container)
            self.assertTrue(ret)

            self.assertEqual(container.save_module.call_count, 1)

            parm_info = [('save_name', 0)]
            kwargs = self.get_patched_call_parms(parm_info, container.save_module, 0)
            self.assertEqual(kwargs['save_name'], 'changed.py')
示例#3
0
    def test_save_with_changes(self):
        with mock.patch('tddtags.core.UTModuleContainer.save_module', spec=True) as ModCon:
            # --> Prep. This time we need a container
            container = UTModuleContainer(module_path=self.tmp_file)
            updater = ModuleUpdater(ut_module=self.ut_module)
            container.dirty_flag = True
            ret = updater._save(container=container)
            self.assertTrue(ret)

            self.assertEqual(container.save_module.call_count, 1)

            # --> Check the filename
            parm_info = [('save_name', 0)]
            kwargs = self.get_patched_call_parms(parm_info, container.save_module, 0)
            abs_file_path = os.path.abspath(self.tmp_file)
            self.assertEqual(kwargs['save_name'], abs_file_path)
示例#4
0
 def test_save_no_container(self):
     updater = ModuleUpdater(ut_module=self.ut_module)
     ret = updater._save(container=None)
     self.assertTrue(ret)