diff options
| author | Scott Bahling <sbahling@suse.com> | 2020-02-03 17:26:46 +0100 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.com> | 2020-02-03 17:26:46 +0100 |
| commit | 7e42923dcca470dc47e16ac9ed3d98c253c57974 (patch) | |
| tree | 6b9a92c36c0dee2d3e2c8a8a2f95c1919f4ae787 /test/test_api.py | |
| parent | 6eb3d336cdcc06078cd2629be5e2cbabae29eff6 (diff) | |
| download | obsapi-7e42923dcca470dc47e16ac9ed3d98c253c57974.tar.gz obsapi-7e42923dcca470dc47e16ac9ed3d98c253c57974.tar.xz obsapi-7e42923dcca470dc47e16ac9ed3d98c253c57974.zip | |
Re-architect the RepoFlags class
We don't need to create flags - just read and parse them from
the project meta config. Remove the unneeded functionality and
enhance the structure. All flags from a project and package
are accessible via a single RepoFlags object.
Diffstat (limited to 'test/test_api.py')
| -rw-r--r-- | test/test_api.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/test/test_api.py b/test/test_api.py index c8e40b2..5769543 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -357,24 +357,31 @@ def test_get_binary_fileinfo(requests_mock, binary_fileinfo): assert bfinfo.requires == [p.text for p in expected_bfinfo.findall('requires')] -def check_get_repo_flags(flag_type, prj, pkg, expected): - repo_flags = api.get_repo_flags(flag_type, prj, pkg) - assert repo_flags.flag_type == flag_type - assert len(list(repo_flags.flags)) == expected - - -def test_get_project_repo_build_flags(requests_mock, project_meta): +def test_get_project_flags(requests_mock, project_meta): matcher = prj_meta_re requests_mock.get(matcher, text=project_meta) - check_get_repo_flags('build', prj, None, 0) + repoflags = api.get_repo_flags(prj) + assert repoflags.flag_types == set() -def test_get_package_repo_build_flags(requests_mock, package_meta): +def test_get_package_repo_flags(requests_mock, package_meta): matcher = pkg_meta_re requests_mock.get(matcher, text=package_meta) + repoflags = api.get_repo_flags(prj, pkg) + assert repoflags.flag_types == {'build', 'debuginfo', 'useforbuild'} meta = etree.fromstring(package_meta) - expected_repoflags = meta.find('build') - check_get_repo_flags('build', prj, pkg, len(expected_repoflags)) + for element in meta: + for sub in element: + if sub.tag in ['enable', 'disable']: + flag = element.tag + status = sub.tag + repository = sub.get('repository', None) + arch = sub.get('arch', None) + match = False + for flag in repoflags.get_flag(flag): + if flag.status == status and flag.repository == repository and flag.arch == arch: + match = True + assert match @pytest.mark.parametrize('target', ('project', 'package')) |
