Exemple #1
0
 def test_dict(self):
     s = Source()
     s.build = Build()
     dict = {}
     dict['test'] = "ssh://server/testrepository"
     self.assertEquals(s.computeRepositoryURL(dict),
                       "ssh://server/testrepository")
Exemple #2
0
    def test_start_alwaysUseLatest_False_no_branch(self):
        step = self.setupStep(Source())
        step.branch = 'branch'
        step.startVC = mock.Mock()

        step.startStep(mock.Mock())

        self.assertEqual(step.startVC.call_args, (('branch', None, None), {}))
    def test_start_no_codebase(self):
        step = self.setupStep(Source())
        step.branch = 'branch'
        step.startVC = mock.Mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('', ))
Exemple #4
0
    def test_start_alwaysUseLatest_True(self):
        step = self.setupStep(Source(alwaysUseLatest=True), {
            'branch': 'other-branch',
            'revision': 'revision',
        },
                              patch='patch')
        step.branch = 'branch'
        step.startVC = mock.Mock()

        step.startStep(mock.Mock())

        self.assertEqual(step.startVC.call_args, (('branch', None, None), {}))
    def test_start_alwaysUseLatest_False(self):
        step = self.setupStep(Source(), {
            'branch': 'other-branch',
            'revision': 'revision',
        },
                              patch='patch')
        step.branch = 'branch'
        step.run_vc = self.setup_deferred_mock()

        step.startStep(mock.Mock())

        self.assertEqual(step.run_vc.mock.call_args,
                         (('other-branch', 'revision', 'patch'), {}))
    def test_start_alwaysUseLatest_False_binary_patch(self):
        args = {
            'branch': 'other-branch',
            'revision': 'revision',
        }
        step = self.setup_step(Source(), args, patch=(1, b'patch\xf8'))
        step.branch = 'branch'
        step.run_vc = self.setup_deferred_mock()

        step.startStep(mock.Mock())

        self.assertEqual(step.run_vc.mock.call_args,
                         (('other-branch', 'revision', (1, b'patch\xf8')), {}))
Exemple #7
0
    def test_start_no_codebase(self):
        step = self.setupStep(Source())
        step.branch = 'branch'
        step.startVC = mock.Mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.describe(), ['updating'])
        self.assertEqual(step.name, Source.name)

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('', ))

        self.assertEqual(step.description, ['updating'])
Exemple #8
0
    def test_start_with_codebase(self):
        step = self.setupStep(Source(codebase='codebase'))
        step.branch = 'branch'
        step.startVC = mock.Mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.describe(), ['updating', 'codebase'])
        self.assertEqual(step.name, Source.name + " codebase")

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('codebase',))        

        self.assertEqual(step.describe(True), ['update', 'codebase'])
    def test_start_no_codebase(self):
        step = self.setupStep(Source())
        step.branch = 'branch'
        step.run_vc = self.setup_deferred_mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.getCurrentSummary(), {'step': 'updating'})
        self.assertEqual(step.name, Source.name)

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('', ))

        self.assertEqual(step.getCurrentSummary(), {'step': 'updating'})
Exemple #10
0
    def test_start_with_codebase_and_descriptionSuffix(self):
        step = self.setupStep(
            Source(codebase='my-code', descriptionSuffix='suffix'))
        step.branch = 'branch'
        step.startVC = mock.Mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.describe(), ['updating', 'suffix'])
        self.assertEqual(step.name, Source.name + "-my-code")

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('my-code', ))

        self.assertEqual(step.describe(True), ['update', 'suffix'])
Exemple #11
0
    def test_start_with_codebase(self):
        step = self.setupStep(Source(codebase='codebase'))
        step.branch = 'branch'
        step.run_vc = self.setup_deferred_mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.getCurrentSummary(), {'step': 'updating codebase'})
        step.name = yield step.build.render(step.name)
        self.assertEqual(step.name, Source.name + "-codebase")

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('codebase',))

        self.assertEqual(step.getResultSummary(),
                         {'step': 'Codebase codebase not in build codebase (failure)'})
Exemple #12
0
    def test_start_with_codebase_and_descriptionSuffix(self):
        step = self.setupStep(Source(codebase='my-code',
                                     descriptionSuffix='suffix'))
        step.branch = 'branch'
        step.run_vc = self.setup_deferred_mock()
        step.build.getSourceStamp = mock.Mock()
        step.build.getSourceStamp.return_value = None

        self.assertEqual(step.getCurrentSummary(), {'step': 'updating suffix'})
        step.name = yield step.build.render(step.name)
        self.assertEqual(step.name, Source.name + "-my-code")

        step.startStep(mock.Mock())
        self.assertEqual(step.build.getSourceStamp.call_args[0], ('my-code',))

        self.assertEqual(step.getResultSummary(),
                         {'step': 'Codebase my-code not in build suffix (failure)'})
Exemple #13
0
 def test_callable_render(self):
     s = Source()
     s.build = Build()
     func = lambda x: x + "%(foo)s"
     self.assertEquals(s.computeRepositoryURL(func), "testbar")
Exemple #14
0
 def test_backward_compatibility_render(self):
     s = Source()
     s.build = Build()
     self.assertEquals(s.computeRepositoryURL("repourl%(foo)s"),
                       "repourlbar")
Exemple #15
0
 def test_dict_render(self):
     s = Source()
     s.build = Build()
     d = dict(test="repourl%(foo)s")
     self.assertEquals(s.computeRepositoryURL(d), "repourlbar")
Exemple #16
0
 def test_constructor_args_lists(self):
     step = Source(workdir='build',
                   description=['svn', 'update', '(running)'],
                   descriptionDone=['svn', 'update'])
     self.assertEqual(step.description, ['svn', 'update', '(running)'])
     self.assertEqual(step.descriptionDone, ['svn', 'update'])
Exemple #17
0
 def test_constructor_args_strings(self):
     step = Source(workdir='build',
                   description='svn update (running)',
                   descriptionDone='svn update')
     self.assertEqual(step.description, ['svn update (running)'])
     self.assertEqual(step.descriptionDone, ['svn update'])
Exemple #18
0
 def test_callable(self):
     s = Source()
     s.build = Build()
     func = lambda x: x[::-1]
     self.assertEquals(s.computeRepositoryURL(func), "tset")
Exemple #19
0
 def test_format_string(self):
     s = Source()
     s.build = Build()
     self.assertEquals(s.computeRepositoryURL("http://server/%s"), "http://server/test")
Exemple #20
0
 def test_backward_compatibility(self):
     s = Source()
     s.build = Build()
     self.assertEqual(s.computeRepositoryURL("repourl"), "repourl")