Ejemplo n.º 1
0
    def test_TimestampToDatetime(self):
        # 2017-06-04 11:48:25.008880
        ts = Timestamp(1496576905, 888000000, 0)
        dt = ts.datetime()
        self.assertIsInstance(dt, datetime.datetime)

        self.assertIsNone(dt.tzinfo)

        self.assertEqual(2017, dt.year)
        self.assertEqual(6, dt.month)
        self.assertEqual(4, dt.day)

        self.assertEqual(11, dt.hour)
        self.assertEqual(48, dt.minute)
        self.assertEqual(25, dt.second)
Ejemplo n.º 2
0
  def test_TimestampToDatetime(self):
      # 2017-06-04 11:48:25.008880
      ts = Timestamp(1496576905, 888000000, 0)
      dt = ts.datetime()
      self.assertIsInstance(dt, datetime.datetime)

      self.assertIsNone(dt.tzinfo)

      self.assertEqual(2017, dt.year)
      self.assertEqual(6, dt.month)
      self.assertEqual(4, dt.day)

      self.assertEqual(11, dt.hour)
      self.assertEqual(48, dt.minute)
      self.assertEqual(25, dt.second)
Ejemplo n.º 3
0
    def test_timestamp(self):
        ts_schema = StreamSchema('tuple<int32 a, timestamp ts>').as_tuple(named=True)

        ts1 = Timestamp(133001, 302245576, 56)
        ts2s = Timestamp(23543463, 876265298, 32)
        dt1 = ts2s.datetime()
        ts2 = Timestamp.from_datetime(dt1)

        self.assertEqual(ts2s.seconds, ts2s.seconds);

        topo = Topology()
        s = topo.source([(1,ts1), (2,dt1)])
        s = s.map(lambda x : x, schema=ts_schema)
        as_ts = s.map(lambda x : x.ts.tuple())
        s.print()

        tester = Tester(topo)
        tester.tuple_check(s, ts_check)
        tester.tuple_count(s, 2)
        tester.contents(as_ts, [ts1.tuple(), ts2.tuple()])
        tester.test(self.test_ctxtype, self.test_config)
Ejemplo n.º 4
0
    def test_timestamp(self):
        ts_schema = StreamSchema('tuple<int32 a, timestamp ts>').as_tuple(named=True)

        ts1 = Timestamp(133001, 302245576, 56)
        ts2s = Timestamp(23543463, 876265298, 32)
        dt1 = ts2s.datetime()
        ts2 = Timestamp.from_datetime(dt1)

        self.assertEqual(ts2s.seconds, ts2s.seconds);

        topo = Topology()
        s = topo.source([(1,ts1), (2,dt1)])
        s = s.map(lambda x : x, schema=ts_schema)
        as_ts = s.map(lambda x : x.ts.tuple())
        s.print()

        tester = Tester(topo)
        tester.tuple_check(s, ts_check)
        tester.tuple_count(s, 2)
        tester.contents(as_ts, [ts1.tuple(), ts2.tuple()])
        tester.test(self.test_ctxtype, self.test_config)