From 7e42923dcca470dc47e16ac9ed3d98c253c57974 Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Mon, 3 Feb 2020 17:26:46 +0100 Subject: 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. --- test/test_api.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'test/test_api.py') 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')) -- cgit v1.2.3