Пример #1
0
    def test_getoffset(self):
        data = (
            ("Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS", 0),
            ("Rule\tEgypt\t1945\tonly\t-\tApr\t16\t0:00\t1:00\tS", 60 * 60),
            ("Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST", 20 * 60),
        )

        for ruletext, offset in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(ruleitem.getOffset(), offset)
Пример #2
0
    def test_datetimeforyear(self):
        data = (
            ("Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS", 2006, DateTime(2006, 10, 1, 0, 0, 0), ""),
            ("Rule\tAlgeria\t1916\t1919\t-\tOct\tSun>=1\t23:00s\t0\t-", 1916, DateTime(1916, 10, 1, 23, 0, 0), "s"),
            ("Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST", 1937, DateTime(1937, 9, 1, 0, 0, 0), ""),
        )

        for ruletext, year, dt, special in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(ruleitem.datetimeForYear(year), (dt, special))
Пример #3
0
    def test_getoffset(self):
        data = (
            ("Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS", 0),
            ("Rule\tEgypt\t1945\tonly\t-\tApr\t16\t0:00\t1:00\tS", 60 * 60),
            ("Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST", 20 * 60),
        )

        for ruletext, offset in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(ruleitem.getOffset(), offset)
Пример #4
0
    def test_parse(self):
        data = (
            "Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS",
            "Rule\tAlgeria\t1916\t1919\t-\tOct\tSun>=1\t23:00s\t0\t-",
            "Rule\tEgypt\t1945\tonly\t-\tApr\t16\t0:00\t1:00\tS",
            "Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST",
        )

        for ruletext in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(str(ruleitem), ruletext)
Пример #5
0
    def test_parse(self):
        data = (
            "Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS",
            "Rule\tAlgeria\t1916\t1919\t-\tOct\tSun>=1\t23:00s\t0\t-",
            "Rule\tEgypt\t1945\tonly\t-\tApr\t16\t0:00\t1:00\tS",
            "Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST",
        )

        for ruletext in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(str(ruleitem), ruletext)
Пример #6
0
    def test_datetimeforyear(self):
        data = (
            ("Rule\tGuat\t2006\tonly\t-\tOct\t1\t0:00\t0\tS", 2006,
             DateTime(2006, 10, 1, 0, 0, 0), ""),
            ("Rule\tAlgeria\t1916\t1919\t-\tOct\tSun>=1\t23:00s\t0\t-", 1916,
             DateTime(1916, 10, 1, 23, 0, 0), "s"),
            ("Rule\tGhana\t1936\t1942\t-\tSep\t1\t0:00\t0:20\tGHST", 1937,
             DateTime(1937, 9, 1, 0, 0, 0), ""),
        )

        for ruletext, year, dt, special in data:
            ruleitem = Rule()
            ruleitem.parse(ruletext)

            self.assertEqual(ruleitem.datetimeForYear(year), (dt, special))