Skip to content

Commit

Permalink
Adding
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-Thakur committed Nov 9, 2023
1 parent b068f7f commit 4ae2b70
Showing 1 changed file with 4 additions and 49 deletions.
53 changes: 4 additions & 49 deletions tests/functional/adapter/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,24 +448,19 @@ def assert_expected_error_messages(self, error_message, expected_error_messages)
def test__constraints_enforcement_rollback(
self, project, expected_color, expected_error_messages, null_model_sql
):
# print(expected_error_messages)
results = run_dbt(["run", "-s", "my_model"])
# print(results)

assert len(results) == 1

# # Make a contract-breaking change to the model
# Make a contract-breaking change to the model
write_file(null_model_sql, "models", "my_model.sql")

failing_results = run_dbt(["run", "-s", "my_model"], expect_pass=True)
# print("start",failing_results[0].message,"endhere", len(failing_results))
assert len(failing_results) == 1

# # Verify the previous table still exists
# Verify the previous table still exists
relation = relation_from_name(project.adapter, "my_model")
old_model_exists_sql = f"select * from {relation}"
old_model_exists = project.run_sql(old_model_exists_sql, fetch="all")
# print(old_model_exists[0][1],len(old_model_exists))
assert len(old_model_exists) == 1
assert old_model_exists[0][1] == expected_color

Expand All @@ -478,8 +473,7 @@ def test__constraints_enforcement_rollback(

assert contract_actual_config.enforced is True

# # Its result includes the expected error messages
# print(expected_error_messages)
# Its result includes the expected error messages
self.assert_expected_error_messages(failing_results[0].message, expected_error_messages)


Expand Down Expand Up @@ -574,17 +568,7 @@ def models(self):
"my_model_wrong_name.sql": my_model_view_wrong_name_sql,
"constraints_schema.yml": constraints_yml,
}
#class TestVerticaTableConstraintsRollback(BaseConstraintsRollback):
# @pytest.fixture(scope="class")
# def models(self):
# return {
# "my_model.sql": my_model_sql,
# "constraints_schema.yml": constraints_yml,
# }

# @pytest.fixture(scope="class")
# def expected_error_messages(self):
# return ["Required field id cannot be null"]


class TestVerticaConstraintsRuntimeDdlEnforcement(BaseConstraintsRuntimeDdlEnforcement):
Expand All @@ -599,27 +583,7 @@ def expected_sql(self):

return """create table <model_identifier> include schema privileges as(-- depends_on: <foreign_key_model_identifier> select 'blue' as color,1 as id,'2019-01-01' as date_day); ;"""

return """
create table
<model_identifier>
INCLUDE SCHEMA PRIVILEGES as (
select
'blue' as color,
1 as id,
'2019-01-01' as date_day
)
; ;
"""



my_incremental_model_sql = """
{{
Expand Down Expand Up @@ -665,7 +629,6 @@ def null_model_sql(self):


class TestIncrementalConstraintsRollback(BaseIncrementalConstraintsRollback):
# pass

@pytest.fixture(scope="class")
def models(self):
Expand All @@ -687,8 +650,6 @@ def null_model_sql(self):





class TestValidateSqlMethod(BaseValidateSqlMethod):
pass

Expand All @@ -711,8 +672,6 @@ def seeds(self):





class TestConstraintQuotedColumn(BaseConstraintQuotedColumn):
@pytest.fixture(scope="class")
def expected_sql(self):
Expand All @@ -729,8 +688,6 @@ def expected_sql(self):





my_model_contract_sql_header_sql = """
{{
config(
Expand Down Expand Up @@ -806,8 +763,6 @@ def models(self):
}




class BaseIncrementalContractSqlHeader(BaseContractSqlHeader):
@pytest.fixture(scope="class")
def models(self):
Expand Down

0 comments on commit 4ae2b70

Please sign in to comment.