Пример #1
0
 def test_archive_view_absolute_mine(self, mock_view, mock_remove):
     main(["__init__", "archive", "--view", "mine", "--absolute"])
     calls = [
         call(Branch.Archive, ViewContext.Mine, True),
         call(Branch.Stash, ViewContext.Mine, True)
     ]
     mock_view.assert_has_calls(calls)
     mock_remove.assert_not_called()
Пример #2
0
 def test_archive_stash_fofn(self, mock_add, mock_remove, mock_file):
     main(["__init__", "archive", "--stash", "--fofn", "mock_file"])
     args = mock_add.call_args.args
     files = list(args[1])
     branch = args[0]
     self.assertEqual(files, [T.Path("/file1"), T.Path("/file2")])
     self.assertEqual(branch, Branch.Stash)
     mock_remove.assert_not_called()
Пример #3
0
 def test_archive_view_relative_here(self, mock_view, mock_remove):
     main(["__init__", "archive", "--view", "here"])
     calls = [
         call(Branch.Archive, ViewContext.Here, False),
         call(Branch.Stash, ViewContext.Here, False)
     ]
     mock_view.assert_has_calls(calls)
     mock_remove.assert_not_called()
Пример #4
0
    def test_keep_files_symlink(self, mock_add, mock_remove):

        self._tmp = TemporaryDirectory()
        path = T.Path(self._tmp.name).resolve()
        # Form a directory hierarchy
        filepath = path / "a"
        symlink = path / "b"
        filepath.touch()
        os.symlink(filepath, symlink)

        main(["__init__", "keep", str(symlink)])
        mock_add.assert_called_with(Branch.Keep, [filepath])
        mock_remove.assert_not_called()
        self._tmp.cleanup()
Пример #5
0
 def test_symlink_fofn(self, mock_untrack):
     self._tmp = TemporaryDirectory()
     path = T.Path(self._tmp.name).resolve()
     # Form temporary files
     filepath = path / "a"
     symlink = path / "b"
     filepath.touch()
     os.symlink(filepath, symlink)
     with mock.patch("builtins.open",
                     new_callable=mock_open,
                     read_data=f"{symlink}\n"):
         main(["__init__", "untrack", "--fofn", "mock_file"])
         args = mock_untrack.call_args.args
         files = list(args[0])
         self.assertEqual(files, [filepath])
     self._tmp.cleanup()
Пример #6
0
 def test_keep_files(self, mock_add, mock_remove):
     main(["__init__", "keep", "/file1", "/file2"])
     mock_add.assert_called_with(
         Branch.Keep, [T.Path("/file1"), T.Path("/file2")])
     mock_remove.assert_not_called()
Пример #7
0
 def test_keep_view_absolute_mine(self, mock_view, mock_remove):
     main(["__init__", "keep", "--view", "mine", "--absolute"])
     mock_view.assert_called_with(Branch.Keep, ViewContext.Mine, True)
     mock_remove.assert_not_called()
Пример #8
0
 def test_keep_view_relative_here(self, mock_view, mock_remove):
     main(["__init__", "keep", "--view", "here"])
     mock_view.assert_called_with(Branch.Keep, ViewContext.Here, False)
     mock_remove.assert_not_called()
Пример #9
0
 def test_untrack_fofn(self, mock_untrack, mock_file):
     main(["__init__", "untrack", "--fofn", "mock_file"])
     args = mock_untrack.call_args.args
     files = list(args[0])
     self.assertEqual(files, [T.Path("/file1"), T.Path("/file2")])
Пример #10
0
 def test_untrack(self, mock_untrack):
     main(["__init__", "untrack", "/file1", "/file2"])
     mock_untrack.assert_called_with([T.Path("/file1"), T.Path("/file2")])
Пример #11
0
 def test_recover_fofn(self, mock_recover, mock_remove, mock_file):
     main(["__init__", "recover", "--fofn", "mock_file"])
     args = mock_recover.call_args.args
     files = list(args[0])
     self.assertEqual(files, [T.Path("/file1"), T.Path("/file2")])
     mock_remove.assert_not_called()
Пример #12
0
 def test_recover_all(self, mock_recover, mock_untrack):
     main(["__init__", "recover", "--all"])
     mock_recover.assert_called_with(None)
     mock_untrack.assert_not_called()
Пример #13
0
 def test_recover_files(self, mock_recover, mock_remove):
     main(["__init__", "recover", "/file1", "/file2"])
     mock_recover.assert_called_with([T.Path("/file1"), T.Path("/file2")])
     mock_remove.assert_not_called()
Пример #14
0
 def test_stash_files(self, mock_add, mock_remove):
     main(["__init__", "archive", "--stash", "/file1", "/file2"])
     mock_add.assert_called_with(
         Branch.Stash,
         [T.Path("/file1"), T.Path("/file2")])
     mock_remove.assert_not_called()
Пример #15
0
 def test_archive_view_staged_absolute_mine(self, mock_view, mock_remove):
     main(["__init__", "archive", "--view-staged", "mine", "--absolute"])
     mock_view.assert_called_with(Branch.Staged, ViewContext.Mine, True)
     mock_remove.assert_not_called()
Пример #16
0
 def test_archive_view_staged_relative_here(self, mock_view, mock_remove):
     main(["__init__", "archive", "--view-staged", "here"])
     mock_view.assert_called_with(Branch.Staged, ViewContext.Here, False)
     mock_remove.assert_not_called()