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'
        )
Пример #5
0
 def test_cache_locking(self):
     scm = Git(self.cli, self.tasks)
     scm.clone_dir = '.'
     scm.lock_cache()
     fname = scm.lock_file.name
     scm.unlock_cache()
     assert os.path.exists(fname) == 0
Пример #6
0
 def test_method__dstname(self):
     '''
         basename != dstname
         basename is the package name or given by '--filename'
         dstname includes version string
         This is important for obscpio/obsinfo
     '''
     tc_name = inspect.stack()[0][3]
     version = '0.1.1'
     scm_object = Git(self.cli, self.tasks)
     scm_object.clone_dir = os.path.join(self.fixtures_dir, tc_name)
     (dst, chgv, bname) = self.tasks._dstname(scm_object, version)
     self.assertEqual(tc_name, bname)
     self.assertEqual('%s-%s' % (tc_name, version), dst)
     self.assertEqual(chgv, version)
 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'
     )
Пример #8
0
 def test_git_mirror_arg_insert(self):
     f_args  = FakeCli()
     f_tasks = FakeTasks()
     git = Git(f_args, f_tasks)
     git.fetch_specific_revision = mock.MagicMock()
     git.repodir = '/tmp'
     git.pardir = '/foo'
     clone_url = 'https://clone_url'
     clone_dir = '/tmp/clone_dir'
     git.url = clone_url
     git.clone_dir = clone_dir
     with mock.patch.object(Helpers, 'safe_run') as mock_save_run:
         git.fetch_upstream_scm()
         ((command,), kwargs) = mock_save_run.call_args  # noqa: E501 pylint: disable=W0612
         expected_command = [
             'git', '-c', 'http.proxy=http://myproxy', 'clone', '--mirror',
             clone_url, clone_dir]
         self.assertEqual(expected_command, command)
Пример #9
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']})