diff --git a/tests/duplicates/fixtures/allow_duplicates001.conf b/tests/duplicates/job_fixtures/allow_duplicates001.conf similarity index 100% rename from tests/duplicates/fixtures/allow_duplicates001.conf rename to tests/duplicates/job_fixtures/allow_duplicates001.conf diff --git a/tests/duplicates/fixtures/allow_duplicates001.xml b/tests/duplicates/job_fixtures/allow_duplicates001.xml similarity index 100% rename from tests/duplicates/fixtures/allow_duplicates001.xml rename to tests/duplicates/job_fixtures/allow_duplicates001.xml diff --git a/tests/duplicates/fixtures/allow_duplicates001.yaml b/tests/duplicates/job_fixtures/allow_duplicates001.yaml similarity index 100% rename from tests/duplicates/fixtures/allow_duplicates001.yaml rename to tests/duplicates/job_fixtures/allow_duplicates001.yaml diff --git a/tests/duplicates/fixtures/allow_job_group001.conf b/tests/duplicates/job_fixtures/allow_job_group001.conf similarity index 100% rename from tests/duplicates/fixtures/allow_job_group001.conf rename to tests/duplicates/job_fixtures/allow_job_group001.conf diff --git a/tests/duplicates/fixtures/allow_job_group001.xml b/tests/duplicates/job_fixtures/allow_job_group001.xml similarity index 100% rename from tests/duplicates/fixtures/allow_job_group001.xml rename to tests/duplicates/job_fixtures/allow_job_group001.xml diff --git a/tests/duplicates/fixtures/allow_job_group001.yaml b/tests/duplicates/job_fixtures/allow_job_group001.yaml similarity index 100% rename from tests/duplicates/fixtures/allow_job_group001.yaml rename to tests/duplicates/job_fixtures/allow_job_group001.yaml diff --git a/tests/duplicates/fixtures/allow_macros001.conf b/tests/duplicates/job_fixtures/allow_macros001.conf similarity index 100% rename from tests/duplicates/fixtures/allow_macros001.conf rename to tests/duplicates/job_fixtures/allow_macros001.conf diff --git a/tests/duplicates/fixtures/allow_macros001.xml b/tests/duplicates/job_fixtures/allow_macros001.xml similarity index 100% rename from tests/duplicates/fixtures/allow_macros001.xml rename to tests/duplicates/job_fixtures/allow_macros001.xml diff --git a/tests/duplicates/fixtures/allow_macros001.yaml b/tests/duplicates/job_fixtures/allow_macros001.yaml similarity index 100% rename from tests/duplicates/fixtures/allow_macros001.yaml rename to tests/duplicates/job_fixtures/allow_macros001.yaml diff --git a/tests/duplicates/fixtures/allow_projects001.conf b/tests/duplicates/job_fixtures/allow_projects001.conf similarity index 100% rename from tests/duplicates/fixtures/allow_projects001.conf rename to tests/duplicates/job_fixtures/allow_projects001.conf diff --git a/tests/duplicates/fixtures/allow_projects001.xml b/tests/duplicates/job_fixtures/allow_projects001.xml similarity index 100% rename from tests/duplicates/fixtures/allow_projects001.xml rename to tests/duplicates/job_fixtures/allow_projects001.xml diff --git a/tests/duplicates/fixtures/allow_projects001.yaml b/tests/duplicates/job_fixtures/allow_projects001.yaml similarity index 100% rename from tests/duplicates/fixtures/allow_projects001.yaml rename to tests/duplicates/job_fixtures/allow_projects001.yaml diff --git a/tests/duplicates/fixtures/allow_templates001.conf b/tests/duplicates/job_fixtures/allow_templates001.conf similarity index 100% rename from tests/duplicates/fixtures/allow_templates001.conf rename to tests/duplicates/job_fixtures/allow_templates001.conf diff --git a/tests/duplicates/fixtures/allow_templates001.xml b/tests/duplicates/job_fixtures/allow_templates001.xml similarity index 100% rename from tests/duplicates/fixtures/allow_templates001.xml rename to tests/duplicates/job_fixtures/allow_templates001.xml diff --git a/tests/duplicates/fixtures/allow_templates001.yaml b/tests/duplicates/job_fixtures/allow_templates001.yaml similarity index 100% rename from tests/duplicates/fixtures/allow_templates001.yaml rename to tests/duplicates/job_fixtures/allow_templates001.yaml diff --git a/tests/duplicates/fixtures/duplicates001.xml b/tests/duplicates/job_fixtures/duplicates001.xml similarity index 100% rename from tests/duplicates/fixtures/duplicates001.xml rename to tests/duplicates/job_fixtures/duplicates001.xml diff --git a/tests/duplicates/fixtures/duplicates001.yaml b/tests/duplicates/job_fixtures/duplicates001.yaml similarity index 100% rename from tests/duplicates/fixtures/duplicates001.yaml rename to tests/duplicates/job_fixtures/duplicates001.yaml diff --git a/tests/duplicates/fixtures/duplicates002.xml b/tests/duplicates/job_fixtures/duplicates002.xml similarity index 100% rename from tests/duplicates/fixtures/duplicates002.xml rename to tests/duplicates/job_fixtures/duplicates002.xml diff --git a/tests/duplicates/fixtures/duplicates002.yaml b/tests/duplicates/job_fixtures/duplicates002.yaml similarity index 100% rename from tests/duplicates/fixtures/duplicates002.yaml rename to tests/duplicates/job_fixtures/duplicates002.yaml diff --git a/tests/duplicates/fixtures/exception_duplicates001.yaml b/tests/duplicates/job_fixtures/exception_duplicates001.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_duplicates001.yaml rename to tests/duplicates/job_fixtures/exception_duplicates001.yaml diff --git a/tests/duplicates/fixtures/exception_duplicates002.yaml b/tests/duplicates/job_fixtures/exception_duplicates002.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_duplicates002.yaml rename to tests/duplicates/job_fixtures/exception_duplicates002.yaml diff --git a/tests/duplicates/fixtures/exception_job_group001.yaml b/tests/duplicates/job_fixtures/exception_job_group001.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_job_group001.yaml rename to tests/duplicates/job_fixtures/exception_job_group001.yaml diff --git a/tests/duplicates/fixtures/exception_macros001.yaml b/tests/duplicates/job_fixtures/exception_macros001.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_macros001.yaml rename to tests/duplicates/job_fixtures/exception_macros001.yaml diff --git a/tests/duplicates/fixtures/exception_projects001.yaml b/tests/duplicates/job_fixtures/exception_projects001.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_projects001.yaml rename to tests/duplicates/job_fixtures/exception_projects001.yaml diff --git a/tests/duplicates/fixtures/exception_projects002.yaml b/tests/duplicates/job_fixtures/exception_projects002.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_projects002.yaml rename to tests/duplicates/job_fixtures/exception_projects002.yaml diff --git a/tests/duplicates/fixtures/exception_projects003.yaml b/tests/duplicates/job_fixtures/exception_projects003.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_projects003.yaml rename to tests/duplicates/job_fixtures/exception_projects003.yaml diff --git a/tests/duplicates/fixtures/exception_templates001.yaml b/tests/duplicates/job_fixtures/exception_templates001.yaml similarity index 100% rename from tests/duplicates/fixtures/exception_templates001.yaml rename to tests/duplicates/job_fixtures/exception_templates001.yaml diff --git a/tests/duplicates/test_duplicates.py b/tests/duplicates/test_job_duplicates.py similarity index 95% rename from tests/duplicates/test_duplicates.py rename to tests/duplicates/test_job_duplicates.py index 79b883efe..db2e03b97 100644 --- a/tests/duplicates/test_duplicates.py +++ b/tests/duplicates/test_job_duplicates.py @@ -22,7 +22,7 @@ from jenkins_jobs.errors import JenkinsJobsException from tests.enum_scenarios import scenario_list -fixtures_dir = Path(__file__).parent / "fixtures" +fixtures_dir = Path(__file__).parent / "job_fixtures" @pytest.fixture( diff --git a/tests/duplicates/test_view_duplicates.py b/tests/duplicates/test_view_duplicates.py new file mode 100644 index 000000000..280f464ad --- /dev/null +++ b/tests/duplicates/test_view_duplicates.py @@ -0,0 +1,27 @@ +from operator import attrgetter +from pathlib import Path + +import pytest + +from jenkins_jobs.errors import JenkinsJobsException +from tests.enum_scenarios import scenario_list + + +fixtures_dir = Path(__file__).parent / "view_fixtures" + + +@pytest.fixture( + params=scenario_list(fixtures_dir), + ids=attrgetter("name"), +) +def scenario(request): + return request.param + + +def test_yaml_snippet(scenario, check_view): + if scenario.in_path.name.startswith("exception_"): + with pytest.raises(JenkinsJobsException) as excinfo: + check_view() + assert str(excinfo.value).startswith("Duplicate ") + else: + check_view() diff --git a/tests/duplicates/view_fixtures/duplicate_views_in_project.xml b/tests/duplicates/view_fixtures/duplicate_views_in_project.xml new file mode 100644 index 000000000..bdf114f67 --- /dev/null +++ b/tests/duplicates/view_fixtures/duplicate_views_in_project.xml @@ -0,0 +1,16 @@ + + + sample-template-1.1 + Views for version 1.1<!-- Managed by Jenkins Job Builder --> + false + false + + + + + sample-template-2.0 + Views for version 2.0<!-- Managed by Jenkins Job Builder --> + false + false + + diff --git a/tests/duplicates/view_fixtures/duplicate_views_in_project.yaml b/tests/duplicates/view_fixtures/duplicate_views_in_project.yaml new file mode 100644 index 000000000..02c582c90 --- /dev/null +++ b/tests/duplicates/view_fixtures/duplicate_views_in_project.yaml @@ -0,0 +1,12 @@ +- view-template: + name: sample-template-{version} + view-type: all + description: 'Views for version {version}' + +- project: + name: sample-project + version: 1.1 + views: + - sample-template-{version} + - sample-template-{version}: + version: 2.0 diff --git a/tests/duplicates/view_fixtures/exception_duplicate_view.yaml b/tests/duplicates/view_fixtures/exception_duplicate_view.yaml new file mode 100644 index 000000000..b74804eb9 --- /dev/null +++ b/tests/duplicates/view_fixtures/exception_duplicate_view.yaml @@ -0,0 +1,7 @@ +- view: + name: duplicate-view + view-type: all + +- view: + name: duplicate-view + view-type: all diff --git a/tests/duplicates/view_fixtures/exception_duplicate_view_template.yaml b/tests/duplicates/view_fixtures/exception_duplicate_view_template.yaml new file mode 100644 index 000000000..d3a8c6280 --- /dev/null +++ b/tests/duplicates/view_fixtures/exception_duplicate_view_template.yaml @@ -0,0 +1,12 @@ +- view-template: + name: duplicate-view-template + view-type: all + +- view-template: + name: duplicate-view-template + view-type: all + +- project: + name: sample-project + views: + - duplicate-view-template diff --git a/tests/duplicates/view_fixtures/exception_duplicate_views_in_project.yaml b/tests/duplicates/view_fixtures/exception_duplicate_views_in_project.yaml new file mode 100644 index 000000000..f51c737d0 --- /dev/null +++ b/tests/duplicates/view_fixtures/exception_duplicate_views_in_project.yaml @@ -0,0 +1,9 @@ +- view-template: + name: sample-template + view-type: all + +- project: + name: sample-project + views: + - sample-template + - sample-template