-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
157 lines (139 loc) · 4.01 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"""Nox sessions."""
import nox
from nox.sessions import Session
import nox_poetry
nox.options.envdir = ".cache"
nox.options.reuse_existing_virtualenvs = True
locations = "src", "tests", "noxfile.py"
nox.options.sessions = (
"lint",
"mypy",
"unit_tests",
"integration_tests",
"contract_tests",
)
@nox_poetry.session(python=["3.9"])
def unit_tests(session: Session) -> None:
"""Run the unit test suite."""
args = session.posargs
session.install(
".",
"pytest",
"requests-mock",
"pytest-mock",
"asynctest",
)
session.run(
"pytest",
"-m unit",
"-ra",
*args,
env={
"ORGANIZATION_CATALOG_URI": "http://localhost:8000",
"DATA_BRREG_URI": "http://localhost:8000",
"REFERENCE_DATA_URI": "http://localhost:8000",
"FDK_PORTAL_URI": "http://localhost:8000",
"FDK_METADATA_QUALITY_URI": "http://localhost:8000",
"FDK_SPARQL_URI": "http://localhost:8000/sparql",
},
)
@nox_poetry.session(python=["3.9"])
def integration_tests(session: Session) -> None:
"""Run the integration test suite."""
args = session.posargs
session.install(
".",
"pytest",
"pytest-docker",
"requests-mock",
"pytest-mock",
"pytest-aiohttp",
"asynctest",
)
session.run(
"pytest",
"-m integration",
"-ra",
*args,
env={
"ORGANIZATION_CATALOG_URI": "http://localhost:8000",
"DATA_BRREG_URI": "http://localhost:8000",
"REFERENCE_DATA_URI": "http://localhost:8000",
"FDK_PORTAL_URI": "http://localhost:8000",
"FDK_METADATA_QUALITY_URI": "http://localhost:8000",
"FDK_SPARQL_URI": "http://localhost:8000/sparql",
},
)
@nox_poetry.session(python=["3.9"])
def tests(session: Session) -> None:
"""Run the integration test suite."""
args = session.posargs or ["--cov"]
session.install(
".",
"coverage[toml]",
"pytest",
"pytest-cov",
"pytest-docker",
"requests-mock",
"pytest-mock",
"pytest-aiohttp",
"asynctest",
)
session.run(
"pytest",
"-ra",
*args,
env={
"ORGANIZATION_CATALOG_URI": "http://localhost:8000",
"DATA_BRREG_URI": "http://localhost:8000",
"REFERENCE_DATA_URI": "http://localhost:8000",
"FDK_PORTAL_URI": "http://localhost:8000",
"FDK_METADATA_QUALITY_URI": "http://localhost:8000",
"FDK_SPARQL_URI": "http://localhost:8000/sparql",
},
)
@nox_poetry.session(python=["3.9"])
def contract_tests(session: Session) -> None:
"""Run the contract test suite."""
args = session.posargs
session.install(
".", "pytest", "pytest-docker", "asynctest", "requests_mock", "pytest_mock"
)
session.run(
"pytest",
"-m contract",
"-ra",
*args,
)
@nox_poetry.session(python=["3.9"])
def black(session: Session) -> None:
"""Run black code formatter."""
args = session.posargs or locations
session.install("black")
session.run("black", *args)
@nox_poetry.session(python=["3.9"])
def lint(session: Session) -> None:
"""Lint using flake8."""
args = session.posargs or locations
session.install(
"flake8",
"flake8-annotations",
"flake8-bandit",
"flake8-black",
"flake8-bugbear",
"flake8-docstrings",
"flake8-import-order",
"pep8-naming",
)
session.run("flake8", *args)
@nox_poetry.session(python=["3.9"])
def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or locations
session.install("mypy")
session.run("mypy", *args)
@nox_poetry.session(python=["3.9"])
def coverage(session: Session) -> None:
"""Upload coverage data."""
session.install("coverage[toml]")
session.run("coverage", "xml", "--fail-under=0")