Skip to content

Commit 0c47f75

Browse files
committed
[NRL-1922] Add initial unit tests for changes to glue pipeline.py
1 parent 0b85653 commit 0c47f75

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ env = [
104104
"AUTH_STORE=auth-store",
105105
"TABLE_NAME=unit-test-document-pointer"
106106
]
107-
pythonpath = [".", "./scripts"]
107+
pythonpath = [".", "./scripts", "./terraform/account-wide-infrastructure/modules/glue/src"]
108108

109109
[tool.datamodel-codegen]
110110
target-python-version = "3.12"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)