コード例 #1
0
def prepare(tmp_path: Path):
    from .common import reset_modules
    reset_modules()

    LTZ._FASTER = True

    from .location import _prepare_google_config
    google = _prepare_google_config(tmp_path)

    class location:
        home = (
            # supports ISO strings
            ('2005-12-04', (42.697842, 23.325973)),  # Bulgaria, Sofia
            # supports date/datetime objects
            (date(year=1980, month=2, day=15), (40.7128, -74.0060)),  # NY
            # check tz handling..
            (datetime.fromtimestamp(1600000000, tz=timezone.utc),
             (55.7558, 37.6173)),  # Moscow, Russia
        )
        # note: order doesn't matter, will be sorted in the data provider

    class time:
        class tz:
            pass  # just rely on the default..

    import my.core.cfg as C
    with C.tmp_config() as config:
        config.google = google
        config.time = time
        config.location = location
        yield
コード例 #2
0
ファイル: location.py プロジェクト: ktaranov/HPI-1
def prepare(tmp_path: Path):
    from .common import reset_modules
    reset_modules()

    user_config = _prepare_google_config(tmp_path)

    import my.core.cfg as C
    with C.tmp_config() as config:
        config.google = user_config  # type: ignore
        yield
コード例 #3
0
def prepare():
    from .common import testdata
    bmdata = testdata() / 'hpi-testdata' / 'bluemaestro'
    assert bmdata.exists(), bmdata

    class bluemaestro:
        export_path = bmdata

    from my.core.cfg import tmp_config
    with tmp_config() as config:
        config.bluemaestro = bluemaestro
        yield
コード例 #4
0
def prepare():
    testdata = Path(__file__).absolute().parent.parent / 'testdata'
    bmdata = testdata / 'hpi-testdata' / 'bluemaestro'
    assert bmdata.exists(), bmdata

    class bluemaestro:
        export_path = bmdata

    from my.core.cfg import tmp_config
    with tmp_config() as config:
        config.bluemaestro = bluemaestro
        yield
コード例 #5
0
def prepare():
    from .common import testdata
    data = testdata() / 'hpi-testdata' / 'reddit'
    assert data.exists(), data

    # note: deliberately using old config schema so we can test migrations
    class test_config:
        export_dir = data
        please_keep_me = 'whatever'

    from my.core.cfg import tmp_config
    with tmp_config() as config:
        config.reddit = test_config
        yield
コード例 #6
0
ファイル: commits.py プロジェクト: karlicoss/HPI
def prepare(tmp_path: Path):
    # TODO maybe test against actual testdata, could check for
    # - datetime handling
    # - bare repos
    # - canonical name
    # - caching?
    hpi_repo_root = Path(__file__).absolute().parent.parent
    assert (hpi_repo_root / '.git').exists(), hpi_repo_root

    class commits:
        emails = {'*****@*****.**'}
        names = {'Dima'}
        roots = [hpi_repo_root]

    from my.core.cfg import tmp_config
    with tmp_config() as config:
        config.commits = commits
        yield
コード例 #7
0
ファイル: pdfs.py プロジェクト: karlicoss/HPI
def with_config():
    from .common import reset_modules
    reset_modules()  # todo ugh.. getting boilerplaty.. need to make it a bit more automatic..

    # extra_data = Path(__file__).absolute().parent / 'extra/data/polar'
    # assert extra_data.exists(), extra_data
    # todo hmm, turned out no annotations in these ones.. whatever

    class user_config:
        roots = [
            testdata(),
        ]

    import my.core.cfg as C
    with C.tmp_config() as config:
        config.pdfs = user_config  # type: ignore
        try:
            yield
        finally:
            reset_modules()
コード例 #8
0
ファイル: config.py プロジェクト: karlicoss/HPI
def test_dynamic_configuration(notes: Path) -> None:
    import pytz
    from types import SimpleNamespace as NS

    from my.core.cfg import tmp_config
    with tmp_config() as C:
        C.orgmode = NS(paths=[notes])
        # TODO ugh. this belongs to tz provider or global config or someting
        C.weight  = NS(default_timezone=pytz.timezone('Europe/London'))

        from my.body.weight import from_orgmode
        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,
    ]