예제 #1
0
    def testBasicWorker2_16(self):
        s = transfer.JSONPropertiesDownload("props.json")
        s.build = Mock()
        props = Properties()
        props.setProperty('key1', 'value1', 'test')
        s.build.getProperties.return_value = props
        s.build.getWorkerCommandVersion.return_value = '2.16'
        ss = Mock()
        ss.asDict.return_value = dict(revision="12345")
        s.build.getAllSourceStamps.return_value = [ss]

        s.worker = Mock()
        s.remote = Mock()

        s.start()

        for c in s.remote.method_calls:
            name, command, args = c
            commandName = command[3]
            kwargs = command[-1]
            if commandName == 'downloadFile':
                self.assertEqual(kwargs['slavedest'], 'props.json')
                reader = kwargs['reader']
                data = reader.remote_read(100)
                self.assertEqual(
                    data,
                    json.dumps(
                        dict(sourcestamps=[ss.asDict()],
                             properties={'key1': 'value1'})))
                break
        else:
            raise ValueError("No downloadFile command found")
예제 #2
0
    def test_init_workerdest_old_api_warns(self):
        with assertProducesWarning(
                DeprecatedWorkerNameWarning,
                message_pattern="'slavedest' keyword argument is deprecated"):
            step = transfer.JSONPropertiesDownload(slavedest='dstfile')

        self.assertEqual(step.workerdest, 'dstfile')
예제 #3
0
    def testBasic(self):
        s = transfer.JSONPropertiesDownload("props.json")
        s.build = Mock()
        props = Properties()
        props.setProperty('key1', 'value1', 'test')
        s.build.getProperties.return_value = props
        s.build.getSlaveCommandVersion.return_value = 1
        ss = Mock()
        ss.asDict.return_value = dict(revision="12345")
        s.build.getSourceStamp.return_value = ss

        s.step_status = Mock()
        s.buildslave = Mock()
        s.remote = Mock()

        s.start()

        for c in s.remote.method_calls:
            name, command, args = c
            commandName = command[3]
            kwargs = command[-1]
            if commandName == 'downloadFile':
                self.assertEquals(kwargs['slavedest'], 'props.json')
                reader = kwargs['reader']
                data = reader.remote_read(100)
                self.assertEquals(data, json.dumps(dict(sourcestamp=ss.asDict(), properties={'key1': 'value1'})))
                break
        else:
            self.assert_(False, "No downloadFile command found")
예제 #4
0
    def testBasic(self):
        self.setupStep(transfer.JSONPropertiesDownload("props.json"))
        self.step.build.setProperty('key1', 'value1', 'test')
        read = []
        self.expectCommands(
            Expect(
                'downloadFile',
                dict(workerdest="props.json",
                     workdir='wkdir',
                     blocksize=16384,
                     maxsize=None,
                     mode=None,
                     reader=ExpectRemoteRef(remotetransfer.StringFileReader)))
            + Expect.behavior(downloadString(read.append)) + 0)

        self.expectOutcome(result=SUCCESS,
                           state_string="downloading to props.json")
        yield self.runStep()
        # we decode as key order is dependent of python version
        self.assertEqual(json.loads((b''.join(read)).decode()), {
            "properties": {
                "key1": "value1"
            },
            "sourcestamps": []
        })
예제 #5
0
    def test_workerdest_old_api(self):
        step = transfer.JSONPropertiesDownload(workerdest='dstfile')

        with assertNotProducesWarnings(DeprecatedWorkerAPIWarning):
            new = step.workerdest

        with assertProducesWarning(
                DeprecatedWorkerNameWarning,
                message_pattern="'slavedest' attribute is deprecated"):
            old = step.slavedest

        self.assertIdentical(new, old)
예제 #6
0
 def test_init_positional_args(self):
     self.assertRaises(TypeError, lambda: transfer.JSONPropertiesDownload())
예제 #7
0
    def test_init_workerdest_positional(self):
        with assertNotProducesWarnings(DeprecatedWorkerAPIWarning):
            step = transfer.JSONPropertiesDownload('dstfile')

        self.assertEqual(step.workerdest, 'dstfile')
예제 #8
0
    def test_init_workerdest_positional(self):
        step = transfer.JSONPropertiesDownload('dstfile')

        self.assertEqual(step.workerdest, 'dstfile')
예제 #9
0
    def test_init_workerdest_keyword(self):
        step = transfer.JSONPropertiesDownload(workerdest='dstfile')

        self.assertEqual(step.workerdest, 'dstfile')