예제 #1
0
    def test_revert_repo(self, li, le, sys_exit):
        # Different src with prev untracked and no bypass and no revert
        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[True, True]):
            rep_mgr = rm.RepositoryManager(self._repodir, \
                        source_files_to_objects={'src1': None, 'src2': None})
        with self.assertRaises(AssertionError):
            rep_mgr.revert_repository(as_initial=True)
        self.tearDown()
        self.setUp()

        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[True, True]):
            rep_mgr = rm.RepositoryManager(self._repodir, \
                        source_files_to_objects={'src1': None, 'src2': None})
        self.write_file(self._src1, "xxx")
        self.assertTrue(self.file_contains(self._src1, 'xxx'))
        rep_mgr.revert_repository()
        self.assertTrue(self.file_contains(self._src1, 'src1'))
        self.tearDown()
        self.setUp()

        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[True, True]):
            rep_mgr = rm.RepositoryManager(self._repodir, \
                        source_files_to_objects={'src1': None, 'src2': None})
        self.write_file(self._src1, "xxx")
        self.assertTrue(self.file_contains(self._src1, 'xxx'))
        rep_mgr.revert_src_list_files()
        self.assertTrue(self.file_contains(self._src1, 'src1'))
예제 #2
0
 def test_init_noprevuntrack(self, li, le, sys_exit):
     # Different src but no prev untracked
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                     source_files_to_objects={'src1': None, 'src2': None})
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src1': None})
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[False, False]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src2': None})
예제 #3
0
 def test_init_srclistoverride(self, li, le, sys_exit):
     # check src list override
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                     source_files_to_objects={'src1': None, 'src2': None})
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src1': None})
         self.write_file(self._src2, "xxx")
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src1': None})
         self.assertTrue(self.file_contains(self._src2, 'xxx'))
예제 #4
0
 def test_init_prevuntrack_bypass(self, li, le, sys_exit):
     # Different src with prev untracked and bypass
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src1': None})
     self.write_file(self._src1, "xxx")
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src2': None})
         self.assertTrue(self.file_contains(self._src1, 'xxx'))
예제 #5
0
 def test_init_prevuntrack_nobypass_revert(self, li, le, sys_exit):
     # Different src with prev untracked and no bypass and revert
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                     source_files_to_objects={'src1': None, 'src2': None})
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src1': None})
     self.write_file(self._src1, "xxx")
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[False, True]):
         rep_mgr = rm.RepositoryManager(self._repodir, \
                                     source_files_to_objects={'src2': None})
 def setUpClass(cls):
     cls._worktmpdir = tempfile.mkdtemp(suffix=TMP_DIR_SUFFIX)
     cls._repodir = os.path.join(cls._worktmpdir, "repodir")
     cls._src1 = os.path.join(cls._repodir, "src1")
     os.mkdir(cls._repodir)
     with open(cls._src1, 'w') as f:
         f.write("src1")
     with patch.object(rm.common_mix, 'confirm_execution', \
                                                 side_effect=[True, True]):
         cls.rep_mgr_pass = rm.RepositoryManager(cls._repodir, \
                         dev_test_runner_func=lambda *a, **kw: True, \
                         code_builder_func=lambda *a, **kw: True)
         cls.rep_mgr_fail = rm.RepositoryManager(cls._repodir, \
                         dev_test_runner_func=lambda *a, **kw: False, \
                         code_builder_func=lambda *a, **kw: False)
예제 #7
0
    def test_init(self, li, le, sys_exit):
        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[True, True]):
            rep_mgr = rm.RepositoryManager(self._repodir)
        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[False, False]):
            rep_mgr = rm.RepositoryManager(self._repodir)
        self.tearDown()
        self.setUp()

        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[False, True]):
            with self.assertRaises(AssertionError):
                rep_mgr = rm.RepositoryManager(self._repodir)
            self.tearDown()
            self.setUp()

        with patch.object(rm.common_mix, 'confirm_execution', \
                                                    side_effect=[True, False]):
            with self.assertRaises(AssertionError):
                rep_mgr = rm.RepositoryManager(self._repodir, \
                                        source_files_to_objects={'src1': None})