tests: move remaining tests from tests/ to my.tests, cleanup corresponding modules
This commit is contained in:
parent
a5643206a0
commit
b87d1c970a
9 changed files with 120 additions and 134 deletions
57
my/tests/body/weight.py
Normal file
57
my/tests/body/weight.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
from pathlib import Path
|
||||
import pytz
|
||||
from my.core.cfg import tmp_config
|
||||
import pytest
|
||||
from my.body.weight import from_orgmode
|
||||
|
||||
|
||||
def test_body_weight() -> None:
|
||||
weights = [0.0 if isinstance(x, Exception) else x.value for x in from_orgmode()]
|
||||
|
||||
assert weights == [
|
||||
0.0,
|
||||
62.0,
|
||||
0.0,
|
||||
61.0,
|
||||
62.0,
|
||||
0.0,
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def prepare(tmp_path: Path):
|
||||
ndir = tmp_path / 'notes'
|
||||
ndir.mkdir()
|
||||
logs = ndir / 'logs.org'
|
||||
logs.write_text(
|
||||
'''
|
||||
#+TITLE: Stuff I'm logging
|
||||
|
||||
* Weight (org-capture) :weight:
|
||||
** [2020-05-01 Fri 09:00] 62
|
||||
** 63
|
||||
this should be ignored, got no timestamp
|
||||
** [2020-05-03 Sun 08:00] 61
|
||||
** [2020-05-04 Mon 10:00] 62
|
||||
'''
|
||||
)
|
||||
misc = ndir / 'misc.org'
|
||||
misc.write_text(
|
||||
'''
|
||||
Some misc stuff
|
||||
|
||||
* unrelated note :weight:whatever:
|
||||
'''
|
||||
)
|
||||
|
||||
class orgmode:
|
||||
paths = [ndir]
|
||||
|
||||
class weight:
|
||||
# TODO ugh. this belongs to tz provider or global config or something
|
||||
default_timezone = pytz.timezone('Europe/London')
|
||||
|
||||
with tmp_config() as cfg:
|
||||
cfg.orgmode = orgmode
|
||||
cfg.weight = weight
|
||||
yield
|
Loading…
Add table
Add a link
Reference in a new issue