Esempio n. 1
0
 def test_qualified_name(self):
     key1 = Key.build_from_qualified_name('Kettle.Black')
     self.assertEqual(key1, Key.make_key('Black', 'Kettle'))
     key2 = Key.build_from_qualified_name('Kettle.Black.Osmus')
     self.assertEqual(key2, Key.make_key('Black.Osmus', 'Kettle'))
     key3 = Key.make_key()
     self.assertEqual(str(key3), 'default.?')
Esempio n. 2
0
    def test_build(self):
        key1 = Key.make_key()
        self.assertEqual(key1, ('default', None))

        key2 = Key.make_key(name='Sand')
        self.assertEqual(key2, ('default', 'Sand'))

        key3 = Key.make_key('Sand')
        self.assertEqual(key3, ('default', 'Sand'))

        key4 = Key.make_key('Sand', 'Snakes')
        self.assertEqual(key4, ('Snakes', 'Sand'))

        key5 = Key.make_key('Sand', bucket='Snakes')
        self.assertEqual(key5, ('Snakes', 'Sand'))

        key6 = Key.make_key(bucket='Snakes', name='Sand')
        self.assertEqual(key6, ('Snakes', 'Sand'))
Esempio n. 3
0
 def test_hashable(self):
     key = Key.make_key(bucket='Snakes', name='Sand')
     self.assertIsInstance(hash(key), int)
Esempio n. 4
0
 def test_getattr(self):
     key = Key.make_key(bucket='Snakes', name='Sand')
     self.assertEqual(key.bucket, 'Snakes')
     self.assertEqual(key.name, 'Sand')
     self.assertEqual(key.qualified_name, 'Snakes.Sand')