Beispiel #1
0
    def test_driver_get(self, mfabget, mfabset, mexecute):
        mexecute.return_value = ("RETURN_CODE", "STDOUT", "STDERR")
        remote_path = "/remote_dir/remote_file"
        target_path = "/target_dir"

        driver = shotgun.driver.Driver(
            {"host": {
                "address": "remote_host",
                "ssh-key": "path_to_key",
            }}, None)
        driver.get(remote_path, target_path)
        mexecute.assert_called_with('mkdir -p "{0}"'.format(target_path))
        mfabget.assert_called_with(remote_path, target_path)
        mfabset.assert_called_with(host_string="remote_host",
                                   key_filename="path_to_key",
                                   timeout=2,
                                   warn_only=True)

        mexecute.reset_mock()
        driver = shotgun.driver.Driver({}, None)
        driver.get(remote_path, target_path)
        self.assertEqual(mexecute.mock_calls, [
            mock.call('mkdir -p "{0}"'.format(target_path)),
            mock.call('cp -r "{0}" "{1}"'.format(remote_path, target_path))
        ])
Beispiel #2
0
    def test_driver_get(self, mfabget, mfabset, mexecute):
        mexecute.return_value = ("RETURN_CODE", "STDOUT", "STDERR")
        remote_path = "/remote_dir/remote_file"
        target_path = "/target_dir"

        driver = shotgun.driver.Driver({"host": "remote_host"}, None)
        driver.get(remote_path, target_path)
        mexecute.assert_called_with("mkdir -p %s" % target_path)
        mfabget.assert_called_with(remote_path, target_path)
        mfabset.assert_called_with(
            host_string="remote_host", timeout=2, warn_only=True)

        mexecute.reset_mock()
        driver = shotgun.driver.Driver({}, None)
        driver.get(remote_path, target_path)
        assert mexecute.mock_calls == [
            call("mkdir -p %s" % target_path),
            call("cp -r %s %s" % (remote_path, target_path))
        ]
Beispiel #3
0
    def test_driver_get(self):
        shotgun.driver.fabric.api.get = MagicMock()
        shotgun.driver.fabric.api.settings = MagicMock()
        shotgun.driver.execute = MagicMock(
            return_value=("RETURN_CODE", "STDOUT", "STDERR"))
        path = "PATH"
        target_path = "/tmp/TARGET_PATH"

        driver = shotgun.driver.Driver({"host": "remote"}, None)
        driver.get(path, target_path)
        shotgun.driver.fabric.api.get.assert_called_with(path, target_path)
        shotgun.driver.fabric.api.settings.assert_called_with(
            host_string="remote", timeout=2, warn_only=True)

        driver = shotgun.driver.Driver({}, None)
        driver.get(path, target_path)
        shotgun.driver.execute.assert_any_call(
            "mkdir -p %s" % os.path.dirname(target_path))
        shotgun.driver.execute.assert_any_call(
            "cp -r %s %s" % (path, target_path))
Beispiel #4
0
    def test_driver_get(self, mfabget, mfabset, mexecute):
        mexecute.return_value = ("RETURN_CODE", "STDOUT", "STDERR")
        remote_path = "/remote_dir/remote_file"
        target_path = "/target_dir"

        driver = shotgun.driver.Driver({
            "host": {
                "address": "remote_host",
                "ssh-key": "path_to_key",
            }
        }, None)
        driver.get(remote_path, target_path)
        mexecute.assert_called_with('mkdir -p "{0}"'.format(target_path))
        mfabget.assert_called_with(remote_path, target_path)
        mfabset.assert_called_with(
            host_string="remote_host", key_filename="path_to_key",
            timeout=2, warn_only=True)

        mexecute.reset_mock()
        driver = shotgun.driver.Driver({}, None)
        driver.get(remote_path, target_path)
        self.assertEqual(mexecute.mock_calls, [
            call('mkdir -p "{0}"'.format(target_path)),
            call('cp -r "{0}" "{1}"'.format(remote_path, target_path))])