Esempio n. 1
0
 def test_push_content(self):
     self._populate(self.local1_base)
     self._populate(self.local2_base)
     self.assertEqual(0, len(Diff(Repo(self.local1_base), Repo(self.local2_base), content=True).compute()))
     with io.open(os.path.join(self.local1_base, "dir", "file_ä"), "w") as f:
         f.write("xontent2")
     self._fix_mtime(self.local1_base)
     self._fix_mtime(self.local2_base)
     diff = Diff(Repo(self.local1_base), Repo(self.local2_base), content=True)
     self.assertEqual((("dir/file_ä", "content"),), self._filter(diff))
     diff.push(force=True)
     diff = Diff(Repo(self.local1_base), Repo(self.local2_base), content=True)
     self.assertEqual(0, len(diff.compute()))
Esempio n. 2
0
 def test_compute_show(self):
     self._populate(self.local1_base)
     os.mkdir(os.path.join(self.remote, "test"))
     with io.open(os.path.join(self.remote, "file_ä"), "w") as f:
         f.write("xontent")
     stdout = sys.stdout
     output = io.StringIO()
     sys.stdout = output
     diff = Diff(Repo(self.local1_base), Repo(self.remote), content=True)
     diff.compute(show=True)
     DiffStatistics(diff).show()
     expected = "\n".join(
         (
             "--> dir",
             "--> dir/file_ä (8.0 B)",
             "<-> file_ä (7.0 B/7.0 B)",
             "<-- test",
             "pull: 1 files (0.0 B)",
             "push: 2 files (8.0 B)",
             "rest: 1 files (local: 7.0 B, remote: 7.0 B)",
             "",
         )
     )
     self.assertEqual(expected, output.getvalue())
     output = io.StringIO()
     sys.stdout = output
     diff.compute(show=True, show_verbose=True)
     DiffStatistics(diff).show()
     expected = "\n".join(
         (
             "Comparing 4 local files against 3 remote files...",
             "--> dir [remote file does not exist]",
             "--> dir/file_ä (8.0 B) [remote file does not exist]",
             "<-> file_ä (7.0 B/7.0 B) [files have different content; files have the same timestamp",
             "    local file hash:  9a0364b9e99bb480dd25e1f0284c8555",
             "    remote file hash: d57830865b3020a563b955b27320c31e]",
             "<-- test [local file does not exist]",
             "pull: 1 files (0.0 B)",
             "push: 2 files (8.0 B)",
             "rest: 1 files (local: 7.0 B, remote: 7.0 B)",
             "",
         )
     )
     self.assertEqual(expected, output.getvalue())
     sys.stdout = stdout