def test_hive_dataimport_with_config_force_false(import_sample_mocked, table_exists_mocked, read_config_mocked): table_exists_mocked.return_value = False read_config_mocked.return_value = [{ 'origin_db': 'test', 'target_table_name': 'test', 'origin_queue': 'test', 'origin_host': 'test', 'sample_sql': 'test', 'sql_id': 'test' }] ctx = sql_id = engine = \ skip_remote_preparation = force_copy_files = validate =\ force_remote = max_query_size = destination_port =\ destination_host_username = destination_host_password = destination_hdfs_root_path = None force = False conf = '/path/to/conf' destination_host = 'test' hdi = hive.HiveDataImporter( max_query_size=max_query_size, destination_host=destination_host, destination_port=destination_port, destination_host_username=destination_host_username, destination_host_password=destination_host_password, destination_hdfs_root_path=destination_hdfs_root_path, origin_db='test', target_table_name='test', engine=engine, sql_id='test', origin_host='test', origin_queue='test', sample_sql='test', ) with mock.patch('marvin_python_toolbox.management.hive.HiveDataImporter', return_value=hdi): hive.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) table_exists_mocked.assert_called_once_with( host=hdi.destination_host, db=hdi.origin_db, table=hdi.target_table_name) import_sample_mocked.assert_called_once_with( create_temp_table=True, copy_files=None, validate_query=None, force_create_remote_table=None)
def test_hive_dataimport_with_config_sql_id(import_sample_mocked, table_exists_mocked, init_mocked, read_config_mocked): read_config_mocked.return_value = [ { 'origin_db': 'test', 'target_table_name': 'test', 'sql_id': 'test' }, { 'origin_db': 'bla', 'target_table_name': 'bla', 'sql_id': 'bla' }, ] init_mocked.return_value = None ctx = sql_id = engine = \ skip_remote_preparation = force_copy_files = validate =\ force_remote = max_query_size = destination_port =\ destination_host_username = destination_host_password = destination_hdfs_root_path = None sql_id = 'test' force = True conf = '/path/to/conf' destination_host = 'test' hive.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) init_mocked.assert_called_once_with( max_query_size=max_query_size, destination_host=destination_host, destination_port=destination_port, destination_host_username=destination_host_username, destination_host_password=destination_host_password, destination_hdfs_root_path=destination_hdfs_root_path, origin_db='test', target_table_name='test', sql_id='test', engine=engine, ) import_sample_mocked.assert_called_once_with( create_temp_table=True, copy_files=None, validate_query=None, force_create_remote_table=None)
def test_hive_dataimport_without_config(init_mocked, read_config_mocked): read_config_mocked.return_value = None 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 = None hive.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) init_mocked.assert_not_called()