예제 #1
0
    def test_string_past(self):
        when = fullformat(self.since - self.delta1)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -60)

        when = fullformat(self.since - self.delta2)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -120)

        when = fullformat(self.since - self.delta3)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -180)
예제 #2
0
    def test_string_past(self):
        when = fullformat(self.since - self.delta1)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -60)

        when = fullformat(self.since - self.delta2)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -120)

        when = fullformat(self.since - self.delta3)
        dep = Departure("from", "to", when, "line", since=self.since)
        self.assertEqual(dep.remaining, -180)
예제 #3
0
 def test_datetime_formats(self):
     f = [(datetime.datetime(2013, 1, 2, 3, 4, 0), "2013-01-02 03:04:00",
           "03:04", "02.01.2013"),
          (datetime.datetime(2013, 5, 2), "2013-05-02 00:00:00", "00:00",
           "02.05.2013"),
          (datetime.datetime(2013, 2, 2, 3, 4, 30), "2013-02-02 03:04:30",
           "03:04", "02.02.2013")]
     for dt, sf, st, sd in f:
         self.assertEqual(fullformat(dt), sf)
         self.assertEqual(dateformat(dt), sd)
         self.assertEqual(timeformat(dt), st)
예제 #4
0
 def test_datetime_formats(self):
     f = [(datetime.datetime(2013, 1, 2, 3, 4, 0),
           "2013-01-02 03:04:00", "03:04", "02.01.2013"),
          (datetime.datetime(2013, 5, 2),
           "2013-05-02 00:00:00", "00:00", "02.05.2013"),
          (datetime.datetime(2013, 2, 2, 3, 4, 30),
           "2013-02-02 03:04:30", "03:04", "02.02.2013")]
     for dt, sf, st, sd in f:
         self.assertEqual(fullformat(dt), sf)
         self.assertEqual(dateformat(dt), sd)
         self.assertEqual(timeformat(dt), st)
예제 #5
0
    def test_compute_remaining(self):
        dates = [
            datetime.datetime(2013, 1, 2, 3, 4, 0),
            datetime.datetime(2013, 1, 2, 3, 4, 1),
            datetime.datetime(2013, 1, 2, 3, 4, 59),
            datetime.datetime(2013, 1, 2, 3, 5, 0),
            datetime.datetime(2013, 1, 2, 3, 5, 1),
            datetime.datetime(2013, 1, 2, 3, 5, 59)
        ]

        target = [[0, 0, 0, 60, 60, 60], [-60, 0, 0, 0, 60, 60],
                  [-60, -60, 0, 0, 0, 60], [-60, -60, -60, 0, 0, 0],
                  [-120, -60, -60, -60, 0, 0], [-120, -120, -60, -60, -60, 0]]
        for start in range(len(dates)):
            for end in range(len(dates)):
                s = dates[start]
                e = dates[end]
                t = target[start][end]
                self.assertEqual(
                    compute_remaining(s, e), target[start][end],
                    "Start: %s; End: %s; target: %d" %
                    (fullformat(s), fullformat(e), t))
예제 #6
0
    def test_compute_remaining(self):
        dates = [datetime.datetime(2013, 1, 2, 3, 4, 0),
                 datetime.datetime(2013, 1, 2, 3, 4, 1),
                 datetime.datetime(2013, 1, 2, 3, 4, 59),
                 datetime.datetime(2013, 1, 2, 3, 5, 0),
                 datetime.datetime(2013, 1, 2, 3, 5, 1),
                 datetime.datetime(2013, 1, 2, 3, 5, 59)]

        target = [[0, 0, 0, 60, 60, 60],
                  [-60, 0, 0, 0, 60, 60],
                  [-60, -60, 0, 0, 0, 60],
                  [-60, -60, -60, 0, 0, 0],
                  [-120, -60, -60, -60, 0, 0],
                  [-120, -120, -60, -60, -60, 0]]
        for start in range(len(dates)):
            for end in range(len(dates)):
                s = dates[start]
                e = dates[end]
                t = target[start][end]
                self.assertEqual(compute_remaining(s, e),
                                 target[start][end],
                                 "Start: %s; End: %s; target: %d" % (
                                     fullformat(s), fullformat(e), t))
예제 #7
0
 def test_string_now(self):
     when = fullformat(self.since)
     dep = Departure("from", "to", when, "line", since=self.since)
     self.assertEqual(dep.remaining, 0)
예제 #8
0
 def test_string_now(self):
     when = fullformat(self.since)
     dep = Departure("from", "to", when, "line", since=self.since)
     self.assertEqual(dep.remaining, 0)