1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00
django/tests/backends/oracle/test_introspection.py
Mariusz Felisiak 94d4bd3a09
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.
2020-02-24 14:21:50 +01:00

30 lines
1.2 KiB
Python

import unittest
from django.db import connection
from django.test import TransactionTestCase
from ..models import Square
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
class DatabaseSequenceTests(TransactionTestCase):
available_apps = []
def test_get_sequences(self):
with connection.cursor() as cursor:
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'], 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(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(Square)
editor.create_model(Square)