Ejemplo n.º 1
0
    def test_normalized_name(self):
        config = IndexConfig(None, IndexType.SORTED, ["attr"])
        normalized = IndexUtil.validate_and_normalize("map", config)
        self.assertEqual("map_sorted_attr", normalized.name)

        config = IndexConfig("test", IndexType.BITMAP, ["attr"])
        normalized = IndexUtil.validate_and_normalize("map", config)
        self.assertEqual("test", normalized.name)

        config = IndexConfig(None, IndexType.HASH, ["this.attr2.x"])
        normalized = IndexUtil.validate_and_normalize("map2", config)
        self.assertEqual("map2_hash_attr2.x", normalized.name)
Ejemplo n.º 2
0
    def test_duplicate_attributes(self):
        invalid_attributes = [
            ["a", "b", "a"],
            ["a", "b", " a"],
            [" a", "b", "a"],
            ["this.a", "b", "a"],
            ["this.a ", "b", " a"],
            ["this.a", "b", "this.a"],
            ["this.a ", "b", " this.a"],
            [" this.a", "b", "a"],
        ]

        for attributes in invalid_attributes:
            with self.assertRaises(ValueError):
                config = IndexConfig(attributes=attributes)
                IndexUtil.validate_and_normalize("", config)
Ejemplo n.º 3
0
 def test_with_bitmap_indexes(self):
     bio = {
         "unique_key": QueryConstants.THIS_ATTRIBUTE_NAME,
         "unique_key_transformation": UniqueKeyTransformation.RAW
     }
     config = IndexConfig(type=IndexType.BITMAP, attributes=["attr"], bitmap_index_options=bio)
     normalized = IndexUtil.validate_and_normalize("map", config)
     self.assertEqual(bio["unique_key"], normalized.bitmap_index_options.unique_key)
     self.assertEqual(bio["unique_key_transformation"], normalized.bitmap_index_options.unique_key_transformation)
Ejemplo n.º 4
0
 def test_canonicalize_attribute_name(self):
     config = IndexConfig(attributes=["this.x.y.z", "a.b.c"])
     normalized = IndexUtil.validate_and_normalize("", config)
     self.assertEqual("x.y.z", normalized.attributes[0])
     self.assertEqual("a.b.c", normalized.attributes[1])
Ejemplo n.º 5
0
    def test_with_composite_bitmap_indexes(self):
        config = IndexConfig(attributes=["attr1", "attr2"],
                             type=IndexType.BITMAP)

        with self.assertRaises(ValueError):
            IndexUtil.validate_and_normalize("", config)
Ejemplo n.º 6
0
    def test_with_too_many_attributes(self):
        attributes = ["attr_%s" % i for i in range(512)]
        config = IndexConfig(attributes=attributes)

        with self.assertRaises(ValueError):
            IndexUtil.validate_and_normalize("", config)
Ejemplo n.º 7
0
    def test_with_no_attributes(self):
        config = IndexConfig()

        with self.assertRaises(ValueError):
            IndexUtil.validate_and_normalize("", config)