Пример #1
0
 def test4(self):
     """test list's return value"""
     Project.LIST_SCHEMA = self.fixture_file('directory.xsd')
     Package.LIST_SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('openSUSE:Factory')
     pkg = prj.list()[0]
     self.assertEqual(pkg.name, 'osc')
     files = pkg.list()
     self.assertTrue(len(files.entry[:]) == 2)
     self.assertEqual(files.get('name'), 'osc')
     self.assertEqual(files.get('rev'), '61')
     self.assertEqual(files.get('srcmd5'), 'fff')
     self.assertEqual(files.get('project'), 'openSUSE:Factory')
     self.assertEqual(files.entry[0].get('name'), 'osc-0.132.4.tar.gz')
     self.assertEqual(files.entry[0].get('md5'), 'abc')
     self.assertEqual(files.entry[0].get('size'), '269202')
     self.assertEqual(files.entry[0].get('mtime'), '1')
     # second entry
     self.assertEqual(files.entry[1].get('name'), 'osc.spec')
     self.assertEqual(files.entry[1].get('md5'), 'ef2')
     self.assertEqual(files.entry[1].get('size'), '3761')
     self.assertEqual(files.entry[1].get('mtime'), '14')
     # test file method
     f = files.entry[1].file()
     self.assertEqual(f.read(), '# this is\n# no spec\n')
Пример #2
0
 def test4(self):
     """test list's return value"""
     Project.LIST_SCHEMA = self.fixture_file('directory.xsd')
     Package.LIST_SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('openSUSE:Factory')
     pkg = prj.list()[0]
     self.assertEqual(pkg.name, 'osc')
     files = pkg.list()
     self.assertTrue(len(files.entry[:]) == 2)
     self.assertEqual(files.get('name'), 'osc')
     self.assertEqual(files.get('rev'), '61')
     self.assertEqual(files.get('srcmd5'), 'fff')
     self.assertEqual(files.get('project'), 'openSUSE:Factory')
     self.assertEqual(files.entry[0].get('name'), 'osc-0.132.4.tar.gz')
     self.assertEqual(files.entry[0].get('md5'), 'abc')
     self.assertEqual(files.entry[0].get('size'), '269202')
     self.assertEqual(files.entry[0].get('mtime'), '1')
     # second entry
     self.assertEqual(files.entry[1].get('name'), 'osc.spec')
     self.assertEqual(files.entry[1].get('md5'), 'ef2')
     self.assertEqual(files.entry[1].get('size'), '3761')
     self.assertEqual(files.entry[1].get('mtime'), '14')
     # test file method
     f = files.entry[1].file()
     self.assertEqual(f.read(), '# this is\n# no spec\n')
Пример #3
0
 def test1(self):
     """test package list"""
     Project.SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('openSUSE:Factory')
     pkgs = prj.list()
     self.assertTrue(len(pkgs) == 3)
     self.assertEqual(pkgs[0].name, 'osc')
     self.assertEqual(pkgs[1].name, 'glibc')
     self.assertEqual(pkgs[2].name, 'python')
Пример #4
0
 def test1(self):
     """test package list"""
     Project.SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('openSUSE:Factory')
     pkgs = prj.list()
     self.assertTrue(len(pkgs) == 3)
     self.assertEqual(pkgs[0].name, 'osc')
     self.assertEqual(pkgs[1].name, 'glibc')
     self.assertEqual(pkgs[2].name, 'python')
Пример #5
0
def list_project_or_all(renderer, project, info):
    """Lists projects content or all projects.

    illegal options: --%(opt)s is not supported at project or global level.

    """
    global PRJ_PKG_LIST_TEMPLATE
    if project is None:
        # FIXME: this is a bit hacky - better use a SourceListing class
        project = ''
    query = {'apiurl': info.apiurl}
    if info.deleted:
        query['deleted'] = '1'
    prj = Project(project)
    directory = prj.list(**query)
    renderer.render(PRJ_PKG_LIST_TEMPLATE, directory=directory, info=info)
Пример #6
0
def _list(info):
    expand = ''
    if hasattr(info, 'expand'):
        expand = info.expand
    if hasattr(info, 'package'):
        spkg = SourcePackage(info.project, info.package)
        directory = spkg.list(expand=expand)
        title = "%s: %s" % (os.path.join(
            info.project, info.package), directory.get('srcmd5'))
    else:
        title = info.project + ':'
        sprj = SourceProject(info.project)
        directory = sprj.list(expand=expand)
    print title
    for entry in directory:
        print entry.get('name')
Пример #7
0
def _list(info):
    expand = ''
    if hasattr(info, 'expand'):
        expand = info.expand
    if hasattr(info, 'package'):
        spkg = SourcePackage(info.project, info.package)
        directory = spkg.list(expand=expand)
        title = "%s: %s" % (os.path.join(info.project, info.package),
                            directory.get('srcmd5'))
    else:
        title = info.project + ':'
        sprj = SourceProject(info.project)
        directory = sprj.list(expand=expand)
    print title
    for entry in directory:
        print entry.get('name')
Пример #8
0
def list_project_or_all(renderer, project, info):
    """Lists projects content or all projects.

    illegal options: --%(opt)s is not supported at project or global level.

    """
    global PRJ_PKG_LIST_TEMPLATE
    if project is None:
        # FIXME: this is a bit hacky - better use a SourceListing class
        project = ''
    query = {'apiurl': info.apiurl}
    if info.deleted:
        query['deleted'] = '1'
    prj = Project(project)
    directory = prj.list(**query)
    renderer.render(PRJ_PKG_LIST_TEMPLATE, directory=directory, info=info)
Пример #9
0
 def _calculate_updateinfo(self, *packages):
     added = []
     deleted = []
     candidates = []
     conflicted = []
     sprj = SourceProject(self.name)
     remote_pkgs = [pkg.name for pkg in sprj.list(apiurl=self.apiurl)]
     local_pkgs = self.packages()
     for package in remote_pkgs:
         if package in local_pkgs:
             candidates.append(package)
         else:
             added.append(package)
     for package in local_pkgs:
         st = self._status(package)
         pkg = self.package(package)
         if pkg is not None and not pkg.is_updateable():
             conflicted.append(package)
         elif st != 'A' and package not in remote_pkgs:
             deleted.append(package)
     # check for conflicts
     for package in candidates[:]:
         pkg = self.package(package)
         if (self._status(package) in ('A', '!')
                 or not pkg.is_updateable()):
             conflicted.append(package)
             candidates.remove(package)
     for package in added[:]:
         path = os.path.join(self.path, package)
         st = self._status(package)
         if st == '?' and os.path.exists(path):
             conflicted.append(package)
             added.remove(package)
     if packages:
         # only consider specified packages
         candidates = [p for p in candidates if p in packages]
         added = [p for p in added if p in packages]
         deleted = [p for p in deleted if p in packages]
         conflicted = [p for p in conflicted if p in packages]
     return PackageUpdateInfo(self.name, candidates, added, deleted,
                              conflicted)
Пример #10
0
 def _calculate_updateinfo(self, *packages):
     added = []
     deleted = []
     candidates = []
     conflicted = []
     sprj = SourceProject(self.name)
     remote_pkgs = [pkg.name for pkg in sprj.list(apiurl=self.apiurl)]
     local_pkgs = self.packages()
     for package in remote_pkgs:
         if package in local_pkgs:
             candidates.append(package)
         else:
             added.append(package)
     for package in local_pkgs:
         st = self._status(package)
         pkg = self.package(package)
         if pkg is not None and not pkg.is_updateable():
             conflicted.append(package)
         elif st != 'A' and package not in remote_pkgs:
             deleted.append(package)
     # check for conflicts
     for package in candidates[:]:
         pkg = self.package(package)
         if (self._status(package) in ('A', '!')
                 or not pkg.is_updateable()):
             conflicted.append(package)
             candidates.remove(package)
     for package in added[:]:
         path = os.path.join(self.path, package)
         st = self._status(package)
         if st == '?' and os.path.exists(path):
             conflicted.append(package)
             added.remove(package)
     if packages:
         # only consider specified packages
         candidates = [p for p in candidates if p in packages]
         added = [p for p in added if p in packages]
         deleted = [p for p in deleted if p in packages]
         conflicted = [p for p in conflicted if p in packages]
     return PackageUpdateInfo(self.name, candidates, added, deleted,
                              conflicted)
Пример #11
0
 def test2(self):
     """test empty package list"""
     Project.LIST_SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('test')
     pkgs = prj.list()
     self.assertTrue(len(pkgs) == 0)
Пример #12
0
 def test3(self):
     """test invalid xml data (package list)"""
     Project.LIST_SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('openSUSE:Factory')
     self.assertRaises(etree.DocumentInvalid, prj.list)
Пример #13
0
 def test2(self):
     """test empty package list"""
     Project.LIST_SCHEMA = self.fixture_file('directory.xsd')
     prj = Project('test')
     pkgs = prj.list()
     self.assertTrue(len(pkgs) == 0)