def test_str_9_30(self):
     line = "2019-11-25T12:21:58-0500 cloud 570"
     history = History(line)
     h_string = str(history)
     expected = "11/25/2019: 09:30"
     actual = str(history)
     self.assertEqual(expected, actual)
 def test_str_hour_plus(self):
     line = "2019-11-25T12:21:58-0500 cloud 3603"
     history = History(line)
     h_string = str(history)
     expected = "11/25/2019: 01:00:03"
     actual = str(history)
     self.assertEqual(expected, actual)
Esempio n. 3
0
    def __init__(self, filename=DEFAULT_FILENAME):
        self.filename = filename
        self.levels = {}
        self.earliest_date = None
        self.latest_date = None
        with open(self.filename, "rt") as f:
            for line in f:
                history = History(line)
                if self.earliest_date is None or history.date < self.earliest_date:
                    self.earliest_date = history.date
                if self.latest_date is None or history.date > self.latest_date:
                    self.latest_date = history.date
                level = history.level
                record_list = self.get_record_list(level)
                record_list.add(history)

        self.count = 0
        for level in self.levels:
            record_list = self.get_record_list(level)
            record_list.sort()
            self.count += record_list.get_count()
Esempio n. 4
0
 def testNormal(self):
     line = "2019-11-30T20:05:00-0500 Normal 234"
     h = History(line)
     expected = "03:54 (11/30/2019)"
     actual = h.timedate()
     self.assertEqual(expected, actual)
Esempio n. 5
0
 def test_hour_plus(self):
     seconds = 3603
     expected = "01:00:03"
     actual = History.format_time(seconds)
     self.assertEqual(expected, actual)
Esempio n. 6
0
 def test_all_day(self):
     seconds = 60 * 60 * 24 - 1
     expected = "23:59:59"
     actual = History.format_time(seconds)
     self.assertEqual(expected, actual)
Esempio n. 7
0
 def test_two_seconds(self):
     seconds = 2
     expected = "00:02"
     actual = History.format_time(seconds)
     self.assertEqual(expected, actual)
Esempio n. 8
0
 def test_one_minute(self):
     seconds = 60
     expected = "01:00"
     actual = History.format_time(seconds)
     self.assertEqual(expected, actual)
Esempio n. 9
0
 def test_empty(self):
     seconds = 0
     expected = "00:00"
     actual = History.format_time(seconds)
     self.assertEqual(expected, actual)