cpath tests, rely more on it

This commit is contained in:
Dima Gerasimov 2020-05-04 08:53:41 +01:00
parent 8b8a85e8c3
commit 55ac85c7e7
3 changed files with 10 additions and 13 deletions

View file

@ -9,7 +9,7 @@ from typing import Dict, List, Optional, Iterator
from datetime import datetime from datetime import datetime
from .common import LazyLogger, get_files, group_by_key, cproperty, make_dict from .common import LazyLogger, get_files, group_by_key, cproperty, make_dict
from .kython.kompress import open as kopen from .kython.kompress import CPath
from my.config import rtm as config from my.config import rtm as config
@ -80,7 +80,7 @@ class MyTodo:
class DAL: class DAL:
def __init__(self, data: bytes, revision=None) -> None: def __init__(self, data: str, revision=None) -> None:
self.cal = icalendar.Calendar.from_ical(data) self.cal = icalendar.Calendar.from_ical(data)
self.revision = revision self.revision = revision
@ -99,8 +99,7 @@ class DAL:
def dal(): def dal():
last = get_files(config.export_path)[-1] last = get_files(config.export_path)[-1]
with kopen(last) as fo: data = CPath(last).read_text() # TODO make it automatic
data = fo.read()
return DAL(data=data, revision='TODO') return DAL(data=data, revision='TODO')

View file

@ -5,7 +5,7 @@ import lzma
import io import io
import zipfile import zipfile
from my.kython.kompress import kopen, kexists from my.kython.kompress import kopen, kexists, CPath
import pytest # type: ignore import pytest # type: ignore
@ -41,10 +41,7 @@ def test_kexists(prepare, tmp_path: Path) -> None:
assert not kexists(tmp_path / 'nosuchzip.zip', 'path/in/archive') assert not kexists(tmp_path / 'nosuchzip.zip', 'path/in/archive')
def test_cpath(): def test_cpath(prepare, tmp_path: Path) -> None:
# TODO CPath(str(tmp_path / 'file' )).read_text() == 'just plaintext'
raise RuntimeError CPath( tmp_path / 'file.xz').read_text() == 'compressed text'
# TODO not sure about zip files??
# TODO FIXME these tests should def run on CI
# TODO get rid of all decode utf8?

View file

@ -8,11 +8,12 @@ passenv = CI CI_*
# deliberately set to nonexistent pathe to check the fallback logic # deliberately set to nonexistent pathe to check the fallback logic
setenv = MY_CONFIG = nonexistent setenv = MY_CONFIG = nonexistent
commands = commands =
pip install -e . pip install -e .[testing]
# TODO ?? # TODO ??
# python -m pytest {posargs} # python -m pytest {posargs}
python3 -c 'import my.init; from my.config import stub as config; print(config.key)' python3 -c 'import my.init; from my.config import stub as config; print(config.key)'
python3 -c 'import my.init; import my.config; import my.config.repos' # shouldn't fail at least python3 -c 'import my.init; import my.config; import my.config.repos' # shouldn't fail at least
python3 -m pytest tests/misc.py tests/get_files.py
# TODO run demo.py? just make sure with_my is a bit cleverer? # TODO run demo.py? just make sure with_my is a bit cleverer?
# TODO e.g. under CI, rely on installing # TODO e.g. under CI, rely on installing