def testAbandonTransaction(self): outfile = self.MakeTestScript() t = igd_time.TimeTZ(tzfile=outfile.name) t.StartTransaction() t.LocalTimeZoneName = 'This should not be written.' t.AbandonTransaction() self.assertEqual(outfile.read().strip(), '')
def testUCLibcIsReallyReallyReallyPickyAboutWhitespace(self): # uClibC will only accept a TZ file with exactly one newline at the end. tzwrite = 'PST8PDT,M3.2.0/2,M11.1.0/2' t = igd_time.TimeTZ() t.LocalTimeZoneName = tzwrite + '\n\n\n\n\n' self.loop.RunOnce(timeout=1) actual = open(self.tzfile).read() self.assertEqual(actual, tzwrite + '\n') os.remove(self.tzfile) t = igd_time.TimeTZ() t.LocalTimeZoneName = tzwrite self.loop.RunOnce(timeout=1) actual = open(self.tzfile).read() self.assertEqual(actual, tzwrite + '\n')
def testUCLibcIsReallyReallyReallyPickyAboutWhitespace(self): # uClibC will only accept a TZ file with exactly one newline at the end. tzwrite = 'PST8PDT,M3.2.0/2,M11.1.0/2' outfile = self.MakeTestScript() t = igd_time.TimeTZ(tzfile=outfile.name) t.StartTransaction() t.LocalTimeZoneName = tzwrite + '\n\n\n\n\n' t.CommitTransaction() self.assertEqual(outfile.read(), tzwrite + '\n') outfile = self.MakeTestScript() t = igd_time.TimeTZ(tzfile=outfile.name) t.StartTransaction() t.LocalTimeZoneName = tzwrite t.CommitTransaction() self.assertEqual(outfile.read(), tzwrite + '\n')
def testSetLocalTimeZoneName(self): outfile = self.MakeTestScript() t = igd_time.TimeTZ(tzfile=outfile.name) expected = 'PST8PDT,M3.2.0/2,M11.1.0/2' t.StartTransaction() t.LocalTimeZoneName = expected t.CommitTransaction() self.assertEqual(outfile.read().strip(), expected)
def testSetLocalTimeZoneName(self): t = igd_time.TimeTZ() t.LocalTimeZoneName = 'UTC0' self.loop.RunOnce(timeout=1) expectedTZ = 'UTC0\n' actualTZ = open(self.tzfile).read() self.assertEqual(actualTZ, expectedTZ) # UTCtzfile copied from /usr/share/zoneinfo/posix/UTC, # and modified with hex editor to remove the portions # not handled by igd_time.py expectedLT = open('testdata/igd_time/UTCtzfile').read() actualLT = open(self.localtimefile).read() self.assertEqual(actualLT, expectedLT)
def testGetLocalTimeZoneName(self): t = igd_time.TimeTZ(tzfile='testdata/igd_time/TZ') self.assertEqual(t.LocalTimeZoneName, 'POSIX')
def testCurrentLocalTime(self): t = igd_time.TimeTZ() self.assertEqual(t.CurrentLocalTime, '2009-02-13T23:31:30.987654Z')
def testValidateExports(self): t = igd_time.TimeTZ() t.ValidateExports()
def testGetLocalTimeZoneName(self): igd_time.TZFILE = 'testdata/igd_time/TZ' t = igd_time.TimeTZ() self.assertEqual(t.LocalTimeZoneName, 'POSIX')
def testValidateExports(self): t = igd_time.TimeTZ() tr.handle.ValidateExports(t)
def testTimeSyncedStatus(self): t = igd_time.TimeTZ() igd_time.TIMESYNCEDFILE = '/nonexistant' self.assertEqual(t.Status, 'Unsynchronized') igd_time.TIMESYNCEDFILE = 'testdata/igd_time/time.synced' self.assertEqual(t.Status, 'Synchronized')
def testIncorrectPosixTzNotThatAcsWouldEverSendOneNopeNopeNope(self): t = igd_time.TimeTZ() t.LocalTimeZoneName = 'This is not a timezone' self.loop.RunOnce(timeout=1) self.assertFalse(os.path.exists(self.localtimefile)) self.assertFalse(os.path.exists(self.tzfile))