Skip to content

Commit af83629

Browse files
author
Michael Johansen
committed
Add unit tests for _get_application_import_names().
Signed-off-by: Michael Johansen <[email protected]>
1 parent 40ddc1b commit af83629

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Tests for the "_get_application_import_names" method of _cli.py."""
2+
3+
import pytest
4+
5+
from ni_python_styleguide._cli import _get_application_import_names
6+
7+
8+
@pytest.mark.parametrize(
9+
"pyproject_obj, expected_names",
10+
[
11+
(
12+
{
13+
"tool": {
14+
"ni-python-styleguide": {
15+
"application-import-names": "ain1,ain2"
16+
},
17+
"poetry": {
18+
"name": "tool.poetry.name"
19+
}
20+
},
21+
"project": {
22+
"import-names": ["import-names1", "import-names2"],
23+
"name": "project.name"
24+
}
25+
},
26+
"ain1,ain2,tests"
27+
),
28+
(
29+
{
30+
"tool": {
31+
"poetry": {
32+
"name": "tool.poetry.name"
33+
}
34+
},
35+
"project": {
36+
"import-names": ["import-names1", "import-names2"],
37+
"name": "project.name"
38+
}
39+
},
40+
"import-names1,import-names2,tests"
41+
),
42+
(
43+
{
44+
"tool": {
45+
"poetry": {
46+
"name": "tool.poetry.name"
47+
}
48+
},
49+
"project": {
50+
"name": "project.name"
51+
}
52+
},
53+
"project.name,tests"
54+
),
55+
(
56+
{
57+
"tool": {
58+
"poetry": {
59+
"name": "tool.poetry.name"
60+
}
61+
}
62+
},
63+
"tool.poetry.name,tests"
64+
)
65+
],
66+
)
67+
def test_get_application_import_names_returns_valid_data(pyproject_obj, expected_names):
68+
"""Tests that _get_application_import_names returns valid data."""
69+
result = _get_application_import_names(pyproject_obj)
70+
assert result == expected_names

0 commit comments

Comments
 (0)