예제 #1
0
파일: test_models.py 프로젝트: nodet/yata
 def runTest(self):
     aDate = datetime.date(2010,01,19)
     self.assertEqual( 0, due_date_cmp(aDate, aDate))
     self.assertEqual(-1, due_date_cmp(aDate, tomorrow(aDate)))
     self.assertEqual( 1, due_date_cmp(tomorrow(aDate), aDate))
     self.assertEqual( sys.maxint, due_date_cmp(None, aDate))
     self.assertEqual(-sys.maxint-1, due_date_cmp(aDate, None))
     self.assertEqual( 0, due_date_cmp(None, None))
예제 #2
0
파일: test_views.py 프로젝트: nodet/yata
 def setUp(self):
     YataTestCase.setUp(self)
     t = self.new_task(description="Not future")
     t.save()
     t = self.new_task(description="Future", start_date=tomorrow(tomorrow()))
     t.save()
     # Make sure we call the view first so that it saves a session
     self.client.get("/yata/")
예제 #3
0
파일: test_models.py 프로젝트: nodet/yata
 def runTest(self):
     aDate = datetime.date(2011,01,19)
     self.assertEqual('Today', relativeDueDate(aDate, aDate))
     self.assertEqual('Tomorrow', relativeDueDate(aDate, tomorrow(aDate)))
     self.assertEqual('Yesterday', relativeDueDate(aDate, yesterday(aDate)))
     self.assertEqual('in 2 days', relativeDueDate(aDate, tomorrow(tomorrow(aDate))))
     self.assertEqual('in 6 days', relativeDueDate(aDate, aDate + datetime.timedelta(6)))
     self.assertEqual('in 1 week', relativeDueDate(aDate, aDate + datetime.timedelta(7)))
     self.assertEqual('Jan 27', relativeDueDate(aDate, aDate + datetime.timedelta(8)))
     self.assertEqual('Jan 10', relativeDueDate(aDate, aDate - datetime.timedelta(9)))
     self.assertEqual('2010-12-31', relativeDueDate(aDate, aDate - datetime.timedelta(19)))
예제 #4
0
파일: test_views.py 프로젝트: nodet/yata
 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()
예제 #5
0
파일: test_views.py 프로젝트: nodet/yata
 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)
예제 #6
0
파일: test_models.py 프로젝트: nodet/yata
 def runTest(self):
     aDate = datetime.date(2010,01,19)
     oneDayAfter = tomorrow(aDate)
     oneDayBefore = yesterday(aDate)
     t = self.new_task(description = "something", due_date = aDate)
     self.assertEqual('something, due 2010-01-19', t.__unicode__()) 
     t.save();
     self.assertEqual(1, Task.objects.filter(due_date=aDate).count())
     self.assertEqual(0, Task.objects.filter(due_date__gte=oneDayAfter).count())
     self.assertEqual(0, Task.objects.filter(due_date__lte=oneDayBefore).count())
     self.assertEqual(1, Task.objects.filter(due_date__lte=oneDayAfter).count())
     self.assertEqual(1, Task.objects.filter(due_date__gte=oneDayBefore).count())
예제 #7
0
파일: test_views.py 프로젝트: nodet/yata
 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)
예제 #8
0
파일: test_views.py 프로젝트: nodet/yata
    def test_edit_view_saves_the_changes(self):
        c = self.client
        response = c.get("/yata/")
        self.assertTrue("/yata/task/1/edit/" in response.content)
        response = c.get("/yata/task/1/edit/")
        self.assertEqual(200, response.status_code)

        ndesc = "new description"
        prio = 0
        sdate = yesterday()
        ddate = tomorrow()
        nb = 2
        type = "W"
        done = True
        note = "the note..."
        response = c.post(
            "/yata/task/1/edit/",
            {
                "description": ndesc,
                "priority": prio,
                "start_date": sdate,
                "due_date": ddate,
                "repeat_nb": nb,
                "repeat_type": type,
                "done": done,
                "note": note,
            },
        )
        all = Task.objects.all()
        self.assertEqual(1, all.count())
        t = all[0]
        self.assertEqual(ndesc, t.description)
        self.assertEqual(prio, t.priority)
        self.assertEqual(sdate, t.start_date)
        self.assertEqual(ddate, t.due_date)
        self.assertEqual(nb, t.repeat_nb)
        self.assertEqual(type, t.repeat_type)
        self.assertEqual(note, t.note)
예제 #9
0
파일: test_models.py 프로젝트: nodet/yata
 def setUp(self):
     YataTestCase.setUp(self)
     d = tomorrow()
     self.t1 = self.new_task(description='T1')
     self.t2 = self.new_task(description='T2', due_date=d)
예제 #10
0
파일: test_models.py 프로젝트: nodet/yata
 def test_RepeatingWithStartDateGetsAStartDate(self):
     t = self.a_repeating_task()
     t.start_date = d = tomorrow()
     t = self.mark_done_and_get_repeated(t)
     self.assertEqual(7, (t.start_date - datetime.date.today()).days)
     self.assertTrue(t.due_date == None)