コード例 #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))
コード例 #2
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")))
コード例 #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))
コード例 #6
0
    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))
        )
コード例 #7
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",
            PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
            PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
        )
コード例 #8
0
    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))
        )
コード例 #9
0
    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
ファイル: test_timezones.py プロジェクト: nunb/calendarserver
    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))
        )
コード例 #14
0
    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
        )
コード例 #15
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",
            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")))
コード例 #17
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))
コード例 #18
0
 def setUp(self):
     TimezoneCache.clear()
     TimezoneCache.create()
コード例 #19
0
 def tearDown(self):
     TimezoneCache.clear()
     TimezoneCache.create()
コード例 #20
0
 def setUp(self):
     super(TimezonePackageTest, self).setUp()
     TimezoneCache.clear()
     TimezoneCache.create()
コード例 #21
0
 def setUp(self):
     super(TimezonePackageTest, self).setUp()
     TimezoneCache.clear()
     TimezoneCache.create()
コード例 #22
0
 def tearDown(self):
     TimezoneCache.clear()
     TimezoneCache.create()