Пример #1
0
    def testTuuid(self):
        """
        Test TUUID generation
        """
        console.terse("{0}\n".format(self.testTuuid.__doc__))

        tuid = timing.tuuid()
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)

        tuid = timing.tuuid(9)
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)
        self.assertEqual(stamp[:16], '0000000000895440')

        tuid = timing.tuuid(stamp=9, prefix="m")
        self.assertEqual(len(tuid), 26)
        prefix, stamp, randomized = tuid.split('_')
        self.assertEqual(prefix, 'm')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)
        self.assertEqual(stamp[:16], '0000000000895440')
Пример #2
0
    def testEventize(self):
        """
        Test eventize function
        """
        console.terse("{0}\n".format(self.testEventize.__doc__))
        console.reinit(verbosity=console.Wordage.profuse)


        stamp = iso8601()  # "YYYY-MM-DDTHH:MM:SS.mmmmmm"
        tuid = tuuid()  # "0000014ddf1f2f9c_5e36738"
        time.sleep(0.1)

        event = eventing.eventize('hello')
        self.assertEqual(event['tag'], 'hello')
        self.assertFalse('data' in event)
        self.assertFalse('stamp' in event)
        self.assertFalse('uid' in event)
        self.assertFalse('route' in event)

        event = eventing.eventize(tag=eventing.tagify(head='exchange', tail='started'),
                                  stamp=True,
                                  uid=True,
                                  data=True,
                                  route=odict([("src", (None, None, None)),
                                             ("dst", (None, None, None))]))


        self.assertEqual(event['tag'], 'exchange.started')
        self.assertTrue('data' in event)
        self.assertIsInstance(event["data"], odict)
        self.assertEqual(event['data'], odict([]))
        self.assertTrue('stamp' in event)
        self.assertIsInstance(event["stamp"], str)
        self.assertGreater(event['stamp'], stamp)
        self.assertTrue('uid' in event)
        self.assertIsInstance(event["uid"], str)
        self.assertGreater(event['uid'], tuid)
        self.assertTrue('route' in event)
        self.assertEqual(event['route'] ,odict([("src", (None, None, None)),
                                         ("dst", (None, None, None))]))

        event = eventing.eventize(tag=eventing.tagify(head='exchange', tail='started'),
                                  stamp=stamp,
                                  uid=tuid,
                                  data=odict(name="John"),
                                  route=odict([("src", (None, None, None)),
                                             ("dst", (None, None, None))]))


        self.assertEqual(event['tag'], 'exchange.started')
        self.assertEqual(event['data'], odict(name="John"))
        self.assertEqual(event['stamp'], stamp)
        self.assertEqual(event['uid'], tuid)
        self.assertEqual(event['route'] ,odict([("src", (None, None, None)),
                                         ("dst", (None, None, None))]))



        console.reinit(verbosity=console.Wordage.concise)
Пример #3
0
    def testTuuid(self):
        """
        Test TUUID generation
        """
        console.terse("{0}\n".format(self.testTuuid.__doc__))

        tuid = timing.tuuid()
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)

        tuid =  timing.tuuid(9)
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)
        self.assertEqual(stamp[:16], '0000000000895440' )
Пример #4
0
    def testTuuid(self):
        """
        Test TUUID generation
        """
        console.terse("{0}\n".format(self.testTuuid.__doc__))
        console.reinit(verbosity=console.Wordage.profuse)

        tuid = timing.tuuid()
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)

        tuid =  timing.tuuid(9)
        self.assertEqual(len(tuid), 24)
        stamp, sep, randomized = tuid.rpartition('_')
        self.assertEqual(sep, '_')
        self.assertEqual(len(stamp), 16)
        self.assertEqual(len(randomized), 7)
        self.assertEqual(stamp[:16], '0000000000895440' )

        console.reinit(verbosity=console.Wordage.concise)