forked from jefersondaniel/pydantic-mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phulpyfile.py
56 lines (45 loc) · 1.46 KB
/
phulpyfile.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
import xml.etree.ElementTree as ET
from os import system, unlink
from os.path import dirname, join
from phulpy import task
@task
def test(phulpy):
phulpy.start([
"lint",
# "typecheck",
"unit_test"])
@task
def lint(phulpy):
pydantic_mongo_dir = "pydantic_mongo"
for cmd, message in (
(f"flake8 {pydantic_mongo_dir}", "please check flake8 errors"),
(f"isort {pydantic_mongo_dir} --profile black --check", "please run isort!"),
# (f"black {pydantic_mongo_dir} --check", "please run black!"),
):
result = system(cmd)
if result:
raise Exception(f"Lint failed: {message}")
@task
def unit_test(phulpy):
result = system(
"pytest --cov-report term-missing"
" --cov-report xml --cov=pydantic_mongo test"
)
if result:
raise Exception("Unit tests failed")
coverage_path = join(dirname(__file__), "coverage.xml")
xml = ET.parse(coverage_path).getroot()
if float(xml.get("line-rate")) < 1:
raise Exception("Unit test is not fully covered")
@task
def integration_test(phulpy):
result = system("pytest integration_test")
if result:
raise Exception("Integration tests failed")
# @task
# def typecheck(phulpy):
# result = system(
# r'find ./pydantic_mongo -name "*.py" -exec mypy --ignore-missing-imports --follow-imports=skip --strict-optional {} \+'
# )
# if result:
# raise Exception("lint test failed")