def test_exclude_early_dates(self): from datetime import date res = list(exclude(self.cfg, data)) nt.assert_true(len(res) > 0) for r in res: nt.assert_true(date.today() - r["date"] > self.cfg[module]["date"][1]["values"][0])
def test_exclude_old_and_early_dates(self): """multiple filter tests within a key""" from datetime import date res = list(exclude(self.cfg, data)) nt.assert_true(len(res) > 0) for r in res: nt.assert_true(date.today() - r["date"] < self.cfg[module]["date"][0]["values"][0]) nt.assert_true(date.today() - r["date"] > self.cfg[module]["date"][1]["values"][0])
def test_multiple_keys(self): from datetime import date del self.cfg[module]["date"][1] self.cfg[module]["code"] = [{ "values": [u'#TODO celebrate'], "functions": [lambda data, value: data.startswith(value)]}] res = list(exclude(self.cfg, data)) nt.assert_true(len(res) > 0) for r in res: nt.assert_true(date.today() - r["date"] < self.cfg[module]["date"][0]["values"][0]) nt.assert_false(r["code"].startswith("#TODO celebrate"))
def test_by_default_does_not_exclude(self): res = list(exclude({}, data)) nt.assert_equals(len(res), len(data))