Fixed backends tests on Oracle.

Using Person in test_introspection caused removing constraints in
intermediate table for ManyToManyField in
VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ that were
expected by other transaction tests. A model without any constraints
was used to prevent isolation issues.
This commit is contained in:
Mariusz Felisiak 2020-02-24 14:21:50 +01:00 committed by GitHub
parent 84e35f4679
commit 94d4bd3a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -3,7 +3,7 @@ import unittest
from django.db import connection
from django.test import TransactionTestCase
from ..models import Person
from ..models import Square
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
@ -12,18 +12,18 @@ class DatabaseSequenceTests(TransactionTestCase):
def test_get_sequences(self):
with connection.cursor() as cursor:
seqs = connection.introspection.get_sequences(cursor, Person._meta.db_table, Person._meta.local_fields)
seqs = connection.introspection.get_sequences(cursor, Square._meta.db_table, Square._meta.local_fields)
self.assertEqual(len(seqs), 1)
self.assertIsNotNone(seqs[0]['name'])
self.assertEqual(seqs[0]['table'], Person._meta.db_table)
self.assertEqual(seqs[0]['table'], Square._meta.db_table)
self.assertEqual(seqs[0]['column'], 'id')
def test_get_sequences_manually_created_index(self):
with connection.cursor() as cursor:
with connection.schema_editor() as editor:
editor._drop_identity(Person._meta.db_table, 'id')
seqs = connection.introspection.get_sequences(cursor, Person._meta.db_table, Person._meta.local_fields)
self.assertEqual(seqs, [{'table': Person._meta.db_table, 'column': 'id'}])
editor._drop_identity(Square._meta.db_table, 'id')
seqs = connection.introspection.get_sequences(cursor, Square._meta.db_table, Square._meta.local_fields)
self.assertEqual(seqs, [{'table': Square._meta.db_table, 'column': 'id'}])
# Recreate model, because adding identity is impossible.
editor.delete_model(Person)
editor.create_model(Person)
editor.delete_model(Square)
editor.create_model(Square)