-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #644 from Riverside-Healthcare/dev
- Loading branch information
Showing
18 changed files
with
475 additions
and
74 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
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
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,34 @@ | ||
"""Test django quoted tags. | ||
poetry run pytest tests/test_django/test_filter.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.reformat import formatter | ||
from tests.conftest import printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
( | ||
"<h1>\n" | ||
' {% if condition1 %}<span class="cls"></span>{% endif %}\n' | ||
' {% if condition2 %}"{{ text }}"{% endif %}\n' | ||
" </h1>\n" | ||
), | ||
( | ||
"<h1>\n" | ||
' {% if condition1 %}<span class="cls"></span>{% endif %}\n' | ||
' {% if condition2 %}"{{ text }}"{% endif %}\n' | ||
"</h1>\n" | ||
), | ||
id="issue #640", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source, expected, django_config): | ||
output = formatter(django_config, source) | ||
|
||
printer(expected, source, output) | ||
assert expected == output |
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,45 @@ | ||
"""Test linter code H005. | ||
poetry run pytest tests/test_linter/test_h005.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.lint import linter | ||
from tests.conftest import lint_printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
("<!DOCTYPE html>\n<html>"), | ||
( | ||
[ | ||
{ | ||
"code": "H005", | ||
"line": "2:0", | ||
"match": "<html>", | ||
"message": "Html tag should have lang attribute.", | ||
}, | ||
{ | ||
"code": "H025", | ||
"line": "2:0", | ||
"match": "<html>", | ||
"message": "Tag seems to be an orphan.", | ||
}, | ||
] | ||
), | ||
id="one", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source, expected, nunjucks_config): | ||
filename = "test.html" | ||
output = linter(nunjucks_config, source, filename, filename) | ||
|
||
lint_printer(source, expected, output[filename]) | ||
|
||
mismatch = list(filter(lambda x: x not in expected, output[filename])) + list( | ||
filter(lambda x: x not in output[filename], expected) | ||
) | ||
|
||
assert len(mismatch) == 0 |
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,49 @@ | ||
"""Test linter code H006. | ||
poetry run pytest tests/test_linter/test_h006.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.lint import linter | ||
from tests.conftest import lint_printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
('<img alt="test"/>'), | ||
( | ||
[ | ||
{ | ||
"code": "H006", | ||
"line": "1:0", | ||
"match": '<img alt="test"/>', | ||
"message": "Img tag should have height and width attributes.", | ||
} | ||
] | ||
), | ||
id="one", | ||
), | ||
pytest.param( | ||
( | ||
'{# [INFO][JINJA] I use syntax "{% if <img alt=""\n' | ||
' if I want that something happened solely if "img" exists in the content of my articles #}\n' | ||
"\n" | ||
' <script src="script.js" defer></script>\n' | ||
), | ||
([]), | ||
id="partial ignored", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source, expected, nunjucks_config): | ||
filename = "test.html" | ||
output = linter(nunjucks_config, source, filename, filename) | ||
|
||
lint_printer(source, expected, output[filename]) | ||
|
||
mismatch = list(filter(lambda x: x not in expected, output[filename])) + list( | ||
filter(lambda x: x not in output[filename], expected) | ||
) | ||
|
||
assert len(mismatch) == 0 |
Oops, something went wrong.