def test_archive(self) -> NoReturn:
        zip_name = self.arch_name + ".zip"
        assert not Archiver.archive(zip_name, *self.files), "errors occured"
        assert os.path.exists(zip_name), "archive not exists"
        assert not Archiver.archive(zip_name, *self.files,
                                    rewrite=True), "errors occured"
        assert Archiver.archive(zip_name, *self.files,
                                rewrite=False) < 0, "file was rewrited"

        tar_name = self.arch_name + ".tar"
        assert not Archiver.archive(tar_name, *self.files), "error occured"
        assert os.path.exists(tar_name), "can't find archive"
        assert not Archiver.archive(tar_name, *self.files, rewrite=True)
        assert Archiver.archive(tar_name, *self.files, rewrite=False) < 0
    def test__archive(self) -> NoReturn:
        assert Archiver._archive(
            *self.files, method="x",
            destination=self.arch_name) < 0, "invalid method was accepted"

        tar_kwargs = {'method': "tar", 'destination': self.arch_name + ".tar"}
        zip_kwargs = {'method': "zip", 'destination': self.arch_name + ".zip"}

        for res in (Archiver._archive(*self.files, **tar_kwargs),
                    Archiver._archive(*self.files, **zip_kwargs)):
            assert not res, "errors occured"
        assert os.path.exists(tar_kwargs['destination']), "archive exists"
        assert os.path.exists(zip_kwargs['destination']), "archive exists"

        for res in (Archiver._archive(*self.files, rewrite=True, **tar_kwargs),
                    Archiver._archive(*self.files, rewrite=True,
                                      **zip_kwargs)):
            assert not res, "errors occured"

        for res in (Archiver._archive(*self.files, rewrite=False,
                                      **tar_kwargs),
                    Archiver._archive(*self.files, rewrite=False,
                                      **zip_kwargs)):
            assert res < 0, "file was rewritten"
 def test__to_tar(self) -> NoReturn:
     assert not Archiver._to_tar(self.arch_name, *self.files), "no errors"
     assert os.path.exists(self.arch_name), "archive isn't exist"
 def test_to_tar_flow(self) -> NoReturn:
     Archiver.to_tar_flow({fn: fn for fn in self.files}, self.arch_name)
     assert os.path.exists(self.arch_name + ".tar"), "archive not exist"
Exemplo n.º 5
0
 def as_archive(self) -> io.BytesIO:
     """ Returns generated configs as archive. """
     return Archiver.get_tar_io(self.configs)
Exemplo n.º 6
0
 def archive(self, path: str = None) -> object:
     """ Generate tar file with FPGA config files for specific project """
     Archiver.to_tar_flow(self.configs, path=path or self.project_name)
     return self