def setUp(self): self.overdue = Task(description = "t1", due_date = yesterday()) self.very_soon = Task(description = 't2', due_date = today()) self.soon = Task(description = 't3', due_date = today() + datetime.timedelta(10)) self.later = Task(description = 't3', due_date = today() + datetime.timedelta(30)) self.high = Task(description = "high", priority = 2) self.medium = Task(description = 'medium', priority = 1) self.low = Task(description = 'low', priority = 0)
def test_RepeatingWithStartAndDueDateGetsBoth(self): t = self.a_repeating_task() t.start_date = y = yesterday() t.due_date = d = today() t = self.mark_done_and_get_repeated(t) self.assertEqual(7, (t.due_date - d).days) self.assertEqual(1, (t.due_date - t.start_date).days)
def setUp(self): YataTestCase.setUp(self) t = self.new_task(description="something to do now", start_date=today()) t.save() # Something in the future. Not just tomorrow, in case the test is run around midnight... t = self.new_task(description="something to do in two days", start_date=tomorrow(tomorrow())) t.save()
def test_post(self): desc = "The created task" prio = 0 sdate = today() ddate = tomorrow() repeat_nb = 1 repeat_type = "W" note = "the note..." response = self.client.post( "/yata/task/new/", { "description": desc, "priority": prio, "start_date": sdate, "due_date": ddate, "repeat_nb": repeat_nb, "repeat_type": repeat_type, "note": note, }, ) self.assertEqual(response.status_code, 302) # Redirect all = Task.objects.all() self.assertEqual(1, all.count()) t = all[0] self.assertEqual(desc, t.description) self.assertEqual(prio, t.priority) self.assertEqual(sdate, t.start_date) self.assertEqual(ddate, t.due_date) self.assertEqual(repeat_nb, t.repeat_nb) self.assertEqual(repeat_type, t.repeat_type) self.assertEqual(note, t.note)
def test_post_only_required_fields(self): desc = "The created task" prio = 0 sdate = today() ddate = tomorrow() repeat_nb = 1 repeat_type = "W" note = "the note..." response = self.client.post("/yata/task/new/", {"description": desc, "priority": prio}) all = Task.objects.all() self.assertEqual(1, all.count()) t = all[0] self.assertEqual(desc, t.description) self.assertEqual(0, t.priority) self.assertEqual(None, t.start_date) self.assertEqual(None, t.due_date) self.assertEqual(None, t.repeat_nb) self.assertEqual(None, t.repeat_type) self.assertEqual("", t.note)