another attempt to make the configs more self-documenting: via NamedTuple
This commit is contained in:
parent
4b8c2d4be4
commit
c877104b90
2 changed files with 66 additions and 47 deletions
|
@ -1,16 +1,17 @@
|
|||
from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from my.reddit import events, inputs, saved
|
||||
from my.common import make_dict
|
||||
|
||||
|
||||
def test() -> None:
|
||||
from my.reddit import events, inputs, saved
|
||||
list(events())
|
||||
list(saved())
|
||||
|
||||
|
||||
def test_unfav() -> None:
|
||||
from my.reddit import events, inputs, saved
|
||||
ev = events()
|
||||
url = 'https://reddit.com/r/QuantifiedSelf/comments/acxy1v/personal_dashboard/'
|
||||
uev = [e for e in ev if e.url == url]
|
||||
|
@ -23,6 +24,7 @@ def test_unfav() -> None:
|
|||
|
||||
|
||||
def test_saves() -> None:
|
||||
from my.reddit import events, inputs, saved
|
||||
# TODO not sure if this is necesasry anymore?
|
||||
saves = list(saved())
|
||||
# just check that they are unique..
|
||||
|
@ -30,6 +32,7 @@ def test_saves() -> None:
|
|||
|
||||
|
||||
def test_disappearing() -> None:
|
||||
from my.reddit import events, inputs, saved
|
||||
# eh. so for instance, 'metro line colors' is missing from reddit-20190402005024.json for no reason
|
||||
# but I guess it was just a short glitch... so whatever
|
||||
saves = events()
|
||||
|
@ -39,12 +42,18 @@ def test_disappearing() -> None:
|
|||
|
||||
|
||||
def test_unfavorite() -> None:
|
||||
from my.reddit import events, inputs, saved
|
||||
evs = events()
|
||||
unfavs = [s for s in evs if s.text == 'unfavorited']
|
||||
[xxx] = [u for u in unfavs if u.eid == 'unf-19ifop']
|
||||
assert xxx.dt == datetime(2019, 1, 28, 8, 10, 20, tzinfo=pytz.utc)
|
||||
|
||||
|
||||
def test_extra_attr() -> None:
|
||||
from my.reddit import config
|
||||
assert isinstance(getattr(config, 'passthrough'), str)
|
||||
|
||||
|
||||
import pytest # type: ignore
|
||||
@pytest.fixture(autouse=True, scope='module')
|
||||
def prepare():
|
||||
|
@ -55,3 +64,5 @@ def prepare():
|
|||
# first bit is for 'test_unfavorite, the second is for test_disappearing
|
||||
files = files[300:330] + files[500:520]
|
||||
config.export_dir = files # type: ignore
|
||||
|
||||
setattr(config, 'passthrough', "isn't handled, but available dynamically nevertheless")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue