Update get_system_repo for dnf

With dnf we iterate the repos and return their names, not the filenames
like we do with yum. Also make the list test more flexible.
This commit is contained in:
Brian C. Lane 2018-08-07 09:20:16 -07:00
parent 1d6d145854
commit a2a0477424

View File

@ -44,8 +44,7 @@ def get_system_repo():
for section in cfg.sections(): for section in cfg.sections():
try: try:
if cfg.get(section, "enabled") == "1": if cfg.get(section, "enabled") == "1":
# The API only supports repo filenames, return that. return section
return os.path.basename(sys_repo)[:-5]
except NoOptionError: except NoOptionError:
pass pass
@ -534,10 +533,9 @@ class ServerTestCase(unittest.TestCase):
resp = self.server.get("/api/v0/projects/source/list") resp = self.server.get("/api/v0/projects/source/list")
data = json.loads(resp.data) data = json.loads(resp.data)
self.assertNotEqual(data, None) self.assertNotEqual(data, None)
if self.rawhide: # Make sure it lists some common sources
self.assertEqual(data["sources"], ["lorax-1", "lorax-2", "lorax-3", "lorax-4", "other-repo", "rawhide", "single-repo"]) for r in ["lorax-1", "lorax-2", "lorax-3", "lorax-4", "other-repo", "single-repo"]:
else: self.assertTrue(r in data["sources"] )
self.assertEqual(data["sources"], ["fedora", "lorax-1", "lorax-2", "lorax-3", "lorax-4", "other-repo", "single-repo", "updates"])
def test_projects_source_00_info(self): def test_projects_source_00_info(self):
"""Test /api/v0/projects/source/info""" """Test /api/v0/projects/source/info"""