|
| 1 | +from typing import Union |
1 | 2 |
|
2 | 3 |
|
3 | 4 | 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 | + """ |
4 | 17 | @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 |
7 | 23 |
|
8 | 24 | def test_lint_code(self, poetry_path, run_command): |
9 | 25 | command = self._command(poetry_path, "lint:code") |
10 | 26 | 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 | + |
12 | 46 | assert output.returncode == 0 |
0 commit comments