-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Segregate dbt plugin tests * linting * update contributing.md Co-authored-by: Barry Pollard <barry@tunetheweb.com>
- Loading branch information
1 parent
6e4f2fc
commit 30a04a0
Showing
42 changed files
with
76 additions
and
92 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Init PY for tests.""" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""The Test file for the linter class.""" | ||
|
||
import os | ||
import os.path | ||
|
||
from sqlfluff.core import Linter, FluffConfig | ||
from test.fixtures.dbt.templater import DBT_FLUFF_CONFIG, project_dir # noqa: F401 | ||
|
||
|
||
def test__linter__skip_dbt_model_disabled(project_dir): # noqa | ||
"""Test that the linter skips disabled dbt models.""" | ||
conf = FluffConfig(configs=DBT_FLUFF_CONFIG) | ||
lntr = Linter(config=conf) | ||
model_file_path = os.path.join( | ||
project_dir, "models/my_new_project/disabled_model.sql" | ||
) | ||
linted_path = lntr.lint_path(path=model_file_path) | ||
# Check that the file is still there | ||
assert len(linted_path.files) == 1 | ||
linted_file = linted_path.files[0] | ||
# Normalise paths to control for OS variance | ||
assert os.path.normpath(linted_file.path) == os.path.normpath(model_file_path) | ||
assert not linted_file.templated_file | ||
assert not linted_file.tree |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Tests for the standard set of rules.""" | ||
import pytest | ||
import os | ||
|
||
from sqlfluff.core.config import FluffConfig | ||
from sqlfluff.testing.rules import assert_rule_raises_violations_in_file | ||
|
||
from test.fixtures.dbt.templater import ( # noqa | ||
DBT_FLUFF_CONFIG, | ||
project_dir, | ||
dbt_templater, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"rule,path,violations", | ||
[ | ||
# Group By | ||
("L021", "models/my_new_project/select_distinct_group_by.sql", [(1, 8)]), | ||
], | ||
) | ||
def test__rules__std_file_dbt(rule, path, violations, project_dir): # noqa | ||
"""Test the linter finds the given errors in (and only in) the right places (DBT).""" | ||
assert_rule_raises_violations_in_file( | ||
rule=rule, | ||
fpath=os.path.join(project_dir, path), | ||
violations=violations, | ||
fluff_config=FluffConfig(configs=DBT_FLUFF_CONFIG, overrides=dict(rules=rule)), | ||
) |
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
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