[Kimchi-devel] [PATCH 09/10] Update test cases to reflect the repositories changes
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Mar 18 17:04:14 UTC 2014
From: Aline Manera <alinefm at br.ibm.com>
Based on the lastest repositories changes we need to update the test cases.
And make sure to create the correct repository type according to the system.
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
tests/test_model.py | 151 +++++++++++++++++++++++++++++++--------------------
tests/test_rest.py | 10 ++--
2 files changed, 98 insertions(+), 63 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 60d0b94..c8c54c0 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -989,101 +989,136 @@ class ModelTests(unittest.TestCase):
inst = model.Model('test:///default',
objstore_loc=self.tmp_store)
- system_host_repos = len(inst.repositories_get_list())
-
- test_repos = [{'repo_id': 'fedora-fake',
- 'baseurl': 'http://www.fedora.org'},
- {'repo_id': 'fedora-updates-fake',
- 'baseurl': 'http://www.fedora.org/updates',
- 'is_mirror': True,
- 'gpgkey': 'file:///tmp/KEY-fedora-updates-fake-19'}]
+ yum_repos = [{'repo_id': 'fedora-fake',
+ 'baseurl': 'http://www.fedora.org'},
+ {'repo_id': 'fedora-updates-fake',
+ 'config':
+ {'mirrorlist': 'http://www.fedora.org/updates',
+ 'gpgkey': 'file:///tmp/KEY-fedora-updates-fake-19'}}]
+
+ deb_repos = [{'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+ 'config': {'dist': 'quantal'}},
+ {'baseurl': 'http://br.archive.kimchi.com/ubuntu/fake',
+ 'config': {'dist': 'quantal', 'comps': ['main']}}]
+
+ repo_type = inst.capabilities_lookup()['repo_mngt_tool']
+ if repo_type == 'yum':
+ test_repos = yum_repos
+ elif repo_type == 'deb':
+ test_repos = deb_repos
+ else:
+ # repository management tool was not recognized by Kimchi
+ # skip test case
+ return
for repo in test_repos:
- inst.repositories_create(repo)
- host_repos = inst.repositories_get_list()
- self.assertEquals(system_host_repos + len(test_repos), len(host_repos))
+ system_host_repos = len(inst.repositories_get_list())
+ repo_id = inst.repositories_create(repo)
+ host_repos = inst.repositories_get_list()
+ self.assertEquals(system_host_repos + 1, len(host_repos))
- for repo in test_repos:
- repo_info = inst.repository_lookup(repo.get('repo_id'))
- self.assertEquals(repo.get('repo_id'), repo_info.get('repo_id'))
- self.assertEquals(repo.get('baseurl', []),
- repo_info.get('baseurl'))
- self.assertEquals(repo.get('is_mirror', False),
- repo_info.get('is_mirror'))
+ repo_info = inst.repository_lookup(repo_id)
+ self.assertEquals(repo_id, repo_info['repo_id'])
self.assertEquals(True, repo_info.get('enabled'))
+ self.assertEquals(repo.get('baseurl', ''),
+ repo_info.get('baseurl'))
+
+ original_config = repo.get('config', {})
+ config_info = repo_info.get('config', {})
- if 'gpgkey' in repo.keys():
- gpgcheck = True
+ if repo_type == 'yum':
+ self.assertEquals(original_config.get('mirrorlist', ''),
+ config_info.get('mirrorlist', ''))
+ self.assertEquals(True, config_info['gpgcheck'])
else:
- gpgcheck = False
+ self.assertEquals(original_config['dist'], config_info['dist'])
+ self.assertEquals(original_config.get('comps', []),
+ config_info.get('comps', []))
- self.assertEquals(gpgcheck, repo_info.get('gpgcheck'))
+ inst.repository_delete(repo_id)
+ self.assertRaises(NotFoundError, inst.repository_lookup, repo_id)
self.assertRaises(NotFoundError, inst.repository_lookup, 'google')
- # remove files created
- for repo in test_repos:
- inst.repository_delete(repo['repo_id'])
- self.assertRaises(NotFoundError,
- inst.repository_lookup, repo['repo_id'])
-
def test_repository_update(self):
inst = model.Model('test:///default',
objstore_loc=self.tmp_store)
- system_host_repos = len(inst.repositories_get_list())
+ yum_repo = {'repo_id': 'fedora-fake',
+ 'baseurl': 'http://www.fedora.org'}
+ yum_new_repo = {'baseurl': 'http://www.fedora.org/updates'}
+
+ deb_repo = {'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+ 'config': {'dist': 'quantal'}}
+ deb_new_repo = {'baseurl': 'http://archive.canonical.com/kimchi'}
+
+ repo_type = inst.capabilities_lookup()['repo_mngt_tool']
+ if repo_type == 'yum':
+ repo = yum_repo
+ new_repo = yum_new_repo
+ elif repo_type == 'deb':
+ repo = deb_repo
+ new_repo = deb_new_repo
+ else:
+ # repository management tool was not recognized by Kimchi
+ # skip test case
+ return
- repo = {'repo_id': 'fedora-fake',
- 'repo_name': 'Fedora 19 FAKE',
- 'baseurl': 'http://www.fedora.org'}
- inst.repositories_create(repo)
+ system_host_repos = len(inst.repositories_get_list())
+ repo_id = inst.repositories_create(repo)
host_repos = inst.repositories_get_list()
self.assertEquals(system_host_repos + 1, len(host_repos))
- new_repo = {'repo_id': 'fedora-fake',
- 'repo_name': 'Fedora 19 Update FAKE',
- 'baseurl': 'http://www.fedora.org/update'}
+ new_repo_id = inst.repository_update(repo_id, new_repo)
+ repo_info = inst.repository_lookup(new_repo_id)
- inst.repository_update(repo['repo_id'], new_repo)
- repo_info = inst.repository_lookup(new_repo.get('repo_id'))
- self.assertEquals(new_repo.get('repo_id'), repo_info.get('repo_id'))
- self.assertEquals(new_repo.get('repo_name'),
- repo_info.get('repo_name'))
- self.assertEquals(new_repo.get('baseurl', None),
- repo_info.get('baseurl'))
- self.assertEquals(True, repo_info.get('enabled'))
+ self.assertEquals(new_repo_id, repo_info['repo_id'])
+ self.assertEquals(new_repo['baseurl'], repo_info['baseurl'])
+ self.assertEquals(True, repo_info['enabled'])
# remove files creates
- inst.repository_delete(repo['repo_id'])
+ inst.repository_delete(new_repo_id)
def test_repository_disable_enable(self):
inst = model.Model('test:///default',
objstore_loc=self.tmp_store)
+ yum_repo = {'repo_id': 'fedora-fake',
+ 'baseurl': 'http://www.fedora.org'}
+ deb_repo = {'baseurl': 'http://br.archive.ubuntu.com/kimchi/fake',
+ 'config': {'dist': 'quantal'}}
+
+ repo_type = inst.capabilities_lookup()['repo_mngt_tool']
+ if repo_type == 'yum':
+ repo = yum_repo
+ elif repo_type == 'deb':
+ repo = deb_repo
+ else:
+ # repository management tool was not recognized by Kimchi
+ # skip test case
+ return
+
system_host_repos = len(inst.repositories_get_list())
- repo = {'repo_id': 'fedora-fake',
- 'repo_name': 'Fedora 19 FAKE',
- 'baseurl': 'http://www.fedora.org'}
- inst.repositories_create(repo)
+ repo_id = inst.repositories_create(repo)
host_repos = inst.repositories_get_list()
self.assertEquals(system_host_repos + 1, len(host_repos))
- repo_info = inst.repository_lookup(repo.get('repo_id'))
- self.assertEquals(True, repo_info.get('enabled'))
+ repo_info = inst.repository_lookup(repo_id)
+ self.assertEquals(True, repo_info['enabled'])
- inst.repository_disable(repo.get('repo_id'))
- repo_info = inst.repository_lookup(repo.get('repo_id'))
- self.assertEquals(False, repo_info.get('enabled'))
+ inst.repository_disable(repo_id)
+ repo_info = inst.repository_lookup(repo_id)
+ self.assertEquals(False, repo_info['enabled'])
- inst.repository_enable(repo.get('repo_id'))
- repo_info = inst.repository_lookup(repo.get('repo_id'))
- self.assertEquals(True, repo_info.get('enabled'))
+ inst.repository_enable(repo_id)
+ repo_info = inst.repository_lookup(repo_id)
+ self.assertEquals(True, repo_info['enabled'])
# remove files creates
- inst.repository_delete(repo['repo_id'])
+ inst.repository_delete(repo_id)
class BaseModelTests(unittest.TestCase):
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 831517f..fe8d3c4 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1594,8 +1594,7 @@ class RestTests(unittest.TestCase):
def test_repositories(self):
def verify_repo(t, res):
- for field in ('repo_id', 'repo_name', 'baseurl', 'is_mirror',
- 'url_args', 'enabled', 'gpgcheck', 'gpgkey'):
+ for field in ('repo_id', 'enabled', 'baseurl', 'config'):
if field in t.keys():
self.assertEquals(t[field], res[field])
@@ -1617,9 +1616,10 @@ class RestTests(unittest.TestCase):
verify_repo(repo, res)
# Update the repository
- repo['baseurl'] = 'http://www.fedora.org/update'
- req = json.dumps(repo)
- resp = self.request('%s/fedora-fake' % base_uri, req, 'PUT')
+ params = {}
+ params['baseurl'] = repo['baseurl'] = 'http://www.fedora.org/update'
+ resp = self.request('%s/fedora-fake' % base_uri, json.dumps(params),
+ 'PUT')
# Verify the repository
res = json.loads(self.request('%s/fedora-fake' % base_uri).read())
--
1.7.10.4
More information about the Kimchi-devel
mailing list