Beispiel #1
0
 async def asyncSetUp(self):
     self.obs = obsgit.AsyncOBS("https://api.example.local", "user",
                                "secret")
     with unittest.mock.patch.object(self.obs,
                                     "files_md5_revision",
                                     return_value=[(), None]):
         self.storage = await obsgit.Storage(self.obs, "project/package")
     self.git = obsgit.Git("/tmp/git")
     self.exporter = obsgit.Exporter(self.obs, self.git, self.storage)
Beispiel #2
0
    async def test_packages(self):
        with tempfile.TemporaryDirectory() as tmp:
            tmp = pathlib.Path(tmp)
            git = obsgit.Git(tmp)

            for package in ("mypackage1", "mypackage2", ".git", ".obs"):
                (tmp / package).mkdir()

            self.assertEqual(git.packages(), ["mypackage1", "mypackage2"])
Beispiel #3
0
    async def test_delete_package(self):
        with tempfile.TemporaryDirectory() as tmp:
            tmp = pathlib.Path(tmp)
            git = obsgit.Git(tmp)

            package_path = tmp / "mypackage"
            package_path.mkdir()

            self.assertTrue(package_path.exists())
            await git.delete("mypackage")
            self.assertFalse(package_path.exists())
Beispiel #4
0
    async def test_files_md5(self):
        with tempfile.TemporaryDirectory() as tmp:
            tmp = pathlib.Path(tmp)
            git = obsgit.Git(tmp)

            package_path = tmp / "mypackage"
            package_path.mkdir()

            for filename in ("myfile1", "myfile2"):
                with (package_path / filename).open("w") as f:
                    f.write(filename)

            self.assertEqual(
                list(await git.files_md5("mypackage")),
                [
                    ("myfile1", "52a082e3940c1bda8306223103eaab28"),
                    ("myfile2", "549d8b648caf7cce417751c0fbe15c7a"),
                ],
            )
Beispiel #5
0
 def test_exists_and_create(self):
     with tempfile.TemporaryDirectory() as tmp:
         git = obsgit.Git(tmp)
         self.assertFalse(git.exists())
         git.create()
         self.assertTrue(git.exists())