Пример #1
0
    def testBasic(self):
        s = FileUpload(slavesrc=__file__, masterdest=self.destfile)
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = 1

        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 == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                break
        else:
            self.assert_(False, "No uploadFile command found")

        self.assertEquals(
            open(self.destfile, "rb").read(),
            open(__file__, "rb").read())
Пример #2
0
    def testTimestamp(self):
        s = FileUpload(slavesrc=__file__,
                       masterdest=self.destfile,
                       keepstamp=True)
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = "2.13"

        s.step_status = Mock()
        s.buildslave = Mock()
        s.remote = Mock()
        s.start()
        timestamp = (os.path.getatime(__file__), os.path.getmtime(__file__))

        for c in s.remote.method_calls:
            name, command, args = c
            commandName = command[3]
            kwargs = command[-1]
            if commandName == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                writer.remote_utime(timestamp)
                break
        else:
            self.assert_(False, "No uploadFile command found")

        desttimestamp = (os.path.getatime(self.destfile),
                         os.path.getmtime(self.destfile))
        self.assertAlmostEquals(timestamp[0], desttimestamp[0], places=5)
        self.assertAlmostEquals(timestamp[1], desttimestamp[1], places=5)
Пример #3
0
    def testTimestamp(self):
        s = FileUpload(slavesrc=__file__, masterdest=self.destfile, keepstamp=True)
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = "2.13"

        s.step_status = Mock()
        s.buildslave = Mock()
        s.remote = Mock()
        s.start()
        timestamp = ( os.path.getatime(__file__),
                      os.path.getmtime(__file__) )

        for c in s.remote.method_calls:
            name, command, args = c
            commandName = command[3]
            kwargs = command[-1]
            if commandName == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                writer.remote_utime(timestamp)
                break
        else:
            self.assert_(False, "No uploadFile command found")

        desttimestamp = ( os.path.getatime(self.destfile),
                          os.path.getmtime(self.destfile) )
        self.assertAlmostEquals(timestamp[0],desttimestamp[0],places=5)
        self.assertAlmostEquals(timestamp[1],desttimestamp[1],places=5)
Пример #4
0
    def testBasic(self):
        s = FileUpload(slavesrc=__file__, masterdest=self.destfile)
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = 1

        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 == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                break
        else:
            self.assert_(False, "No uploadFile command found")

        self.assertEquals(open(self.destfile, "rb").read(),
                open(__file__, "rb").read())
Пример #5
0
    def testURL(self):
        s = FileUpload(slavesrc=__file__, masterdest=self.destfile, url="http://server/file")
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = "2.13"

        s.step_status = Mock()
        s.step_status.addURL = 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 == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                break
        else:
            self.assert_(False, "No uploadFile command found")

        s.step_status.addURL.assert_called_once_with(
            os.path.basename(self.destfile), "http://server/file")
Пример #6
0
    def testURL(self):
        s = FileUpload(slavesrc=__file__,
                       masterdest=self.destfile,
                       url="http://server/file")
        s.build = Mock()
        s.build.getProperties.return_value = Properties()
        s.build.getSlaveCommandVersion.return_value = "2.13"

        s.step_status = Mock()
        s.step_status.addURL = 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 == 'uploadFile':
                self.assertEquals(kwargs['slavesrc'], __file__)
                writer = kwargs['writer']
                writer.remote_write(open(__file__, "rb").read())
                self.assert_(not os.path.exists(self.destfile))
                writer.remote_close()
                break
        else:
            self.assert_(False, "No uploadFile command found")

        s.step_status.addURL.assert_called_once_with(
            os.path.basename(self.destfile), "http://server/file")