def test_obscpio_broken_link(self):
        tc_name              = inspect.stack()[0][3]
        cl_name              = self.__class__.__name__
        c_dir                = os.path.join(self.tmp_dir, tc_name)
        scmlogs              = ScmInvocationLogs('git', c_dir)
        scmlogs.next('start-test')  # pylint: disable=E1102
        fixture              = GitFixtures(c_dir, scmlogs)
        fixture.init()
        scm_object           = Git(self.cli, self.tasks)
        scm_object.clone_dir = fixture.repo_path
        scm_object.arch_dir  = fixture.repo_path
        outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                            'out')
        cwd = os.getcwd()
        print("cwd = %s" % cwd)
        os.chdir(fixture.repo_path)
        os.symlink('non-existant-file', 'broken-link')
        fixture.run('add broken-link')
        fixture.run("commit -m 'added broken-link'")
        os.chdir(cwd)

        self.cli.outdir      = outdir
        arch                 = ObsCpio()
        os.makedirs(outdir)
        arch.create_archive(
            scm_object,
            cli      = self.cli,
            basename = 'test',
            dstname  = 'test',
            version  = '0.1.1'
        )
    def test_obscpio_create_archive(self):
        tc_name              = inspect.stack()[0][3]
        cl_name              = self.__class__.__name__
        c_dir                = os.path.join(self.tmp_dir, tc_name)
        f_dir                = os.path.join(self.fixtures_dir, tc_name, 'repo')
        shutil.copytree(f_dir, c_dir)
        scmlogs              = ScmInvocationLogs('git', c_dir)
        scmlogs.next('start-test') # pylint: disable=E1102
        fixture              = GitFixtures(c_dir, scmlogs)
        fixture.init()
        scm_object           = Git(self.cli, self.tasks)
        scm_object.clone_dir = fixture.repo_path
        scm_object.arch_dir  = fixture.repo_path
        outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                            'out')

        self.cli.outdir      = outdir
        arch                 = ObsCpio()
        os.makedirs(outdir)
        arch.create_archive(
            scm_object,
            cli      = self.cli,
            basename = 'test',
            dstname  = 'test',
            version  = '0.1.1'
        )
    def test_obscpio_create_archive(self):
        tc_name              = inspect.stack()[0][3]
        cl_name              = self.__class__.__name__
        c_dir                = os.path.join(self.tmp_dir, tc_name)
        f_dir                = os.path.join(self.fixtures_dir, tc_name, 'repo')
        shutil.copytree(f_dir, c_dir)
        scmlogs              = ScmInvocationLogs('git', c_dir)
        scmlogs.next('start-test')
        fixture              = GitFixtures(c_dir, scmlogs)
        fixture.init()
        scm_object           = Git(self.cli, self.tasks)
        scm_object.clone_dir = fixture.repo_path
        scm_object.arch_dir  = fixture.repo_path
        outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                            'out')

        self.cli.outdir      = outdir
        arch                 = ObsCpio()
        os.makedirs(outdir)
        arch.create_archive(
            scm_object,
            cli      = self.cli,
            basename = 'test',
            dstname  = 'test',
            version  = '0.1.1'
        )
    def test_obscpio_broken_link(self):
        tc_name              = inspect.stack()[0][3]
        cl_name              = self.__class__.__name__
        c_dir                = os.path.join(self.tmp_dir, tc_name)
        scmlogs              = ScmInvocationLogs('git', c_dir)
        scmlogs.next('start-test')
        fixture              = GitFixtures(c_dir, scmlogs)
        fixture.init()
        scm_object           = Git(self.cli, self.tasks)
        scm_object.clone_dir = fixture.repo_path
        scm_object.arch_dir  = fixture.repo_path
        outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                            'out')
        cwd = os.getcwd()
        print("cwd = %s" % cwd)
        os.chdir(fixture.repo_path)
        os.symlink('non-existant-file', 'broken-link')
        fixture.run('add broken-link')
        fixture.run("commit -m 'added broken-link'")
        os.chdir(cwd)

        self.cli.outdir      = outdir
        arch                 = ObsCpio()
        os.makedirs(outdir)
        arch.create_archive(
            scm_object,
            cli      = self.cli,
            basename = 'test',
            dstname  = 'test',
            version  = '0.1.1'
        )
    def test_obscpio_extract_mf(self):
        '''
        Test obscpio to extract multiple files from archive
        '''
        tc_name = inspect.stack()[0][3]
        cl_name = self.__class__.__name__

        repodir = os.path.join(self.fixtures_dir, tc_name, 'repo')
        files = ["test.spec", 'Readme.md']
        outdir = os.path.join(self.tmp_dir, cl_name, tc_name, 'out')
        arch = ObsCpio()
        os.makedirs(outdir)
        arch.extract_from_archive(repodir, files, outdir)
        for fname in files:
            self.assertTrue(os.path.exists(os.path.join(outdir, fname)))
    def test_obscpio_extract_glob(self):
        '''
        Test obscpio to extract file glob from archive
        '''
        tc_name = inspect.stack()[0][3]
        cl_name = self.__class__.__name__

        repodir = os.path.join(self.fixtures_dir, tc_name, 'repo')
        files = ["test.*"]
        files_expected = ["test.spec", "test.rpmlintrc"]
        outdir = os.path.join(self.tmp_dir, cl_name, tc_name, 'out')
        arch = ObsCpio()
        os.makedirs(outdir)
        arch.extract_from_archive(repodir, files, outdir)
        for fname in files_expected:
            self.assertTrue(os.path.exists(os.path.join(outdir, fname)))
    def test_obscpio_extract_mf(self):
        '''
        Test obscpio to extract multiple files from archive
        '''
        tc_name = inspect.stack()[0][3]
        cl_name = self.__class__.__name__

        repodir = os.path.join(self.fixtures_dir, tc_name, 'repo')
        files   = ["test.spec", 'Readme.md']
        outdir  = os.path.join(self.tmp_dir, cl_name, tc_name, 'out')
        arch    = ObsCpio()
        os.makedirs(outdir)
        arch.extract_from_archive(repodir, files, outdir)
        for fname in files:
            self.assertTrue(os.path.exists(
                os.path.join(outdir, fname)))
    def test_obscpio_extract_glob(self):
        '''
        Test obscpio to extract file glob from archive
        '''
        tc_name = inspect.stack()[0][3]
        cl_name = self.__class__.__name__

        repodir = os.path.join(self.fixtures_dir, tc_name, 'repo')
        files   = ["test.*"]
        files_expected = ["test.spec", "test.rpmlintrc"]
        outdir  = os.path.join(self.tmp_dir, cl_name, tc_name, 'out')
        arch    = ObsCpio()
        os.makedirs(outdir)
        arch.extract_from_archive(repodir, files, outdir)
        for fname in files_expected:
            self.assertTrue(os.path.exists(
                os.path.join(outdir, fname)))
 def test_obscpio_create_archive(self):
     tc_name              = inspect.stack()[0][3]
     cl_name              = self.__class__.__name__
     scm_object           = Git(self.cli, self.tasks)
     scm_object.clone_dir = os.path.join(self.fixtures_dir, tc_name, 'repo')
     scm_object.arch_dir  = os.path.join(self.fixtures_dir, tc_name, 'repo')
     outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                         'out')
     self.cli.outdir      = outdir
     arch                 = ObsCpio()
     os.makedirs(outdir)
     arch.create_archive(
         scm_object,
         cli      = self.cli,
         basename = 'test',
         dstname  = 'test',
         version  = '0.1.1'
     )
示例#10
0
    def test_obscpio_create_archive(self):
        tc_name              = inspect.stack()[0][3]
        cl_name              = self.__class__.__name__
        c_dir                = os.path.join(self.tmp_dir, tc_name)
        f_dir                = os.path.join(self.fixtures_dir, tc_name, 'repo')
        shutil.copytree(f_dir, c_dir)
        scmlogs              = ScmInvocationLogs('git', c_dir)
        scmlogs.nextlog('start-test')
        fixture              = GitFixtures(c_dir, scmlogs)
        fixture.init()
        scm_object           = Git(self.cli, self.tasks)
        scm_object.clone_dir = fixture.repo_path
        scm_object.arch_dir  = fixture.repo_path
        outdir               = os.path.join(self.tmp_dir, cl_name, tc_name,
                                            'out')

        self.cli.outdir      = outdir
        arch                 = ObsCpio()
        os.makedirs(outdir)
        version  = '0.1.1'
        (dst, chgv, bname) = self.tasks._dstname(scm_object, version)
        arch.create_archive(
            scm_object,
            cli      = self.cli,
            basename = bname,
            dstname  = dst,
            version  = chgv
        )
        cpiofile = os.path.join(outdir, "%s-%s.obscpio" % (bname, version))
        infofile = os.path.join(outdir, bname + ".obsinfo")
        self.assertTrue(os.path.isfile(cpiofile))
        self.assertTrue(os.path.isfile(infofile))
        with io.open(infofile, 'r', encoding='UTF-8') as fhl:
            data = yaml.safe_load(fhl)
        self.assertDictEqual(
            data, {
                'name': bname,
                'version': chgv,
                'mtime': 1234567890,
                'commit': data['commit']})
    def test_obscpio_extract_nef(self):
        '''
        Test obscpio to extract non existant file from archive
        '''
        tc_name = inspect.stack()[0][3]
        cl_name = self.__class__.__name__

        repodir = os.path.join(self.fixtures_dir, tc_name, 'repo')
        files = ['nonexistantfile']
        outdir = os.path.join(self.tmp_dir, cl_name, tc_name, 'out')
        arch = ObsCpio()
        os.makedirs(outdir)
        six.assertRaisesRegex(self, SystemExit,
                              re.compile('No such file or directory'),
                              arch.extract_from_archive, repodir, files,
                              outdir)