summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_constraints.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-16 16:56:44 +0200
committerGitHub <noreply@github.com>2019-07-16 16:56:44 +0200
commitcf79f92abee2ff5fd4fdcc1a124129a9773805b8 (patch)
treef1d442fafca439b709a46f3a00f80e13cd3cc380 /tests/postgres_tests/test_constraints.py
parentad4e83a6d1c0a212fae751a3125dff6e28b2390a (diff)
Simplified tests for PostgreSQL constraints.
Diffstat (limited to 'tests/postgres_tests/test_constraints.py')
-rw-r--r--tests/postgres_tests/test_constraints.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index 2fc6ee5322..3ecabcbd49 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -29,9 +29,7 @@ class SchemaTests(PostgreSQLTestCase):
)
with connection.schema_editor() as editor:
editor.add_constraint(RangesModel, constraint)
- with connection.cursor() as cursor:
- constraints = connection.introspection.get_constraints(cursor, RangesModel._meta.db_table)
- self.assertIn(constraint_name, constraints)
+ self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
with self.assertRaises(IntegrityError), transaction.atomic():
RangesModel.objects.create(ints=(20, 50))
RangesModel.objects.create(ints=(10, 30))
@@ -45,9 +43,7 @@ class SchemaTests(PostgreSQLTestCase):
)
with connection.schema_editor() as editor:
editor.add_constraint(RangesModel, constraint)
- with connection.cursor() as cursor:
- constraints = connection.introspection.get_constraints(cursor, RangesModel._meta.db_table)
- self.assertIn(constraint_name, constraints)
+ self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
date_1 = datetime.date(2016, 1, 1)
date_2 = datetime.date(2016, 1, 4)
with self.assertRaises(IntegrityError), transaction.atomic():
@@ -69,9 +65,7 @@ class SchemaTests(PostgreSQLTestCase):
)
with connection.schema_editor() as editor:
editor.add_constraint(RangesModel, constraint)
- with connection.cursor() as cursor:
- constraints = connection.introspection.get_constraints(cursor, RangesModel._meta.db_table)
- self.assertIn(constraint_name, constraints)
+ self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
datetime_1 = datetime.datetime(2016, 1, 1)
datetime_2 = datetime.datetime(2016, 1, 2, 12)
with self.assertRaises(IntegrityError), transaction.atomic():