Exemple #1
0
def test_it_invokes_athena_query_generator(gen_athena_queries,
                                           get_data_mappers, get_del_q,
                                           batch_sqs_msgs_mock):
    get_del_q.return_value = [{"MatchId": "hi"}]
    queries = [{
        "DataMapperId": "a",
        "QueryExecutor": "athena",
        "Format": "parquet",
        "Database": "test_db",
        "Table": "test_table",
        "Columns": [{
            "Column": "customer_id",
            "MatchIds": ["hi"]
        }],
        "PartitionKeys": [{
            "Key": "product_category",
            "Value": "Books"
        }],
        "DeleteOldVersions": True,
    }]
    gen_athena_queries.return_value = queries
    get_data_mappers.return_value = iter([{
        "DataMapperId": "a",
        "QueryExecutor": "athena",
        "Columns": ["customer_id"],
        "Format": "parquet",
        "QueryExecutorParameters": {
            "DataCatalogProvider": "glue",
            "Database": "test_db",
            "Table": "test_table",
        },
    }])
    handler({"ExecutionName": "test"}, SimpleNamespace())
    batch_sqs_msgs_mock.assert_called_with(mock.ANY, queries)
Exemple #2
0
def test_it_raises_for_unknown_query_executor(get_data_mappers, get_del_q,
                                              batch_sqs_msgs_mock):
    get_del_q.return_value = [{"MatchId": "hi"}]
    get_data_mappers.return_value = iter([{
        "DataMapperId": "a",
        "QueryExecutor": "invalid",
        "Columns": ["customer_id"],
        "Format": "parquet",
        "QueryExecutorParameters": {
            "DataCatalogProvider": "glue",
            "Database": "test_db",
            "Table": "test_table",
        },
    }])
    with pytest.raises(NotImplementedError):
        handler({"ExecutionName": "test"}, SimpleNamespace())
        batch_sqs_msgs_mock.assert_not_called()