|
| 1 | +from moto import mock_aws |
| 2 | +from pipeline import LogPipeline |
| 3 | + |
| 4 | + |
| 5 | +@mock_aws |
| 6 | +def test_pipeline_init_defaults(): |
| 7 | + glue_context = "mock_glue_context" |
| 8 | + spark = "mock_spark_session" |
| 9 | + logger = "mock_logger" |
| 10 | + source_path = "s3://mock-source-path" |
| 11 | + target_path = "s3://mock-target-path" |
| 12 | + host_prefixes = ["host1", "host2"] |
| 13 | + job_name = "test-job-name" |
| 14 | + |
| 15 | + pipeline = LogPipeline( |
| 16 | + glue_context, spark, logger, source_path, target_path, host_prefixes, job_name |
| 17 | + ) |
| 18 | + |
| 19 | + assert pipeline.glue_context == glue_context |
| 20 | + assert pipeline.spark == spark |
| 21 | + assert pipeline.logger == logger |
| 22 | + assert pipeline.source_path == source_path |
| 23 | + assert pipeline.target_path == target_path |
| 24 | + assert pipeline.host_prefixes == host_prefixes |
| 25 | + assert pipeline.job_name == job_name |
| 26 | + assert pipeline.name_prefix == "test-job-name" |
| 27 | + assert pipeline.partition_cols == [] |
| 28 | + assert pipeline.transformations == [] |
| 29 | + |
| 30 | + |
| 31 | +@mock_aws |
| 32 | +def test_pipeline_init_with_custom_values(): |
| 33 | + glue_context = "mock_glue_context" |
| 34 | + spark = "mock_spark_session" |
| 35 | + logger = "mock_logger" |
| 36 | + source_path = "s3://mock-source-path" |
| 37 | + target_path = "s3://mock-target-path" |
| 38 | + host_prefixes = ["host1", "host2"] |
| 39 | + job_name = "test-job-name" |
| 40 | + partition_cols = ["col1", "col2"] |
| 41 | + transformations = ["transformation1", "transformation2"] |
| 42 | + |
| 43 | + pipeline = LogPipeline( |
| 44 | + glue_context, |
| 45 | + spark, |
| 46 | + logger, |
| 47 | + source_path, |
| 48 | + target_path, |
| 49 | + host_prefixes, |
| 50 | + job_name, |
| 51 | + partition_cols=partition_cols, |
| 52 | + transformations=transformations, |
| 53 | + ) |
| 54 | + |
| 55 | + assert pipeline.partition_cols == partition_cols |
| 56 | + assert pipeline.transformations == transformations |
0 commit comments