-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case sensitivity #193
Merged
Merged
Case sensitivity #193
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
import pytest | ||
from dbt.contracts.files import FileHash | ||
from dbt.contracts.graph.nodes import ModelNode, NodeType | ||
from dbt.contracts.graph.nodes import ColumnInfo, ModelNode, NodeType | ||
|
||
from dbt_meshify.change import ResourceChange | ||
from dbt_meshify.storage.file_content_editors import ResourceFileEditor | ||
|
@@ -12,12 +12,14 @@ | |
from ..dbt_project_fixtures import shared_model_catalog_entry | ||
from ..sql_and_yml_fixtures import ( | ||
expected_contract_yml_all_col, | ||
expected_contract_yml_all_col_all_caps, | ||
expected_contract_yml_no_col, | ||
expected_contract_yml_no_entry, | ||
expected_contract_yml_one_col, | ||
expected_contract_yml_one_col_one_test, | ||
expected_contract_yml_other_model, | ||
model_yml_all_col, | ||
model_yml_all_col_all_caps, | ||
model_yml_no_col_no_version, | ||
model_yml_one_col, | ||
model_yml_one_col_one_test, | ||
|
@@ -54,12 +56,41 @@ def model() -> ModelNode: | |
) | ||
|
||
|
||
@pytest.fixture | ||
def all_cap_model() -> ModelNode: | ||
return ModelNode( | ||
database=None, | ||
resource_type=NodeType.Model, | ||
checksum=FileHash("foo", "foo"), | ||
schema="foo", | ||
name=model_name, | ||
package_name="foo", | ||
path="models/_models.yml", | ||
original_file_path=f"models/{model_name}.sql", | ||
unique_id="model.foo.foo", | ||
columns={ | ||
"ID": ColumnInfo.from_dict({"name": "ID", "description": "this is the id column"}), | ||
"COLLEAGUE": ColumnInfo.from_dict( | ||
{"name": "COLLEAGUE", "description": "this is the colleague column"} | ||
), | ||
}, | ||
fqn=["foo", "foo"], | ||
alias="foo", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def change(project, model) -> ResourceChange: | ||
contractor = Contractor(project=project) | ||
return contractor.generate_contract(model) | ||
|
||
|
||
@pytest.fixture | ||
def all_cap_model_change(project, all_cap_model) -> ResourceChange: | ||
contractor = Contractor(project=project) | ||
return contractor.generate_contract(all_cap_model) | ||
Comment on lines
82
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't terrible, but I see what you mean by code smell. I suspect that this fixture could follow a factory pattern instead, in which the fixture returns a function that itself generates or returns models that have different capitalization configurations. |
||
|
||
|
||
class TestAddContractToYML: | ||
def test_add_contract_to_yml_no_col(self, change): | ||
yml_dict = ResourceFileEditor.update_resource( | ||
|
@@ -86,3 +117,9 @@ def test_add_contract_to_yml_no_entry(self, change): | |
def test_add_contract_to_yml_other_model(self, change): | ||
yml_dict = ResourceFileEditor.update_resource(read_yml(model_yml_other_model), change) | ||
assert yml_dict == read_yml(expected_contract_yml_other_model) | ||
|
||
def test_add_contract_to_yml_all_caps_columns(self, all_cap_model_change): | ||
yml_dict = ResourceFileEditor.update_resource( | ||
read_yml(model_yml_all_col_all_caps), all_cap_model_change | ||
) | ||
assert yml_dict == read_yml(expected_contract_yml_all_col_all_caps) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally correct and likely ideal due to readability! Another way of doing this is through the use of
get
's second argument.