Beispiel #1
0
    def test_rescan_indexes(self):
        """Testing DatabaseState.rescan_indexes"""
        database_state = DatabaseState(db_name='default')

        # Check that a few known tables are in the list, to make sure
        # the scan worked.
        for table_name in ('django_content_type', 'django_evolution',
                           'django_project_version'):
            self.assertTrue(database_state.has_table(table_name))

        # Check the Evolution model.
        indexes = [
            (index_state.columns, index_state.unique)
            for index_state in database_state.iter_indexes('django_evolution')
        ]

        self.assertIn((['version_id'], False), indexes)
    def test_rescan_indexes(self):
        """Testing DatabaseState.rescan_indexes"""
        database_state = DatabaseState(db_name='default')

        # Check that a few known tables are in the list, to make sure
        # the scan worked.
        for table_name in ('django_content_type',
                           'django_evolution',
                           'django_project_version'):
            self.assertTrue(database_state.has_table(table_name))

        # Check the Evolution model.
        indexes = [
            (index_state.columns, index_state.unique)
            for index_state in database_state.iter_indexes('django_evolution')
        ]

        self.assertIn((['version_id'], False), indexes)
    def test_iter_indexes(self):
        """Testing DatabaseState.iter_indexes"""
        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_index1',
                                 columns=['col1', 'col2'],
                                 unique=True)
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index2',
                                 columns=['col3'])

        indexes = list(database_state.iter_indexes('my_test_table'))

        self.assertEqual(indexes, [
            IndexState(name='my_index1', columns=['col1', 'col2'],
                       unique=True),
            IndexState(name='my_index2', columns=['col3'], unique=False),
        ])
    def test_iter_indexes(self):
        """Testing DatabaseState.iter_indexes"""
        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_index1',
                                 columns=['col1', 'col2'],
                                 unique=True)
        database_state.add_index(table_name='my_test_table',
                                 index_name='my_index2',
                                 columns=['col3'])

        indexes = list(database_state.iter_indexes('my_test_table'))

        self.assertEqual(
            indexes,
            [
                IndexState(name='my_index1',
                           columns=['col1', 'col2'],
                           unique=True),
                IndexState(name='my_index2',
                           columns=['col3'],
                           unique=False),
            ])