-
Notifications
You must be signed in to change notification settings - Fork 39
/
noxfile.py
84 lines (64 loc) · 1.97 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from __future__ import annotations
from contextlib import contextmanager
from pathlib import Path
from typing import Iterable
import nox
# imports all nox task provided by the toolbox
from exasol.toolbox.nox.tasks import * # pylint: disable=wildcard-import disable=unused-wildcard-import
from nox import Session
# default actions to be run if nothing is explicitly specified with the -s option
nox.options.sessions = ["project:fix"]
__all__ = [
"unit_tests",
"integration_tests",
]
_ROOT: Path = Path(__file__).parent
def _test_command(path: Path) -> Iterable[str]:
base_command = ["poetry", "run"]
pytest_command = [
"pytest",
"-v",
"--log-level=INFO",
"--log-cli-level=INFO",
f"{path}",
]
return base_command + pytest_command
@nox.session(name="db:start", python=False)
def start_db(session: Session) -> None:
"""Start a test database"""
session.run(
"itde",
"spawn-test-environment",
"--environment-name",
"test",
"--database-port-forward",
"8563",
"--bucketfs-port-forward",
"2580",
"--docker-db-image-version",
"7.1.17",
"--db-mem-size",
"4GB",
external=True,
)
@nox.session(name="db:stop", python=False)
def stop_db(session: Session) -> None:
"""Stop the test database"""
session.run("docker", "kill", "db_container_test", external=True)
@nox.session(name="db:import", python=False)
def import_data(session: Session) -> None:
"""Import test data into the database"""
import sys
path = _ROOT / "test" / "integration"
data_dir = _ROOT / "test" / "data"
sys.path.append(f"{path}")
from conftest import DockerDataLoader
loader = DockerDataLoader(
dsn="127.0.0.1:8563",
username="sys",
password="exasol",
container_name="db_container_test",
data_directory=data_dir,
)
loader.load()
# Import documentation related nox tasks from toolbox