def test_valid_line(self): fixture = [u"Name1, 20.10, 04/13/2010, ", u"Name2, 21.01, 04/14/2010, 2w",] result = list(budget.schedule_parser_gen(fixture)) expect = [budget.ScheduleItem(u"Name1", 20.10, datetime(2010,4,13), u""), budget.ScheduleItem(u"Name2", 21.01, datetime(2010,4,14), u"2w"),] result = map(lambda x,y: cmp(x,y) == 0, result, expect) self.assertTrue(all(result), result)
def test_iter1(self): fixture = budget.ScheduleItem(u"Name", 20.10, datetime(2010, 4, 13), u"2w") expect = [u"Name", 20.10, datetime(2010, 4, 13), u"2w"] result = list(fixture) self.assertEqual(result)
def test_unicode(self): fixture = budget.ScheduleItem(u"Name", 20.10, datetime(2010, 4, 13), None) expect = u"Name, 20.1, 04/13/2010, " result = unicode(fixture) self.assertEqual(expect, result)
def test_until_withoutrrule(self): fixture = budget.ScheduleItem(u"Name", 20.10, datetime(2010, 3, 5), u"") expect = [(u'Name', 20.10, datetime(2010, 3, 5)),] result = list(fixture.until(datetime(2010, 3, 19))) self.assertEqual(expect, result)
def test_comment(self): fixture = [u"# This is a comment", u" # This is one as well", u"", u" ", u"Name1, 20.10, 04/13/2010, # Comment"] result = list(budget.schedule_parser_gen(fixture)) expect = [budget.ScheduleItem(u"Name1", 20.10, datetime(2010,4,13), u"")] self.assertEqual(expect, result)