blob: d4c7880001f79f6fde6df3b5b4aa70fa0fbacf25 [file] [log] [blame]
Maru Newby3fe5f852015-01-13 04:22:14 +00001# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from zuul import change_matcher as cm
16from zuul import model
17
18from tests.base import BaseTestCase
19
20
21class TestJob(BaseTestCase):
22
23 @property
24 def job(self):
25 job = model.Job('job')
26 job.skip_if_matcher = cm.MatchAll([
27 cm.ProjectMatcher('^project$'),
28 cm.MatchAllFiles([cm.FileMatcher('^docs/.*$')]),
29 ])
30 return job
31
32 def test_change_matches_returns_false_for_matched_skip_if(self):
33 change = model.Change('project')
34 change.files = ['docs/foo']
35 self.assertFalse(self.job.changeMatches(change))
36
37 def test_change_matches_returns_true_for_unmatched_skip_if(self):
38 change = model.Change('project')
39 change.files = ['foo']
40 self.assertTrue(self.job.changeMatches(change))
41
Maru Newby79427a42015-02-17 17:54:45 +000042 def _assert_job_booleans_are_not_none(self, job):
43 self.assertIsNotNone(job.voting)
44 self.assertIsNotNone(job.hold_following_changes)
45
46 def test_job_sets_defaults_for_boolean_attributes(self):
47 job = model.Job('job')
48 self._assert_job_booleans_are_not_none(job)