move all test files into their own folder, as if this were an authentik recipe repo
This commit is contained in:
parent
3841658e4e
commit
d2f50fb791
22 changed files with 0 additions and 0 deletions
0
recipes/demo/tests_demo/__init__.py
Normal file
0
recipes/demo/tests_demo/__init__.py
Normal file
26
recipes/demo/tests_demo/fixtures_demo.py
Normal file
26
recipes/demo/tests_demo/fixtures_demo.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
This file can be used to define fixtures thate are then used by other tests which
|
||||
depend on [demo]. For this to work
|
||||
|
||||
1. the Runner class of the other test needs to define the depencency as seen
|
||||
by referencing RunnerDemo in the dependencies list:
|
||||
|
||||
from src.tests_demo.runner_demo import RunnerDemo
|
||||
|
||||
class RunnerOther(Runner):
|
||||
dependencies = [RunnerDemo]
|
||||
|
||||
|
||||
2. the specific tests that rely on these fixtures need to import the fixtures.
|
||||
To globally import for all tests in 'other', the import should be done in conftest:
|
||||
|
||||
in 'conftest.py' in 'test_other' dir:
|
||||
from src.tests_demo.fixtures_demo import demo_fixture
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def demo_fixture():
|
||||
return ""
|
||||
25
recipes/demo/tests_demo/runner_demo.py
Normal file
25
recipes/demo/tests_demo/runner_demo.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from src.runner import Runner, Test
|
||||
|
||||
|
||||
class RunnerDemo(Runner):
|
||||
"""Every env file has a corresponding runner class"""
|
||||
|
||||
name: str = "demo" # name of the test, used for logging / output naming
|
||||
test_dir_name: str = "tests_demo" # dir name holding all tests related to RunnerDemo
|
||||
|
||||
# this indicates that tests from RunnerDemo depend on the setup from RunnerAuthentik.
|
||||
# RunnerDemo will only execute, when setup_authentik.py has finished successfully.
|
||||
# For example, setup_authentik.py generates session states, that can be used as fixtures
|
||||
# that can be loaded from fixtures_authentik.py
|
||||
dependencies: list[str] = ["authentik"]
|
||||
|
||||
# todo: update these comments
|
||||
# Filename of Demo setup. If defined, it will run 1st by executing pytest
|
||||
# Filename of Demo test. This file contains unconditional tests that will be run in any
|
||||
# case. If defined, it will run 2nd by executing pytest
|
||||
# this list can hold many more tests from RunnerDemo that run conditional. The condition
|
||||
# and the test file can be defined by creating a ConditionalTest instance:
|
||||
# ConditionalTest(condition: Callable, test_file: str)
|
||||
setups: list[Test] = []
|
||||
tests: list[Test] = []
|
||||
cleanups: list[Test] = []
|
||||
3
recipes/demo/tests_demo/setup_demo.py
Normal file
3
recipes/demo/tests_demo/setup_demo.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Define functions here that are specifically meant for setup, not for testing. This means
|
||||
# all actions that simply are required for other tests from 'demo' to run. Runs before all
|
||||
# tests from 'demo'.
|
||||
Loading…
Add table
Add a link
Reference in a new issue