示例#1
0
def test_time_filter0003(jrnl, now):  # noqa: F811
    """Test relative end time"""

    filters = FilterSettings(time_filter=TimeFilter.from_arg(":1d"))
    path1 = insert_entry(jrnl, title="old", time=now - timedelta(days=3))
    insert_entry(jrnl, title="new")
    ents = jrnl._collect_entries(filters)

    assert len(ents) == 1
    assert ents[0].path == path1
示例#2
0
def test_time_filter0006(jrnl, now):  # noqa: F811
    """Test absolute end time"""

    tstr = (now - timedelta(days=1)).strftime(":%Y-%m-%d")
    filters = FilterSettings(time_filter=TimeFilter.from_arg(tstr))
    path1 = insert_entry(jrnl, title="old", time=now - timedelta(days=3))
    insert_entry(jrnl, title="new")
    ents = jrnl._collect_entries(filters)

    assert len(ents) == 1
    assert ents[0].path == path1
示例#3
0
def test_time_filter0009(jrnl, now):  # noqa: F811
    """Checks that a immortal entry unconditionally passes the time filter"""

    tstr = (now - timedelta(days=2)).strftime("%Y-%m-%d")
    filters = FilterSettings(time_filter=TimeFilter.from_arg(tstr))
    path = insert_entry(jrnl,
                        title="old_immortal",
                        time=now - timedelta(days=500 * 365),
                        attrs="immortal")

    ents = jrnl._collect_entries(filters)
    assert len(ents) == 1
    assert ents[0].path == path
示例#4
0
def test_time_filter0008(jrnl, now):  # noqa: F811
    """Test absolute start and end time"""

    tstr1 = (now - timedelta(days=2)).strftime("%Y-%m-%d")
    tstr2 = (now - timedelta(days=1)).strftime("%Y-%m-%d")
    tstr = "%s:%s" % (tstr1, tstr2)
    filters = FilterSettings(time_filter=TimeFilter.from_arg(tstr))
    insert_entry(jrnl, title="old", time=now - timedelta(days=5))
    path2 = insert_entry(jrnl, title="new", time=now - timedelta(days=2))
    insert_entry(jrnl, title="newer", time=now + timedelta(days=5))
    ents = jrnl._collect_entries(filters)

    assert len(ents) == 1
    assert ents[0].path == path2
示例#5
0
def filters():
    from j import FilterSettings
    return FilterSettings()