[Kimchi-devel] [PATCH] issue #433: Fix repository tests

Crístian Viana vianac at linux.vnet.ibm.com
Mon Sep 22 12:53:37 UTC 2014


Commit 2696052 has introduced bugs in the tests which could only be
reproducible when running on Ubuntu.

Fix the tests by using correct "fake" repositories values and validating URLs
even when updating repositories.

Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
---
 src/kimchi/repositories.py |  2 ++
 tests/test_model.py        | 18 +++++++-----------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/kimchi/repositories.py b/src/kimchi/repositories.py
index 676b7c2..1d19fb7 100644
--- a/src/kimchi/repositories.py
+++ b/src/kimchi/repositories.py
@@ -489,6 +489,8 @@ class AptRepo(object):
                 'config': {'type': 'deb', 'dist': r.dist,
                            'comps': r.comps}}
 
+        validate_repo_url(info['baseurl'])
+
         if 'config' in params.keys():
             config = params['config']
             info['config']['dist'] = config.get('dist', r.dist)
diff --git a/tests/test_model.py b/tests/test_model.py
index ceedc6f..b03b6aa 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1290,9 +1290,9 @@ class ModelTests(unittest.TestCase):
                       {'mirrorlist': 'http://www.fedoraproject.org',
                        'gpgkey': 'file:///tmp/KEY-fedora-updates-fake-19'}}]
 
-        deb_repos = [{'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+        deb_repos = [{'baseurl': 'http://archive.ubuntu.com/ubuntu/',
                       'config': {'dist': 'quantal'}},
-                     {'baseurl': 'http://br.archive.kimchi.com/ubuntu/fake',
+                     {'baseurl': 'http://archive.ubuntu.com/ubuntu/',
                       'config': {'dist': 'quantal', 'comps': ['main']}}]
 
         repo_type = inst.capabilities_lookup()['repo_mngt_tool']
@@ -1320,6 +1320,7 @@ class ModelTests(unittest.TestCase):
         # create repositories with invalid mirrorlist
         for url in invalid_urls:
             repo = {'repo_id': 'repo_fake',
+                    'baseurl': url,
                     'config': {'mirrorlist': url, 'dist': 'quantal'}}
             self.assertRaises(InvalidParameter, inst.repositories_create, repo)
 
@@ -1360,9 +1361,10 @@ class ModelTests(unittest.TestCase):
                     'baseurl': 'http://www.fedora.org'}
         yum_new_repo = {'baseurl': 'http://www.fedoraproject.org'}
 
-        deb_repo = {'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+        deb_repo = {'baseurl': 'http://archive.ubuntu.com/ubuntu/',
                     'config': {'dist': 'quantal'}}
-        deb_new_repo = {'baseurl': 'http://archive.canonical.com/kimchi'}
+        deb_new_repo = {'baseurl': 'http://br.archive.canonical.com/ubuntu/',
+                        'config': {'dist': 'utopic'}}
 
         repo_type = inst.capabilities_lookup()['repo_mngt_tool']
         if repo_type == 'yum':
@@ -1393,12 +1395,6 @@ class ModelTests(unittest.TestCase):
             self.assertRaises(InvalidParameter, inst.repository_update,
                               repo_id, wrong_repo)
 
-        # update repositories with invalid mirrorlist
-        for url in invalid_urls:
-            wrong_repo = {'config': {'mirrorlist': url}}
-            self.assertRaises(InvalidParameter, inst.repository_update,
-                              repo_id, wrong_repo)
-
         new_repo_id = inst.repository_update(repo_id, new_repo)
         repo_info = inst.repository_lookup(new_repo_id)
 
@@ -1415,7 +1411,7 @@ class ModelTests(unittest.TestCase):
 
         yum_repo = {'repo_id': 'fedora-fake',
                     'baseurl': 'http://www.fedora.org'}
-        deb_repo = {'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+        deb_repo = {'baseurl': 'http://archive.ubuntu.com/ubuntu/',
                     'config': {'dist': 'quantal'}}
 
         repo_type = inst.capabilities_lookup()['repo_mngt_tool']
-- 
1.9.3




More information about the Kimchi-devel mailing list