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_repo_flags.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_repo_flags.py')
| -rw-r--r-- | test/test_repo_flags.py | 92 |
1 files changed, 7 insertions, 85 deletions
diff --git a/test/test_repo_flags.py b/test/test_repo_flags.py index 8219eef..d9b8642 100644 --- a/test/test_repo_flags.py +++ b/test/test_repo_flags.py @@ -34,88 +34,10 @@ xml2 = """<package name="suse-hello-1.0" project="home:sbahling:obsapi:test"> flag_types = ['build', 'publish', 'useforbuild', 'debuginfo'] -def test_repo_flags_default_type(): - repo_flags = RepoFlags() - assert repo_flags.flag_type == 'build' - - -@pytest.mark.parametrize('flag_type', flag_types) -def test_repo_flags_flag_type(flag_type): - repo_flags = RepoFlags(flag_type) - assert repo_flags.flag_type == flag_type - assert repo_flags.root.tag == flag_type - - -def test_repo_flags_invalid_flag_type(): - with pytest.raises(ValueError): - RepoFlags('invalid') - - -def test_repo_flags_pass_xml_without_flags(): - repo_flags = RepoFlags(xml=xml1) - assert repo_flags.flag_type == 'build' - - -def test_repo_flags_pass_xml_with_flags(): - repo_flags = RepoFlags(xml=xml2) - assert repo_flags.flag_type in flag_types - - -def test_repo_flags_xml_build_flags(): - repo_flags = RepoFlags('build', xml=xml2) - assert repo_flags.flag_type == 'build' - for flag in repo_flags.flags: - if flag.status == 'enable': - assert flag.repository == 'SLE_12_SP3' - assert flag.arch == 'x86_64' - if flag.status == 'disable': - assert flag.repository is None - assert flag.arch is None - - -def test_repo_flags_xml_debuginfo_flags(): - repo_flags = RepoFlags('debuginfo', xml=xml2) - assert repo_flags.flag_type == 'debuginfo' - for flag in repo_flags.flags: - if flag.status == 'enable': - assert flag.repository is None - assert flag.arch is None - - -def test_repo_flags_xml_new_flags(): - repo_flags = RepoFlags('publish', xml=xml2) - assert repo_flags.flag_type == 'publish' - assert len(list(repo_flags.flags)) == 0 - - -params = [('useforbuild', 'SLE_15_SP1', 'x86_64'), - ('publish', None, None), - ('debuginfo', None, 'aarch64'), - ('build', 'SLE_12_SP3', None) - ] - - -@pytest.mark.parametrize('flag_type, repo, arch', params) -def test_repo_flags_enable(flag_type, repo, arch): - repoflags = RepoFlags(flag_type) - repoflags.enable(repo=repo, arch=arch) - for flag in repoflags.flags: - assert flag.status == 'enable' - assert flag.repository == repo - assert flag.arch == arch - - -@pytest.mark.parametrize('flag_type, repo, arch', params) -def test_repo_flags_disable(flag_type, repo, arch): - repoflags = RepoFlags(flag_type) - repoflags.disable(repo=repo, arch=arch) - for flag in repoflags.flags: - assert flag.status == 'disable' - assert flag.repository == repo - assert flag.arch == arch - - -def test_repo_flags_set_invalid(): - repoflags = RepoFlags() - with pytest.raises(ValueError): - repoflags.set('invalid') +def test_flag_types(): + repoflags = RepoFlags(xml2) + flag_types = repoflags.flag_types + assert len(flag_types) == 3 + assert 'build' in flag_types + assert 'useforbuild' in flag_types + assert 'debuginfo' in flag_types |
