Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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))