Beispiel #1
0
    def test_remove_index_with_untracked_table(self):
        """Testing DatabaseState.remove_index with untracked table"""
        database_state = DatabaseState(db_name='default', scan=False)

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The table is not being tracked in the database state.')

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index')
Beispiel #2
0
    def test_remove_index_with_invalid_index_name(self):
        """Testing DatabaseState.remove_index with invalid index name"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The index could not be found.')

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index',
                                        unique=True)
    def test_remove_index_with_untracked_table(self):
        """Testing DatabaseState.remove_index with untracked table"""
        database_state = DatabaseState(db_name='default', scan=False)

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The table is not being tracked in the database state.'
        )

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index',
                                        unique=True)
    def test_remove_index_with_invalid_index_name(self):
        """Testing DatabaseState.remove_index with invalid index name"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The index could not be found.'
        )

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index',
                                        unique=True)
Beispiel #5
0
    def test_remove_index(self):
        """Testing DatabaseState.remove_index"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index',
                                 columns=['col1', 'col2'])

        database_state.remove_index(table_name='my_test_table',
                                    index_name='my_index')

        self.assertEqual(database_state._tables['my_test_table'], {
            'indexes': {},
            'unique_indexes': {},
        })
    def test_remove_index(self):
        """Testing DatabaseState.remove_index"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index',
                                 columns=['col1', 'col2'],
                                 unique=True)

        database_state.remove_index(table_name='my_test_table',
                                    index_name='my_index',
                                    unique=True)

        self.assertEqual(database_state._tables['my_test_table']['indexes'],
                         {})
    def test_remove_index_with_invalid_index_type(self):
        """Testing DatabaseState.remove_index with invalid index type"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index',
                                 columns=['col1', 'col2'],
                                 unique=True)

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The specified index type (unique=False) does not match the '
            'existing type (unique=True).')

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index',
                                        unique=False)
    def test_remove_index_with_invalid_index_type(self):
        """Testing DatabaseState.remove_index with invalid index type"""
        database_state = DatabaseState(db_name='default', scan=False)
        database_state.add_table('my_test_table')
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index',
                                 columns=['col1', 'col2'],
                                 unique=True)

        expected_message = (
            'Unable to remove index "my_index" from table "my_test_table". '
            'The specified index type (unique=False) does not match the '
            'existing type (unique=True).'
        )

        with self.assertRaisesMessage(DatabaseStateError, expected_message):
            database_state.remove_index(table_name='my_test_table',
                                        index_name='my_index',
                                        unique=False)