blob: a97f0a073f2accdff0a7e0927c781092351ba94c [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
42 def test_copy_retains_skip_if(self):
43 job = model.Job('job')
44 job.copy(self.job)
45 self.assertTrue(job.skip_if_matcher)