예제 #1
0
    def test_copyPackage(self):
        """
        Test that copying of the tz package works.
        """

        self.patch(config, "UsePackageTimezones", True)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertFalse(
            os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertFalse(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "America",
                             "New_York.ics")))

        pkg_tz = readTZ("America/New_York")

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertTrue(
            os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "America",
                             "New_York.ics")))

        copy_tz = readTZ("America/New_York")

        self.assertEqual(str(pkg_tz), str(copy_tz))
    def test_copyPackage_Concurrency(self):
        """
        Test that concurrent copying of the tz package works.
        """

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()

        ex = [None, None]
        def _try(n):
            try:
                TimezoneCache.create()
            except:
                f = Failure()
                ex[n] = str(f)

        t1 = threading.Thread(target=_try, args=(0,))
        t2 = threading.Thread(target=_try, args=(1,))
        t1.start()
        t2.start()
        t1.join()
        t2.join()

        self.assertTrue(ex[0] is None, msg=ex[0])
        self.assertTrue(ex[1] is None, msg=ex[1])

        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
예제 #3
0
    def test_copyPackage_Concurrency(self):
        """
        Test that concurrent copying of the tz package works.
        """

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()

        ex = [None, None]

        def _try(n):
            try:
                TimezoneCache.create()
            except:
                f = Failure()
                ex[n] = str(f)

        t1 = threading.Thread(target=_try, args=(0, ))
        t2 = threading.Thread(target=_try, args=(1, ))
        t1.start()
        t2.start()
        t1.join()
        t2.join()

        self.assertTrue(ex[0] is None, msg=ex[0])
        self.assertTrue(ex[1] is None, msg=ex[1])

        self.assertTrue(
            os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "America",
                             "New_York.ics")))
예제 #4
0
    def test_truncatedApr(self):
        """
        Custom VTZ with truncated standard time - 2006. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest("TruncatedApr01.ics",
                    DateTime(2007, 04, 01, 16, 0, 0, Timezone.UTCTimezone),
                    DateTime(2007, 04, 01, 17, 0, 0, Timezone.UTCTimezone))
예제 #5
0
    def test_truncatedDec(self):
        """
        Custom VTZ valid from 2007. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest("TruncatedDec10.ics",
                    DateTime(2007, 12, 10, 17, 0, 0, Timezone.UTCTimezone),
                    DateTime(2007, 12, 10, 18, 0, 0, Timezone.UTCTimezone))
    def test_truncatedDec(self):
        """
        Properties in components
        """
        TimezoneCache.create("")
        TimezoneCache.clear()

        self.doTest(
            "TruncatedDec10.ics",
            PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
        )
    def test_truncatedApr(self):
        """
        Custom VTZ with truncated standard time - 2006. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest(
            "TruncatedApr01.ics",
            PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
        )
    def test_truncatedApr(self):
        """
        Properties in components
        """
        
        TimezoneCache.create("")
        TimezoneCache.clear()

        self.doTest(
            "TruncatedApr01.ics",
            PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
        )
    def test_truncatedDec(self):
        """
        Custom VTZ valid from 2007. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest(
            "TruncatedDec10.ics",
            PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
        )
예제 #10
0
    def test_truncatedDecThenApr(self):
        """
        Custom VTZ valid from 2007 loaded first. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest("TruncatedDec10.ics",
                    DateTime(2007, 12, 10, 17, 0, 0, Timezone.UTCTimezone),
                    DateTime(2007, 12, 10, 18, 0, 0, Timezone.UTCTimezone))
        self.doTest("TruncatedApr01.ics",
                    DateTime(2007, 04, 01, 16, 0, 0, Timezone.UTCTimezone),
                    DateTime(2007, 04, 01, 17, 0, 0, Timezone.UTCTimezone))
예제 #11
0
    def test_copyPackage_missingVersion(self):
        """
        Test that tz data is updated if the version is missing.
        """

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
        os.remove(os.path.join(config.DataRoot, "zoneinfo", "version.txt"))
        self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))

        TimezoneCache.create()
        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
예제 #12
0
    def test_truncatedAprThenDecFail(self):
        """
        Custom VTZ with truncated standard time - 2006 loaded first. Daylight 2007 OK, standard 2007 wrong.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest(
            "TruncatedApr01.ics",
            DateTime(2007, 04, 01, 16, 0, 0, Timezone.UTCTimezone),
            DateTime(2007, 04, 01, 17, 0, 0, Timezone.UTCTimezone),
        )
        self.doTest("TruncatedDec10.ics",
                    DateTime(2007, 12, 10, 17, 0, 0, Timezone.UTCTimezone),
                    DateTime(2007, 12, 10, 18, 0, 0, Timezone.UTCTimezone),
                    testEqual=False)
예제 #13
0
    def test_truncatedDecThenApr(self):
        """
        Custom VTZ valid from 2007 loaded first. Daylight 2007 OK.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest(
            "TruncatedDec10.ics",
            DateTime(2007, 12, 10, 17, 0, 0, Timezone(utc=True)),
            DateTime(2007, 12, 10, 18, 0, 0, Timezone(utc=True))
        )
        self.doTest(
            "TruncatedApr01.ics",
            DateTime(2007, 04, 01, 16, 0, 0, Timezone(utc=True)),
            DateTime(2007, 04, 01, 17, 0, 0, Timezone(utc=True))
        )
    def test_truncatedAprThenDecFail(self):
        """
        Properties in components
        """

        TimezoneCache.create("")
        TimezoneCache.clear()

        self.doTest(
            "TruncatedApr01.ics",
            PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
        )
        self.doTest(
            "TruncatedDec10.ics",
            PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
            testEqual=False
        )
    def test_truncatedAprThenDecFail(self):
        """
        Custom VTZ with truncated standard time - 2006 loaded first. Daylight 2007 OK, standard 2007 wrong.
        """

        TimezoneCache.create(empty=True)
        TimezoneCache.clear()

        self.doTest(
            "TruncatedApr01.ics",
            PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
        )
        self.doTest(
            "TruncatedDec10.ics",
            PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
            testEqual=False
        )
예제 #16
0
    def test_copyPackage_missingVersion(self):
        """
        Test that tz data is updated if the version is missing.
        """

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertTrue(
            os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
        os.remove(os.path.join(config.DataRoot, "zoneinfo", "version.txt"))
        self.assertFalse(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "version.txt")))

        TimezoneCache.create()
        self.assertTrue(
            os.path.exists(
                os.path.join(config.DataRoot, "zoneinfo", "version.txt")))
    def test_copyPackage(self):
        """
        Test that copying of the tz package works.
        """

        self.patch(config, "UsePackageTimezones", True)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))

        pkg_tz = readTZ("America/New_York")

        self.patch(config, "UsePackageTimezones", False)
        TimezoneCache.clear()
        TimezoneCache.create()

        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
        self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))

        copy_tz = readTZ("America/New_York")

        self.assertEqual(str(pkg_tz), str(copy_tz))
 def setUp(self):
     TimezoneCache.clear()
     TimezoneCache.create()
예제 #19
0
 def tearDown(self):
     TimezoneCache.clear()
     TimezoneCache.create()
 def setUp(self):
     super(TimezonePackageTest, self).setUp()
     TimezoneCache.clear()
     TimezoneCache.create()
예제 #21
0
 def setUp(self):
     super(TimezonePackageTest, self).setUp()
     TimezoneCache.clear()
     TimezoneCache.create()
 def tearDown(self):
     TimezoneCache.clear()
     TimezoneCache.create()