Esempio n. 1
0
 def setUp(self):
     self.info = RepoInfo()
     self.info.addBaseUrl(Url(repo_urls[0]))
     self.info.addBaseUrl(Url(repo_urls[1]))
     self.info.setAlias("default")
     self.info.setName("default")
     self.info.setEnabled(True)
     self.info.setType(RepoType.RPMMD)
     self.info.setGpgCheck(False)
Esempio n. 2
0
class RepoInfoTestCase(unittest.TestCase):

    def setUp(self):
        self.info = RepoInfo()
        self.info.addBaseUrl(Url(repo_urls[0]))
        self.info.addBaseUrl(Url(repo_urls[1]))
        self.info.setAlias("default")
        self.info.setName("default")
        self.info.setEnabled(True)
        self.info.setType(RepoType.RPMMD)
        self.info.setGpgCheck(False)

    def testUrlSetIsUrlSet(self):
        urls = UrlSet()
        assert urls.__class__.__name__ == "UrlSet", 'Incorrect class (' + urls.__class__.__name__ + ')'

    def testUrlSetAppend(self):
        urls = UrlSet()
        urls.append(Url(repo_urls[0]))
        urls.append(Url(repo_urls[1]))
        assert urls.size() == 2, 'Incorrect size ' + urls.size()

    def testBaseUrlsReturnsTuple(self):
        baseurls = self.info.baseUrls()
        assert baseurls.__class__.__name__ == "tuple", 'Incorrect class (' + baseurls.__class__.__name__ + ')'

    def testBaseUrlsIteratable(self):
        baseurls = self.info.baseUrls()
        for url in baseurls:
            assert url.__str__() in repo_urls, 'Incorrect URL ' + url.__str__()

    def testSetBaseUrl(self):
        baseurls = self.info.baseUrls()
        assert len(baseurls) == 2
        self.info.setBaseUrl(Url(repo_urls[0]))
        baseurls = self.info.baseUrls()
        assert len(baseurls) == 1
Esempio n. 3
0
#!/usr/bin/python

from zypp import TmpDir, RepoManagerOptions, RepoManager, RepoInfo, Url

tmp_root=TmpDir()
repo_manager = RepoManager(RepoManagerOptions(tmp_root.path()))

repo_info = RepoInfo()

repo_info.setAlias("factorytest")
repo_info.setName("Test Repo for Factory.")
repo_info.setEnabled(True)
repo_info.setAutorefresh(False)
repo_info.addBaseUrl(Url("file:///tmp/does-not-exist"))

try:
    repo_manager.addRepository(repo_info)
    repo_manager.refreshMetadata(repo_info)
    repo_manager.buildCache(repo_info)
except RuntimeError, strerror:
    print "RuntimeError"
    print strerror
else:
    print "Oh, no exception"