# Path: marvin_python_toolbox/management/hive.py
# def cli():
# def hive_generateconf_cli(ctx):
# def hive_generateconf(ctx):
# def hive_resetremote_cli(ctx, host, engine, queue):
# def hive_resetremote(ctx, host, engine, queue):
# def hive_dataimport_cli(
#     ctx, conf, sql_id, engine, skip_remote_preparation, force_copy_files, validate, force,
#     force_remote, max_query_size, destination_host, destination_port, destination_host_username,
#     destination_host_password, destination_hdfs_root_path
# ):
# def hive_dataimport(
#     ctx, conf, sql_id, engine, skip_remote_preparation, force_copy_files, validate, force,
#     force_remote, max_query_size, destination_host, destination_port, destination_host_username,
#     destination_host_password, destination_hdfs_root_path
# ):
# def read_config(filename):
#     def __init__(
#         self, origin_host, origin_db, origin_queue, target_table_name, sample_sql, engine,
#         max_query_size, destination_host, destination_port, destination_host_username, destination_host_password,
#         destination_hdfs_root_path, sql_id
#     ):
#     def validade_query(self):
#     def table_exists(self, host, db, table):
#     def reset_remote_tables(self):
#     def print_finish_step(self):
#     def print_start_step(self, name, step_number, total_steps):
#     def import_sample(self, create_temp_table=True, copy_files=True, validate_query=True, force_create_remote_table=False):
#     def temp_table_prefix(self):
#     def temp_table_name(self):
#     def full_table_name(self):
#     def full_temp_table_name(self):
#     def generate_table_location(self, root_path, host, db_name, table_name):
#     def clean_ddl(self, ddl, remove_formats=True, remove_general=True):
#     def get_table_format(self, ddl):
#     def get_database_info(self, ddl):
#     def get_createtable_ddl(self, conn, origin_table_name, dest_table_name):
#     def create_database(self, conn, db):
#     def drop_table(self, conn, table_name):
#     def drop_view(self, conn, view_name):
#     def create_table(self, conn, table_name, ddl):
#     def _execute_db_command(self, conn, command):
#     def get_connection(self, host, db='DEFAULT', queue='default'):
#     def retrieve_data_sample(self, conn, full_table_name, sample_limit=100):
#     def count_rows(self, conn, sql):
#     def show_log(self, cursor):
#     def save_data(self, conn, table, data):
#     def get_partitions(self, ddl):
#     def has_partitions(self, sql, partitions):
#     def populate_table(self, conn, table_name, partitions, sql):
#     def create_view(self, conn, view_name, table_name):
#     def refresh_partitions(self, conn, table_name):
#     def get_table_location(self, conn, table_name):
#     def delete_files(self, ssh, url):
#     def copy_files(self, ssh, origin, dest):
#     def _hdfs_commands(self, ssh, cmd):
#     def _get_ssh_client(self, hdfs_host, hdfs_port, username, password):
#     def hdfs_dist_copy(self, force, hdfs_host, hdfs_port, origin, dest, username=None, password=None):
#     def create_external_table(self, conn, temp_table_name, ddl, parquet_file_location):
# class HiveDataImporter():


    import mock
    import unittest.mock as mock
from marvin_python_toolbox.management import hive
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

try:
except ImportError:



@mock.patch('marvin_python_toolbox.management.hive.json')
def test_hive_generateconf_write_file_with_json(mocked_json):
    default_conf = [{
        "origin_host": "xxx_host_name",
        "origin_db": "xxx_db_name",
        "origin_queue": "marvin",
        "target_table_name": "xxx_table_name",
        "sample_sql": "SELECT * FROM XXX",
        "sql_id": "1"
    }]

    mocked_open = mock.mock_open()
    with mock.patch('marvin_python_toolbox.management.hive.open', mocked_open, create=True):

# Path: marvin_python_toolbox/management/hive.py
# def cli():
# def hive_generateconf_cli(ctx):
# def hive_generateconf(ctx):
# def hive_resetremote_cli(ctx, host, engine, queue):
# def hive_resetremote(ctx, host, engine, queue):
# def hive_dataimport_cli(
#     ctx, conf, sql_id, engine, skip_remote_preparation, force_copy_files, validate, force,
#     force_remote, max_query_size, destination_host, destination_port, destination_host_username,
#     destination_host_password, destination_hdfs_root_path
# ):
# def hive_dataimport(
#     ctx, conf, sql_id, engine, skip_remote_preparation, force_copy_files, validate, force,
#     force_remote, max_query_size, destination_host, destination_port, destination_host_username,
#     destination_host_password, destination_hdfs_root_path
# ):
# def read_config(filename):
#     def __init__(
#         self, origin_host, origin_db, origin_queue, target_table_name, sample_sql, engine,
#         max_query_size, destination_host, destination_port, destination_host_username, destination_host_password,
#         destination_hdfs_root_path, sql_id
#     ):
#     def validade_query(self):
#     def table_exists(self, host, db, table):
#     def reset_remote_tables(self):
#     def print_finish_step(self):
#     def print_start_step(self, name, step_number, total_steps):
#     def import_sample(self, create_temp_table=True, copy_files=True, validate_query=True, force_create_remote_table=False):
#     def temp_table_prefix(self):
#     def temp_table_name(self):
#     def full_table_name(self):
#     def full_temp_table_name(self):
#     def generate_table_location(self, root_path, host, db_name, table_name):
#     def clean_ddl(self, ddl, remove_formats=True, remove_general=True):
#     def get_table_format(self, ddl):
#     def get_database_info(self, ddl):
#     def get_createtable_ddl(self, conn, origin_table_name, dest_table_name):
#     def create_database(self, conn, db):
#     def drop_table(self, conn, table_name):
#     def drop_view(self, conn, view_name):
#     def create_table(self, conn, table_name, ddl):
#     def _execute_db_command(self, conn, command):
#     def get_connection(self, host, db='DEFAULT', queue='default'):
#     def retrieve_data_sample(self, conn, full_table_name, sample_limit=100):
#     def count_rows(self, conn, sql):
#     def show_log(self, cursor):
#     def save_data(self, conn, table, data):
#     def get_partitions(self, ddl):
#     def has_partitions(self, sql, partitions):
#     def populate_table(self, conn, table_name, partitions, sql):
#     def create_view(self, conn, view_name, table_name):
#     def refresh_partitions(self, conn, table_name):
#     def get_table_location(self, conn, table_name):
#     def delete_files(self, ssh, url):
#     def copy_files(self, ssh, origin, dest):
#     def _hdfs_commands(self, ssh, cmd):
#     def _get_ssh_client(self, hdfs_host, hdfs_port, username, password):
#     def hdfs_dist_copy(self, force, hdfs_host, hdfs_port, origin, dest, username=None, password=None):
#     def create_external_table(self, conn, temp_table_name, ddl, parquet_file_location):
# class HiveDataImporter():


# Path: tests/management/test_hive.py
    import mock
    import unittest.mock as mock
from marvin_python_toolbox.management import hive

# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

try:
except ImportError:



@mock.patch('marvin_python_toolbox.management.hive.json')
def test_hive_generateconf_write_file_with_json(mocked_json):
    default_conf = [{
        "origin_host": "xxx_host_name",
        "origin_db": "xxx_db_name",
        "origin_queue": "marvin",
        "target_table_name": "xxx_table_name",
        "sample_sql": "SELECT * FROM XXX",
        "sql_id": "1"
    }]

    mocked_open = mock.mock_open()
    with mock.patch('marvin_python_toolbox.management.hive.open', mocked_open, create=True):

        hive.hive_generateconf(None)