Skip to content

Commit

Permalink
Adding
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-Thakur committed Nov 6, 2023
1 parent fe39fc9 commit a264913
Showing 1 changed file with 39 additions and 22 deletions.
61 changes: 39 additions & 22 deletions tests/functional/adapter/constraints/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@

import pytest


SEEDS__DATA_EQUALS_CSV = """key_name,x,y,expected
1,1,1,same
2,1,2,different
3,1,,different
4,2,1,different
5,2,2,same
6,2,,different
7,,1,different
8,,2,different
9,,,same
"""

# model breaking constraints
my_model_with_nulls_sql = """
Expand Down Expand Up @@ -172,7 +182,7 @@ def test__constraints_enforcement_rollback(
write_file(null_model_sql, "models", "my_model.sql")

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

# # Verify the previous table still exists
Expand Down Expand Up @@ -244,33 +254,40 @@ def null_model_sql(self):



# class TestValidateSqlMethod(BaseValidateSqlMethod):
# pass
class TestValidateSqlMethod(BaseValidateSqlMethod):
pass

# class TestNullCompare(BaseNullCompare):
# pass
class TestNullCompare(BaseNullCompare):
pass


# class TestMixedNullCompare(BaseMixedNullCompare):
# pass
class TestMixedNullCompare(BaseMixedNullCompare):
pass


# class TestEquals(BaseEquals):
# pass
class TestEquals(BaseEquals):

@pytest.fixture(scope="class")
def seeds(self):
return {
"data_equals.csv": SEEDS__DATA_EQUALS_CSV,
}
pass





# class TestConstraintQuotedColumn(BaseConstraintQuotedColumn):
# @pytest.fixture(scope="class")
# def expected_sql(self):
# return """
# create table <model_identifier> INCLUDE SCHEMA PRIVILEGES as ( select 'blue' as "from", 1 as id, '2019-01-01' as date_day ) ; """
# pass
class TestConstraintQuotedColumn(BaseConstraintQuotedColumn):
@pytest.fixture(scope="class")
def expected_sql(self):
return """
create table <model_identifier> INCLUDE SCHEMA PRIVILEGES as ( select 'blue' as "from", 1 as id, '2019-01-01' as date_day ) ; """
pass

# class TestModelConstraintsRuntimeEnforcement(BaseModelConstraintsRuntimeEnforcement):
# @pytest.fixture(scope="class")
# 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 ) ;
# """
class TestModelConstraintsRuntimeEnforcement(BaseModelConstraintsRuntimeEnforcement):
@pytest.fixture(scope="class")
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 ) ;
"""

0 comments on commit a264913

Please sign in to comment.