Esempio n. 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")
Esempio n. 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], ('', ))
Esempio n. 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), {}))
Esempio n. 5
0
    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'), {}))
Esempio n. 6
0
    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')), {}))
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 9
0
    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'})
Esempio n. 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'])
Esempio n. 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)'})
Esempio n. 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)'})
Esempio n. 13
0
 def test_callable_render(self):
     s = Source()
     s.build = Build()
     func = lambda x: x + "%(foo)s"
     self.assertEquals(s.computeRepositoryURL(func), "testbar")
Esempio n. 14
0
 def test_backward_compatibility_render(self):
     s = Source()
     s.build = Build()
     self.assertEquals(s.computeRepositoryURL("repourl%(foo)s"),
                       "repourlbar")
Esempio n. 15
0
 def test_dict_render(self):
     s = Source()
     s.build = Build()
     d = dict(test="repourl%(foo)s")
     self.assertEquals(s.computeRepositoryURL(d), "repourlbar")
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 18
0
 def test_callable(self):
     s = Source()
     s.build = Build()
     func = lambda x: x[::-1]
     self.assertEquals(s.computeRepositoryURL(func), "tset")
Esempio n. 19
0
 def test_format_string(self):
     s = Source()
     s.build = Build()
     self.assertEquals(s.computeRepositoryURL("http://server/%s"), "http://server/test")
Esempio n. 20
0
 def test_backward_compatibility(self):
     s = Source()
     s.build = Build()
     self.assertEqual(s.computeRepositoryURL("repourl"), "repourl")