Skip to content

Commit

Permalink
feat: Enhance existing repo with improved meta data (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jezumbro authored Apr 3, 2023
1 parent 742b389 commit 9c234d1
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 198 deletions.
33 changes: 21 additions & 12 deletions phulpyfile.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
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'])
phulpy.start(["lint", "typecheck", "unit_test"])


@task
def lint(phulpy):
result = system('flake8 pydantic_mongo')
if result:
raise Exception('lint test failed')
pydantic_mongo_dir = "pydantic_mongo"
for cmd, message in (
(f"flake8 {pydantic_mongo_dir}", "lint test failed"),
(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("lint test failed")


@task
def unit_test(phulpy):
result = system(
'pytest --cov-report term-missing'
+ ' --cov-report xml --cov=pydantic_mongo test'
"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')
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')
if float(xml.get("line-rate")) < 1:
raise Exception("Unit test is not fully covered")


@task
def typecheck(phulpy):
result = system(r'find ./pydantic_mongo -name "*.py" -exec mypy --ignore-missing-imports --follow-imports=skip --strict-optional {} \+')
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')
raise Exception("lint test failed")
6 changes: 3 additions & 3 deletions pydantic_mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .abstract_repository import AbstractRepository # noqa
from .fields import ObjectIdField # noqa
from .version import __version__ # noqa
from .abstract_repository import AbstractRepository # noqa
from .fields import ObjectIdField # noqa
from .version import __version__ # noqa
Loading

0 comments on commit 9c234d1

Please sign in to comment.