Skip to content

Commit 9a9a072

Browse files
committed
Add test for artifacts:validate
1 parent 1530f8c commit 9a9a072

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed
Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
1+
from typing import Union
12

23

34
class TestSpecificNoxTasks:
5+
"""
6+
Within the PTB, we have nox tasks that are inherently dependent upon other ones
7+
working & delivering specific results to other ones. These relationships
8+
are tested within the GitHub workflows in a distributed manner, which means
9+
that sometimes, when issues are experienced, that it can be quite cumbersome
10+
to determine where the issue arose.
11+
12+
Additionally, the project-template itself is not tested in these workflows.
13+
So the tests included here are meant to cover common pain points to ensure
14+
both the relationships between nox tasks and ensuring that the project-template
15+
passes CI tests when a new project is created from it.
16+
"""
417
@staticmethod
5-
def _command(poetry_path: str, task: str) -> list[str]:
6-
return [poetry_path, "run", "--", "nox", "-s", task]
18+
def _command(poetry_path: str, task: str, add_ons: Union[list[str]|None]=None) -> list[str]:
19+
base = [poetry_path, "run", "--", "nox", "-s", task]
20+
if add_ons:
21+
base = base + ["--"] + add_ons
22+
return base
723

824
def test_lint_code(self, poetry_path, run_command):
925
command = self._command(poetry_path, "lint:code")
1026
output = run_command(command, check=False)
11-
assert "Session lint:code was successful." in output.stderr
27+
28+
assert output.returncode == 0
29+
30+
def test_artifact_validate(self, poetry_path, run_command):
31+
# preparation steps
32+
lint_code = self._command(poetry_path, "lint:code")
33+
run_command(lint_code)
34+
lint_security = self._command(poetry_path, "lint:security")
35+
run_command(lint_security)
36+
test_unit = self._command(poetry_path, "test:unit",["--coverage"])
37+
run_command(test_unit)
38+
test_integration = self._command(poetry_path, "test:integration",["--coverage"])
39+
run_command(test_integration)
40+
# we skip uploading & downloading artifacts, so the coverage combination is
41+
# skipped here from `artifacts:copy`
42+
43+
artifacts_validate = self._command(poetry_path, "artifacts:validate")
44+
output = run_command(artifacts_validate, check=False)
45+
1246
assert output.returncode == 0

0 commit comments

Comments
 (0)