summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jenkins_jobs/modules/view_all.py49
-rw-r--r--setup.cfg1
-rw-r--r--tests/base.py5
-rw-r--r--tests/views/fixtures/view-all-minimal.xml8
-rw-r--r--tests/views/fixtures/view-all-minimal.yaml2
-rw-r--r--tests/views/test_views.py7
6 files changed, 71 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/view_all.py b/jenkins_jobs/modules/view_all.py
new file mode 100644
index 00000000..aa41d5c3
--- /dev/null
+++ b/jenkins_jobs/modules/view_all.py
@@ -0,0 +1,49 @@
+# Copyright 2018 Openstack Foundation
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+View support for All view-type.
+
+To create an all view specify ``all`` in the ``view-type`` attribute
+to the :ref:`view_all` definition.
+
+Example:
+
+ .. literalinclude::
+ /../../tests/views/fixtures/view-all-minimal.yaml
+"""
+
+import xml.etree.ElementTree as XML
+import jenkins_jobs.modules.base
+import jenkins_jobs.modules.helpers as helpers
+
+
+class All(jenkins_jobs.modules.base.Base):
+ sequence = 0
+
+ def root_xml(self, data):
+ root = XML.Element('hudson.model.AllView')
+
+ mapping = [
+ ('name', 'name', None),
+ ('description', 'description', ''),
+ ('filter-executors', 'filterExecutors', False),
+ ('filter-queue', 'filterQueue', False),
+ ]
+ helpers.convert_mapping_to_xml(root, data, mapping, fail_required=True)
+
+ XML.SubElement(root, 'properties',
+ {'class': 'hudson.model.View$PropertyList'})
+
+ return root
diff --git a/setup.cfg b/setup.cfg
index e642b428..70097582 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -62,6 +62,7 @@ jenkins_jobs.projects =
pipeline=jenkins_jobs.modules.project_pipeline:Pipeline
workflow=jenkins_jobs.modules.project_workflow:Workflow
jenkins_jobs.views =
+ all=jenkins_jobs.modules.view_all:All
list=jenkins_jobs.modules.view_list:List
pipeline=jenkins_jobs.modules.view_pipeline:Pipeline
jenkins_jobs.builders =
diff --git a/tests/base.py b/tests/base.py
index 1f233b0a..514b83c4 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -43,6 +43,7 @@ from jenkins_jobs.modules import project_matrix
from jenkins_jobs.modules import project_maven
from jenkins_jobs.modules import project_multibranch
from jenkins_jobs.modules import project_multijob
+from jenkins_jobs.modules import view_all
from jenkins_jobs.modules import view_list
from jenkins_jobs.modules import view_pipeline
from jenkins_jobs.parser import YamlParser
@@ -197,7 +198,9 @@ class BaseScenariosTestCase(testscenarios.TestWithScenarios, BaseTestCase):
project = project_externaljob.ExternalJob(registry)
if 'view-type' in yaml_content:
- if yaml_content['view-type'] == "list":
+ if yaml_content['view-type'] == "all":
+ project = view_all.All(None)
+ elif yaml_content['view-type'] == "list":
project = view_list.List(None)
elif yaml_content['view-type'] == "pipeline":
project = view_pipeline.Pipeline(None)
diff --git a/tests/views/fixtures/view-all-minimal.xml b/tests/views/fixtures/view-all-minimal.xml
new file mode 100644
index 00000000..32a30b38
--- /dev/null
+++ b/tests/views/fixtures/view-all-minimal.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<hudson.model.AllView>
+ <name>All</name>
+ <description/>
+ <filterExecutors>false</filterExecutors>
+ <filterQueue>false</filterQueue>
+ <properties class="hudson.model.View$PropertyList"/>
+</hudson.model.AllView>
diff --git a/tests/views/fixtures/view-all-minimal.yaml b/tests/views/fixtures/view-all-minimal.yaml
new file mode 100644
index 00000000..6b512a0f
--- /dev/null
+++ b/tests/views/fixtures/view-all-minimal.yaml
@@ -0,0 +1,2 @@
+name: All
+view-type: all
diff --git a/tests/views/test_views.py b/tests/views/test_views.py
index 1f9924fc..4ce73330 100644
--- a/tests/views/test_views.py
+++ b/tests/views/test_views.py
@@ -13,11 +13,18 @@
# limitations under the License.import os
import os
+from jenkins_jobs.modules import view_all
from jenkins_jobs.modules import view_list
from jenkins_jobs.modules import view_pipeline
from tests import base
+class TestCaseModuleViewAll(base.BaseScenariosTestCase):
+ fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
+ scenarios = base.get_scenarios(fixtures_path)
+ klass = view_all.All
+
+
class TestCaseModuleViewList(base.BaseScenariosTestCase):
fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
scenarios = base.get_scenarios(fixtures_path)