예제 #1
0
    def test_drop_indexes(self):
        """
        Tests updating indexes on an existing collection with different indexes correctly changes them.
        """

        # Setup
        old_key = ['compound_1', 'compound_2']

        type_def = TypeDefinition('rpm', 'RPM', 'RPM Packages', old_key, None,
                                  [])
        types_db._update_unit_key(type_def)

        # Test
        new_key = ['new_1']
        type_def.unit_key = new_key

        types_db._drop_indexes(type_def)
        types_db._update_unit_key(type_def)

        # Verify
        collection_name = types_db.unit_collection_name(type_def.id)
        collection = pulp_db.get_collection(collection_name)

        index_dict = collection.index_information()

        self.assertEqual(2, len(index_dict))  # default (_id) + new one
예제 #2
0
    def test_create_or_update_existing_type_collection(self):
        """
        Tests calling create_or_update with a change to an existing type
        collection is successful.
        """

        # Setup
        type_def = TypeDefinition('rpm', 'RPM', 'RPM Packages', ['name'],
                                  ['name'], [])
        types_db._create_or_update_type(type_def)

        # Test
        type_def.display_name = 'new-name'
        type_def.description = 'new-description'
        type_def.unit_key = 'new-key'
        type_def.search_indexes = None
        types_db._create_or_update_type(type_def)

        # Verify

        #   Present in types collection
        all_types = list(ContentType.get_collection().find())
        self.assertEqual(1, len(all_types))

        found = all_types[0]
        self.assertEqual(type_def.id, found['id'])
        self.assertEqual(type_def.display_name, found['display_name'])
        self.assertEqual(type_def.description, found['description'])
        self.assertEqual(type_def.unit_key, found['unit_key'])
        self.assertEqual(type_def.search_indexes, found['search_indexes'])

        #   Type collection exists
        collection_name = types_db.unit_collection_name(type_def.id)
        self.assertTrue(
            collection_name in pulp_db.database().collection_names())
예제 #3
0
    def test_create_or_update_existing_type_collection(self):
        """
        Tests calling create_or_update with a change to an existing type
        collection is successful.
        """

        # Setup
        type_def = TypeDefinition('rpm', 'RPM', 'RPM Packages', ['name'], ['name'], [])
        types_db._create_or_update_type(type_def)

        # Test
        type_def.display_name = 'new-name'
        type_def.description = 'new-description'
        type_def.unit_key = 'new-key'
        type_def.search_indexes = None
        types_db._create_or_update_type(type_def)

        # Verify

        #   Present in types collection
        all_types = list(ContentType.get_collection().find())
        self.assertEqual(1, len(all_types))

        found = all_types[0]
        self.assertEqual(type_def.id, found['id'])
        self.assertEqual(type_def.display_name, found['display_name'])
        self.assertEqual(type_def.description, found['description'])
        self.assertEqual(type_def.unit_key, found['unit_key'])
        self.assertEqual(type_def.search_indexes, found['search_indexes'])

        #   Type collection exists
        collection_name = types_db.unit_collection_name(type_def.id)
        self.assertTrue(collection_name in pulp_db.get_database().collection_names())
예제 #4
0
    def test_drop_indexes(self):
        """
        Tests updating indexes on an existing collection with different indexes correctly changes them.
        """

        # Setup
        old_key = ['compound_1', 'compound_2']

        type_def = TypeDefinition('rpm', 'RPM', 'RPM Packages', old_key, None, [])
        types_db._update_unit_key(type_def)

        # Test
        new_key = ['new_1']
        type_def.unit_key = new_key

        types_db._drop_indexes(type_def)
        types_db._update_unit_key(type_def)

        # Verify
        collection_name = types_db.unit_collection_name(type_def.id)
        collection = pulp_db.get_collection(collection_name)

        index_dict = collection.index_information()

        self.assertEqual(2, len(index_dict)) # default (_id) + new one
예제 #5
0
    def test_create_or_update_existing_type_collection(self):
        """
        Tests calling create_or_update with a change to an existing type
        collection is successful.
        """

        # Setup
        type_def = TypeDefinition("rpm", "RPM", "RPM Packages", ["name"], ["name"], [])
        types_db._create_or_update_type(type_def)

        # Test
        type_def.display_name = "new-name"
        type_def.description = "new-description"
        type_def.unit_key = "new-key"
        type_def.search_indexes = None
        types_db._create_or_update_type(type_def)

        # Verify

        #   Present in types collection
        all_types = list(ContentType.get_collection().find())
        self.assertEqual(1, len(all_types))

        found = all_types[0]
        self.assertEqual(type_def.id, found["id"])
        self.assertEqual(type_def.display_name, found["display_name"])
        self.assertEqual(type_def.description, found["description"])
        self.assertEqual(type_def.unit_key, found["unit_key"])
        self.assertEqual(type_def.search_indexes, found["search_indexes"])

        #   Type collection exists
        collection_name = types_db.unit_collection_name(type_def.id)
        self.assertTrue(collection_name in pulp_db.get_database().collection_names())