my.endomondo: add fake data generator, test mypy
This commit is contained in:
parent
1c20eb27aa
commit
d8841d0d7a
3 changed files with 27 additions and 3 deletions
|
@ -20,3 +20,6 @@ class github:
|
||||||
|
|
||||||
class reddit:
|
class reddit:
|
||||||
export_path: Paths = ''
|
export_path: Paths = ''
|
||||||
|
|
||||||
|
class endomondo:
|
||||||
|
export_path: Paths = ''
|
||||||
|
|
|
@ -31,14 +31,14 @@ def inputs() -> Sequence[Path]:
|
||||||
|
|
||||||
|
|
||||||
# todo add a doctor check for pip endoexport module
|
# todo add a doctor check for pip endoexport module
|
||||||
import endoexport.dal
|
import endoexport.dal as dal
|
||||||
from endoexport.dal import Point, Workout
|
from endoexport.dal import Point, Workout
|
||||||
|
|
||||||
|
|
||||||
# todo cachew?
|
# todo cachew?
|
||||||
def workouts() -> Iterable[Res[Workout]]:
|
def workouts() -> Iterable[Res[Workout]]:
|
||||||
dal = endoexport.dal.DAL(inputs())
|
_dal = dal.DAL(inputs())
|
||||||
yield from dal.workouts()
|
yield from _dal.workouts()
|
||||||
|
|
||||||
|
|
||||||
def dataframe(defensive=True):
|
def dataframe(defensive=True):
|
||||||
|
@ -77,3 +77,22 @@ def stats():
|
||||||
|
|
||||||
|
|
||||||
# TODO make sure it's possible to 'advise' functions and override stuff
|
# TODO make sure it's possible to 'advise' functions and override stuff
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
|
@contextmanager
|
||||||
|
def fake_data(count: int=100):
|
||||||
|
from .core.cfg import override_config
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
import json
|
||||||
|
with override_config(endomondo) as cfg, TemporaryDirectory() as td:
|
||||||
|
tdir = Path(td)
|
||||||
|
cfg.export_path = tdir
|
||||||
|
|
||||||
|
# todo would be nice to somehow expose the generator so it's possible to hack from the outside?
|
||||||
|
fd = dal.FakeData()
|
||||||
|
data = fd.generate(count=count)
|
||||||
|
|
||||||
|
jf = tdir / 'data.json'
|
||||||
|
jf.write_text(json.dumps(data))
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -36,12 +36,14 @@ commands =
|
||||||
pip install git+https://github.com/karlicoss/instapexport
|
pip install git+https://github.com/karlicoss/instapexport
|
||||||
pip install git+https://github.com/karlicoss/pockexport
|
pip install git+https://github.com/karlicoss/pockexport
|
||||||
pip install git+https://github.com/karlicoss/rexport
|
pip install git+https://github.com/karlicoss/rexport
|
||||||
|
pip install git+https://github.com/karlicoss/endoexport
|
||||||
# todo I guess use a script...
|
# todo I guess use a script...
|
||||||
python3 -m mypy -p my.github.ghexport \
|
python3 -m mypy -p my.github.ghexport \
|
||||||
-p my.hypothesis \
|
-p my.hypothesis \
|
||||||
-p my.instapaper \
|
-p my.instapaper \
|
||||||
-p my.pocket \
|
-p my.pocket \
|
||||||
-p my.reddit \
|
-p my.reddit \
|
||||||
|
-p my.endomondo \
|
||||||
--txt-report .mypy-coverage \
|
--txt-report .mypy-coverage \
|
||||||
--html-report .mypy-coverage \
|
--html-report .mypy-coverage \
|
||||||
{posargs}
|
{posargs}
|
||||||
|
|
Loading…
Add table
Reference in a new issue