forked from wemake-services/dotenv-linter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added violation tests and violation code tests. FIxes wemake-services#12
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
def test_all_violations_are_documented(all_module_violations): | ||
"""Ensures that all violations are documented""" | ||
for module, classes in all_module_violations.items(): | ||
for violantion_class in classes: | ||
# Once per `summary` and once for `autoclass` | ||
assert module.__doc__.count(violantion_class.__qualname__) == 2 | ||
|
||
def test_all_violations_have_versionadded(all_violations): | ||
"""Ensures that all violations have `versionadded` tag""" | ||
for violation in all_violations: | ||
assert '..versionadded' in violation.__doc__ | ||
|
||
def test_violation_name(all_violations): | ||
"""Ensures all violations have `Violation` suffix""" | ||
for violation in all_violations: | ||
class_name = violation.__qualname__ | ||
assert class_name.endswith('Violation'), class_name | ||
|
||
def test_configuration(all_violations): | ||
"""Ensures all configuration options are listed in the docs.""" | ||
#TODO. This function relies on a configuration file that has yet to be | ||
#completed and implemented. | ||
return None |
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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import ast | ||
|
||
from dotenv_linter.violations.base import ( | ||
BaseViolation, | ||
BaseFSTViolation, | ||
BaseFileViolation, | ||
) | ||
|
||
def test_visitor_returns_location(): | ||
"""Ensures that `BaseNodeVisitor` return correct violation message.""" | ||
visitor = BaseFSTViolation(node=ast.parse(''), text='violation') | ||
visitor.error_template = '{0}' | ||
visitor.code = 1 | ||
assert visitor._node() == (0, 0, 'Z001 violation') | ||
|
||
def test_checker_default_locations(): | ||
"""Ensures that `BaseViolation` returns correct location. """ | ||
assert BaseViolation(None, None).location() == (0, 0) #noqa: Z441 |