def test_put_dir(self, *args):
        mock = self.ssh_cli
        mock.connect()

        local_dir = os.path.join(get_resources_base_path(), 'packs')
        mock.put_dir(local_path=local_dir, remote_path='/tmp')

        mock_cli = mock.client  # The actual mocked object: SSHClient

        # Assert that expected dirs are created on remote box.
        calls = [call('/tmp/packs/pythonactions'), call('/tmp/packs/pythonactions/actions')]
        mock_cli.open_sftp().mkdir.assert_has_calls(calls, any_order=True)

        # Assert that expected files are copied to remote box.
        local_file = os.path.join(get_resources_base_path(),
                                  'packs/pythonactions/actions/pascal_row.py')
        remote_file = os.path.join('/tmp', 'packs/pythonactions/actions/pascal_row.py')

        calls = [call(local_file, remote_file)]
        mock_cli.open_sftp().put.assert_has_calls(calls, any_order=True)
Example #2
0
    def test_put_dir(self, *args):
        mock = self.ssh_cli
        mock.connect()

        local_dir = os.path.join(get_resources_base_path(), 'packs')
        mock.put_dir(local_path=local_dir, remote_path='/tmp')

        mock_cli = mock.client  # The actual mocked object: SSHClient

        # Assert that expected dirs are created on remote box.
        calls = [call('/tmp/packs/pythonactions'), call('/tmp/packs/pythonactions/actions')]
        mock_cli.open_sftp().mkdir.assert_has_calls(calls, any_order=True)

        # Assert that expected files are copied to remote box.
        local_file = os.path.join(get_resources_base_path(),
                                  'packs/pythonactions/actions/pascal_row.py')
        remote_file = os.path.join('/tmp', 'packs/pythonactions/actions/pascal_row.py')

        calls = [call(local_file, remote_file)]
        mock_cli.open_sftp().put.assert_has_calls(calls, any_order=True)