summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanh Ha <zxiiro@linux.com>2018-11-12 16:26:12 +0800
committerThanh Ha <zxiiro@linux.com>2018-11-12 16:55:39 +0800
commit8c99e569b50cb33286750d8a4919dba6bd6b267d (patch)
tree730f3b09ac135ac3fda982913d892de844938dfb
parent2854caec9e82ff22f3a8c086f881e10b5a0d418e (diff)
Add support for All view-type
Change-Id: I49774d6d177382f30f117dab3836619a40d0e895 Signed-off-by: Thanh Ha <zxiiro@linux.com>
Notes
Notes (review): Code-Review+1: Sorin Sbarnea <ssbarnea@redhat.com> Code-Review+2: Thanh Ha (zxiiro) <zxiiro@gmail.com> Workflow+1: Thanh Ha (zxiiro) <zxiiro@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 13 Nov 2018 03:30:18 +0000 Reviewed-on: https://review.openstack.org/617254 Project: openstack-infra/jenkins-job-builder Branch: refs/heads/master
-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 0000000..aa41d5c
--- /dev/null
+++ b/jenkins_jobs/modules/view_all.py
@@ -0,0 +1,49 @@
1# Copyright 2018 Openstack Foundation
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""
16View support for All view-type.
17
18To create an all view specify ``all`` in the ``view-type`` attribute
19to the :ref:`view_all` definition.
20
21Example:
22
23 .. literalinclude::
24 /../../tests/views/fixtures/view-all-minimal.yaml
25"""
26
27import xml.etree.ElementTree as XML
28import jenkins_jobs.modules.base
29import jenkins_jobs.modules.helpers as helpers
30
31
32class All(jenkins_jobs.modules.base.Base):
33 sequence = 0
34
35 def root_xml(self, data):
36 root = XML.Element('hudson.model.AllView')
37
38 mapping = [
39 ('name', 'name', None),
40 ('description', 'description', ''),
41 ('filter-executors', 'filterExecutors', False),
42 ('filter-queue', 'filterQueue', False),
43 ]
44 helpers.convert_mapping_to_xml(root, data, mapping, fail_required=True)
45
46 XML.SubElement(root, 'properties',
47 {'class': 'hudson.model.View$PropertyList'})
48
49 return root
diff --git a/setup.cfg b/setup.cfg
index e642b42..7009758 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -62,6 +62,7 @@ jenkins_jobs.projects =
62 pipeline=jenkins_jobs.modules.project_pipeline:Pipeline 62 pipeline=jenkins_jobs.modules.project_pipeline:Pipeline
63 workflow=jenkins_jobs.modules.project_workflow:Workflow 63 workflow=jenkins_jobs.modules.project_workflow:Workflow
64jenkins_jobs.views = 64jenkins_jobs.views =
65 all=jenkins_jobs.modules.view_all:All
65 list=jenkins_jobs.modules.view_list:List 66 list=jenkins_jobs.modules.view_list:List
66 pipeline=jenkins_jobs.modules.view_pipeline:Pipeline 67 pipeline=jenkins_jobs.modules.view_pipeline:Pipeline
67jenkins_jobs.builders = 68jenkins_jobs.builders =
diff --git a/tests/base.py b/tests/base.py
index 1f233b0..514b83c 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -43,6 +43,7 @@ from jenkins_jobs.modules import project_matrix
43from jenkins_jobs.modules import project_maven 43from jenkins_jobs.modules import project_maven
44from jenkins_jobs.modules import project_multibranch 44from jenkins_jobs.modules import project_multibranch
45from jenkins_jobs.modules import project_multijob 45from jenkins_jobs.modules import project_multijob
46from jenkins_jobs.modules import view_all
46from jenkins_jobs.modules import view_list 47from jenkins_jobs.modules import view_list
47from jenkins_jobs.modules import view_pipeline 48from jenkins_jobs.modules import view_pipeline
48from jenkins_jobs.parser import YamlParser 49from jenkins_jobs.parser import YamlParser
@@ -197,7 +198,9 @@ class BaseScenariosTestCase(testscenarios.TestWithScenarios, BaseTestCase):
197 project = project_externaljob.ExternalJob(registry) 198 project = project_externaljob.ExternalJob(registry)
198 199
199 if 'view-type' in yaml_content: 200 if 'view-type' in yaml_content:
200 if yaml_content['view-type'] == "list": 201 if yaml_content['view-type'] == "all":
202 project = view_all.All(None)
203 elif yaml_content['view-type'] == "list":
201 project = view_list.List(None) 204 project = view_list.List(None)
202 elif yaml_content['view-type'] == "pipeline": 205 elif yaml_content['view-type'] == "pipeline":
203 project = view_pipeline.Pipeline(None) 206 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 0000000..32a30b3
--- /dev/null
+++ b/tests/views/fixtures/view-all-minimal.xml
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="utf-8"?>
2<hudson.model.AllView>
3 <name>All</name>
4 <description/>
5 <filterExecutors>false</filterExecutors>
6 <filterQueue>false</filterQueue>
7 <properties class="hudson.model.View$PropertyList"/>
8</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 0000000..6b512a0
--- /dev/null
+++ b/tests/views/fixtures/view-all-minimal.yaml
@@ -0,0 +1,2 @@
1name: All
2view-type: all
diff --git a/tests/views/test_views.py b/tests/views/test_views.py
index 1f9924f..4ce7333 100644
--- a/tests/views/test_views.py
+++ b/tests/views/test_views.py
@@ -13,11 +13,18 @@
13# limitations under the License.import os 13# limitations under the License.import os
14 14
15import os 15import os
16from jenkins_jobs.modules import view_all
16from jenkins_jobs.modules import view_list 17from jenkins_jobs.modules import view_list
17from jenkins_jobs.modules import view_pipeline 18from jenkins_jobs.modules import view_pipeline
18from tests import base 19from tests import base
19 20
20 21
22class TestCaseModuleViewAll(base.BaseScenariosTestCase):
23 fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
24 scenarios = base.get_scenarios(fixtures_path)
25 klass = view_all.All
26
27
21class TestCaseModuleViewList(base.BaseScenariosTestCase): 28class TestCaseModuleViewList(base.BaseScenariosTestCase):
22 fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') 29 fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
23 scenarios = base.get_scenarios(fixtures_path) 30 scenarios = base.get_scenarios(fixtures_path)