Exemplo n.º 1
0
def test_hour_duration():
    act = get_base()
    durations = [
        (
            timedelta(hours=1),
            [
                "   1 hour",
                "1 hours",
                "0 hours 60 minute ",
                "60 minutes",
                "  1  h   ",
                "1h    0m   ",
                "1h 0 minute",
                "60m",
                "0h     60m",
            ],
        )
    ]
    for result, entries in durations:
        stop = act.start + result
        for entry in entries:
            act.duration = entry
            eq_(stop, act.stop, "%s should result in %s, not %s" % (entry, stop, act.stop))
Exemplo n.º 2
0
def test_single_letter_missing():
    act = get_base()
    matches = Activity.locate(act.start, datetime.now(), ["orking"])
    eq_(0, len(matches))
Exemplo n.º 3
0
def test_multiple_names():
    act = get_base()
    matches = Activity.locate(act.start, datetime.now(), ["Working", "Horking"])
    eq_(2, len(matches))
Exemplo n.º 4
0
def test_earlier_start():
    act = get_base()
    matches = Activity.locate(act.start - timedelta(days=2), datetime.now(), ["Working on tic"])
    eq_(2, len(matches))
    assert act.key() in set((m.key() for m in matches))
Exemplo n.º 5
0
def test_same_ending():
    act = get_base()
    matches = Activity.locate(act.start, datetime.now(), ["on tic"])
    eq_(2, len(matches))
    assert act.key() in set((m.key() for m in matches))
Exemplo n.º 6
0
def test_case_insensitive():
    act = get_base()
    matches = Activity.locate(act.start, datetime.now(), ["working"])
    eq_(1, len(matches))
Exemplo n.º 7
0
def test_tag():
    act = get_base()
    matches = Activity.locate(tags=["tic"])
    eq_(3, len(matches))
    assert act.key() in set((m.key() for m in matches))
Exemplo n.º 8
0
def test_single_letter_difference():
    act = get_base()
    matches = Activity.locate(act.start, datetime.now(), ["Working"])
    eq_(1, len(matches))
    eq_(act.key(), iter(matches).next().key())
Exemplo n.º 9
0
def test_bad_durations():
    act = get_base()
    for entry in ["1 ours", "12", "1q2 hour"]:
        assert_raises(ValueError, setattr, act, "duration", entry)
Exemplo n.º 10
0
 def setUp(self):
     self.app = TestApp(application)
     self.data = make_data()
     self.act = get_base()
     self.key = self.act.key()