diff --git a/tests/test_integration/test_data_testing.py b/tests/test_integration/test_data_testing.py index 8b456f2..5894dd1 100644 --- a/tests/test_integration/test_data_testing.py +++ b/tests/test_integration/test_data_testing.py @@ -19,29 +19,44 @@ from lolafect.connections import open_ssh_tunnel_with_s3_pkey, close_ssh_tunnel TEST_LOLACONFIG = build_lolaconfig(flow_name="testing-suite") +TEST_QUERY = """ +SELECT 1 AS a_one, + "lol" AS a_string, + NULL AS a_null +""" + +TEST_EXPECTATIONS_THAT_FIT_DATA = [ + ExpectationConfiguration( + expectation_type="expect_column_values_to_be_between", + kwargs={"column": "a_one", "min_value": 1, "max_value": 1}, + ), + ExpectationConfiguration( + expectation_type="expect_column_values_to_match_like_pattern", + kwargs={"column": "a_string", "like_pattern": "%lol%"}, + ), + ExpectationConfiguration( + expectation_type="expect_column_values_to_be_null", + kwargs={"column": "a_null"}, + ), +] + +TEST_EXPECTATIONS_THAT_DONT_FIT_DATA = [ + ExpectationConfiguration( + expectation_type="expect_column_values_to_be_between", + kwargs={"column": "a_one", "min_value": 2, "max_value": 2}, + ), + ExpectationConfiguration( + expectation_type="expect_column_values_to_match_like_pattern", + kwargs={"column": "a_string", "like_pattern": "%xD%"}, + ), + ExpectationConfiguration( + expectation_type="expect_column_values_to_not_be_null", + kwargs={"column": "a_null"}, + ), +] + def test_validation_on_mysql_succeeds(): - - test_query = """ - SELECT 1 AS a_one, - "lol" AS a_string, - NULL AS a_null - """ - test_expectations = [ - ExpectationConfiguration( - expectation_type="expect_column_values_to_be_between", - kwargs={"column": "a_one", "min_value": 1, "max_value": 1}, - ), - ExpectationConfiguration( - expectation_type="expect_column_values_to_match_like_pattern", - kwargs={"column": "a_string", "like_pattern": "%lol%"}, - ), - ExpectationConfiguration( - expectation_type="expect_column_values_to_be_null", - kwargs={"column": "a_null"}, - ), - ] - ssh_tunnel = open_ssh_tunnel_with_s3_pkey.run( s3_bucket_name=TEST_LOLACONFIG.S3_BUCKET_NAME, ssh_tunnel_credentials=TEST_LOLACONFIG.SSH_TUNNEL_CREDENTIALS, @@ -58,8 +73,8 @@ def test_validation_on_mysql_succeeds(): "password": TEST_LOLACONFIG.DW_CREDENTIALS["password"], "db": TEST_LOLACONFIG.DW_CREDENTIALS["default_db"], }, - query=test_query, - expectation_configurations=test_expectations, + query=TEST_QUERY, + expectation_configurations=TEST_EXPECTATIONS_THAT_FIT_DATA, ) closed_tunnel = close_ssh_tunnel.run(ssh_tunnel) @@ -70,26 +85,6 @@ def test_validation_on_mysql_succeeds(): def test_validation_on_mysql_fails(): - test_query = """ - SELECT 1 AS a_one, - "lol" AS a_string, - NULL AS a_null - """ - test_expectations = [ - ExpectationConfiguration( - expectation_type="expect_column_values_to_be_between", - kwargs={"column": "a_one", "min_value": 2, "max_value": 2}, - ), - ExpectationConfiguration( - expectation_type="expect_column_values_to_match_like_pattern", - kwargs={"column": "a_string", "like_pattern": "%xD%"}, - ), - ExpectationConfiguration( - expectation_type="expect_column_values_to_not_be_null", - kwargs={"column": "a_null"}, - ), - ] - ssh_tunnel = open_ssh_tunnel_with_s3_pkey.run( s3_bucket_name=TEST_LOLACONFIG.S3_BUCKET_NAME, ssh_tunnel_credentials=TEST_LOLACONFIG.SSH_TUNNEL_CREDENTIALS, @@ -106,8 +101,8 @@ def test_validation_on_mysql_fails(): "password": TEST_LOLACONFIG.DW_CREDENTIALS["password"], "db": TEST_LOLACONFIG.DW_CREDENTIALS["default_db"], }, - query=test_query, - expectation_configurations=test_expectations, + query=TEST_QUERY, + expectation_configurations=TEST_EXPECTATIONS_THAT_DONT_FIT_DATA, ) closed_tunnel = close_ssh_tunnel.run(ssh_tunnel)