Пример #1
0
    def test_archive(self):
        """Test whether a Git archive command is correctly executed"""

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")

        self.assertIsInstance(file_obj, io.BytesIO)
Пример #2
0
    def test_tar_obj(self):
        """Test whether a BytesIO object is converted to a tar object"""

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")

        tar_obj = repo.tar_obj(file_obj)
        self.assertIsInstance(tar_obj, tarfile.TarFile)
Пример #3
0
    def test_filter_tar_no_members(self):
        """Test whether an null object is returned if not members are present"""

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")
        tar_obj = repo.tar_obj(file_obj)

        to_select = []
        filtered_obj = repo.filter_tar(tar_obj, to_select)
        self.assertIsNone(filtered_obj)
Пример #4
0
    def test_filter_tar(self):
        """Test whether tar object members are filtered"""

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")
        tar_obj = repo.tar_obj(file_obj)
        self.assertEqual(len(tar_obj.getmembers()), 18)

        to_select = ['.gitignore']
        filtered_obj = repo.filter_tar(tar_obj, to_select)
        self.assertEqual(len(filtered_obj.getmembers()), 1)
        self.assertEqual(filtered_obj.getmembers()[0].name, '.gitignore')
Пример #5
0
    def test_untar(self):
        """Test whether tar file is untarred"""

        untar_path = os.path.join(self.tmp_path, 'untesttar')

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")
        tar_obj = repo.tar_obj(file_obj)

        repo.untar(tar_obj, untar_path)
        self.assertTrue(os.path.exists(untar_path))
        self.assertTrue(os.path.isdir(untar_path))

        shutil.rmtree(untar_path)
Пример #6
0
    def test_tar(self):
        """Test whether tar object is saved to disk"""

        tar_path = os.path.join(self.tmp_path, 'testtar.tar.gz')

        repo = GraalRepository('http://example.git', self.git_path)
        file_obj = repo.archive("825b4da7ca740f7f2abbae1b3402908a44d130cd")
        tar_obj = repo.tar_obj(file_obj)

        repo.tar(tar_obj, tar_path)

        self.assertTrue(os.path.exists(tar_path))
        self.assertTrue(os.path.isfile(tar_path))

        os.remove(tar_path)