3 # Author: Jan Blunck <jblunck@suse.de>
9 cwd = os.path.abspath(os.path.dirname(__file__))
12 sys.path.insert(0, cwd + "/../../../build/swig/python")
14 from zypp import RepoInfo, Url, UrlSet, RepoType
16 repo_urls = [ "file:/mounts/mirror/SuSE/ftp.opensuse.org/srv/ftp/pub/opensuse/debug/update/11.1/",
17 "http://download.opensuse.org/debug/update/11.1/" ]
19 class RepoInfoTestCase(unittest.TestCase):
22 self.info = RepoInfo()
23 self.info.addBaseUrl(Url(repo_urls[0]))
24 self.info.addBaseUrl(Url(repo_urls[1]))
25 self.info.setAlias("default")
26 self.info.setName("default")
27 self.info.setEnabled(True)
28 self.info.setType(RepoType.RPMMD)
29 self.info.setGpgCheck(False)
31 def testUrlSetIsUrlSet(self):
33 assert urls.__class__.__name__ == "UrlSet", 'Incorrect class (' + urls.__class__.__name__ + ')'
35 def testUrlSetAppend(self):
37 urls.append(Url(repo_urls[0]))
38 urls.append(Url(repo_urls[1]))
39 assert urls.size() == 2, 'Incorrect size ' + urls.size()
41 def testBaseUrlsReturnsTuple(self):
42 baseurls = self.info.baseUrls()
43 assert baseurls.__class__.__name__ == "tuple", 'Incorrect class (' + baseurls.__class__.__name__ + ')'
45 def testBaseUrlsIteratable(self):
46 baseurls = self.info.baseUrls()
48 assert url.__str__() in repo_urls, 'Incorrect URL ' + url.__str__()
50 def testSetBaseUrl(self):
51 baseurls = self.info.baseUrls()
52 assert len(baseurls) == 2
53 self.info.setBaseUrl(Url(repo_urls[0]))
54 baseurls = self.info.baseUrls()
55 assert len(baseurls) == 1
58 out = self.info.dump()
59 assert len(out) == 396, 'Invalid output length %d' % len(out)
61 def testDumpIni(self):
62 out = self.info.dumpAsIni()
63 assert len(out) == 208, 'Invalid output length %d' % len(out)
65 def testDumpXML(self):
66 out = self.info.dumpAsXML()
67 assert len(out) == 253, 'Invalid output length %d' % len(out)
69 if __name__ == "__main__":