| |
@@ -108,3 +108,35 @@
|
| |
|
| |
mbs = MBS('http://mbs.example.com')
|
| |
self.assertFalse(mbs.module_has_requires(604, {'platform': 'f28'}))
|
| |
+
|
| |
+ def test_get_modules_with_requires(self):
|
| |
+ mbs_resp_data = self.load_json_from_file('test_get_modules_with_requires.json')
|
| |
+ mbs = MBS('http://mbs.example.com')
|
| |
+
|
| |
+ # name, stream, requires, buildrequires, expected module build ids
|
| |
+ test_matrix = (
|
| |
+ ('testmodule', 'rhel-8.0', None, None, [604, 605]),
|
| |
+ ('testmodule', 'rhel-8.0', {'platform': 'el8'}, None, [604, 605]),
|
| |
+ ('testmodule', 'rhel-8.0', None, {'platform': 'el8'}, [604]),
|
| |
+ ('testmodule', 'rhel-8.0', {'platform': 'el8'}, {'platform': 'el8'}, [604]),
|
| |
+ ('testmodule', 'rhel-8.0', {'platform': 'f30'}, None, []),
|
| |
+ ('testmodule', 'rhel-8.0', {'platform': 'f30'}, {'platform': 'f30'}, []),
|
| |
+ ('testmodule', 'rhel-8.0', None, {'platform': 'f30'}, []),
|
| |
+ )
|
| |
+
|
| |
+ for name, stream, requires, buildrequires, expected_build_ids in test_matrix:
|
| |
+ with mock.patch('ursa_major.mbs.requests.get') as get:
|
| |
+ get.return_value = MockResponse(mbs_resp_data, 200)
|
| |
+
|
| |
+ module_builds = mbs.get_modules_with_requires(
|
| |
+ name=name,
|
| |
+ stream=stream,
|
| |
+ requires=requires,
|
| |
+ buildrequires=buildrequires)
|
| |
+
|
| |
+ get.assert_called_once_with(
|
| |
+ mbs.module_builds_api_url,
|
| |
+ params={'name': name, 'stream': stream, 'verbose': 'true'})
|
| |
+
|
| |
+ build_ids = sorted(build_info['id'] for build_info in module_builds)
|
| |
+ assert expected_build_ids == build_ids
|
| |
Signed-off-by: Chenxiong Qi cqi@redhat.com