1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
import mock
from buildbot.test.util import steps
import os
class SourceStepMixin(steps.BuildStepMixin):
"""
Support for testing source steps. Aside from the capabilities of
L{BuildStepMixin}, this adds:
- fake sourcestamps
The following instance variables are available after C{setupSourceStep}, in
addition to those made available by L{BuildStepMixin}:
@ivar sourcestamp: fake SourceStamp for the build
"""
def setUpSourceStep(self):
return steps.BuildStepMixin.setUpBuildStep(self)
def tearDownSourceStep(self):
return steps.BuildStepMixin.tearDownBuildStep(self)
# utilities
def setupStep(self, step, args={}, patch=None, **kwargs):
"""
Set up C{step} for testing. This calls L{BuildStepMixin}'s C{setupStep}
and then does setup specific to a Source step.
"""
step = steps.BuildStepMixin.setupStep(self, step, **kwargs)
ss = self.sourcestamp = mock.Mock(name="sourcestamp")
ss.ssid = 9123
ss.branch = args.get('branch', None)
ss.revision = args.get('revision', None)
ss.project = ''
ss.repository = ''
ss.patch = patch
ss.patch_info = None
ss.changes = []
self.build.path_module = os.path
self.build.getSourceStamp = lambda x=None: ss
return step
|