Beispiel #1
0
    def testReadTimestamp(self):
        ts_filename = os.path.join(self.workdir, 'tsr')
        ts_file = open(ts_filename, 'w')
        ts_file.write('1970-01-01T00:00:01Z\n')
        ts_file.close()

        ts = timestamps.ReadTimestamp(ts_filename)
        self.assertEqual(time.gmtime(1), ts)
Beispiel #2
0
    def testReadTimestamp(self):
        # TZ=UTC date -d @1306428781
        # Thu May 26 16:53:01 UTC 2011
        ts_filename = os.path.join(self.workdir, 'tsr')
        ts_file = open(ts_filename, 'w')
        ts_file.write('2011-05-26T16:53:01Z\n')
        ts_file.close()

        ts = timestamps.ReadTimestamp(ts_filename)
        self.assertEqual(time.gmtime(1306428781), ts)
Beispiel #3
0
  def testWriteTimestamp(self):
    ts_filename = os.path.join(self.workdir, 'tsw')

    good_ts = time.gmtime(1)
    timestamps.WriteTimestamp(good_ts, ts_filename)

    self.assertEqual(good_ts, timestamps.ReadTimestamp(ts_filename))

    ts_file = open(ts_filename, 'r')
    self.assertEqual('1970-01-01T00:00:01Z\n', ts_file.read())
Beispiel #4
0
    def testReadTimestampInFuture(self):
        ts_filename = os.path.join(self.workdir, 'tsr')
        ts_file = open(ts_filename, 'w')
        ts_file.write('2011-05-26T16:02:00Z')
        ts_file.close()

        now = time.gmtime(1)
        self.mox.StubOutWithMock(time, 'gmtime')
        time.gmtime().AndReturn(now)
        self.mox.ReplayAll()

        ts = timestamps.ReadTimestamp(ts_filename)
        self.assertEqual(now, ts)