summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/postgres_tests
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_array.py38
-rw-r--r--tests/postgres_tests/test_constraints.py3
-rw-r--r--tests/postgres_tests/test_indexes.py6
-rw-r--r--tests/postgres_tests/test_introspection.py15
-rw-r--r--tests/postgres_tests/test_ranges.py27
5 files changed, 60 insertions, 29 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 512972b8e6..28d5924b9d 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -540,11 +540,17 @@ class TestQuerying(PostgreSQLTestCase):
)
def test_unsupported_lookup(self):
- msg = "Unsupported lookup '0_bar' for ArrayField or join on the field not permitted."
+ msg = (
+ "Unsupported lookup '0_bar' for ArrayField or join on the field not "
+ "permitted."
+ )
with self.assertRaisesMessage(FieldError, msg):
list(NullableIntegerArrayModel.objects.filter(field__0_bar=[2]))
- msg = "Unsupported lookup '0bar' for ArrayField or join on the field not permitted."
+ msg = (
+ "Unsupported lookup '0bar' for ArrayField or join on the field not "
+ "permitted."
+ )
with self.assertRaisesMessage(FieldError, msg):
list(NullableIntegerArrayModel.objects.filter(field__0bar=[2]))
@@ -881,7 +887,10 @@ class TestMigrations(TransactionTestCase):
class TestSerialization(PostgreSQLSimpleTestCase):
- test_data = '[{"fields": {"field": "[\\"1\\", \\"2\\", null]"}, "model": "postgres_tests.integerarraymodel", "pk": null}]'
+ test_data = (
+ '[{"fields": {"field": "[\\"1\\", \\"2\\", null]"}, '
+ '"model": "postgres_tests.integerarraymodel", "pk": null}]'
+ )
def test_dumping(self):
instance = IntegerArrayModel(field=[1, 2, None])
@@ -937,7 +946,8 @@ class TestValidation(PostgreSQLSimpleTestCase):
exception = cm.exception.error_list[0]
self.assertEqual(
exception.message,
- "Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
+ "Item 1 in the array did not validate: Ensure this value has at most 2 "
+ "characters (it has 3).",
)
self.assertEqual(exception.code, "item_invalid")
self.assertEqual(
@@ -956,7 +966,8 @@ class TestValidation(PostgreSQLSimpleTestCase):
exception = cm.exception.error_list[0]
self.assertEqual(
exception.message,
- "Item 1 in the array did not validate: Ensure this value is greater than or equal to 1.",
+ "Item 1 in the array did not validate: Ensure this value is greater than "
+ "or equal to 1.",
)
self.assertEqual(exception.code, "item_invalid")
self.assertEqual(
@@ -997,7 +1008,8 @@ class TestSimpleFormField(PostgreSQLSimpleTestCase):
first_error = errors[0]
self.assertEqual(
first_error.message,
- "Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
+ "Item 1 in the array did not validate: Ensure this value has at most 2 "
+ "characters (it has 3).",
)
self.assertEqual(first_error.code, "item_invalid")
self.assertEqual(
@@ -1007,7 +1019,8 @@ class TestSimpleFormField(PostgreSQLSimpleTestCase):
second_error = errors[1]
self.assertEqual(
second_error.message,
- "Item 3 in the array did not validate: Ensure this value has at most 2 characters (it has 4).",
+ "Item 3 in the array did not validate: Ensure this value has at most 2 "
+ "characters (it has 4).",
)
self.assertEqual(second_error.code, "item_invalid")
self.assertEqual(
@@ -1169,7 +1182,10 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
)
def test_invalid_integer(self):
- msg = "Item 2 in the array did not validate: Ensure this value is less than or equal to 100."
+ msg = (
+ "Item 2 in the array did not validate: Ensure this value is less than or "
+ "equal to 100."
+ )
with self.assertRaisesMessage(exceptions.ValidationError, msg):
SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
@@ -1200,8 +1216,10 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
self.assertEqual(
cm.exception.messages,
[
- "Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
- "Item 3 in the array did not validate: Ensure this value has at most 2 characters (it has 4).",
+ "Item 1 in the array did not validate: Ensure this value has at most 2 "
+ "characters (it has 3).",
+ "Item 3 in the array did not validate: Ensure this value has at most 2 "
+ "characters (it has 4).",
],
)
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index 14b45f9b7f..377af41042 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -920,7 +920,8 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
)
with connection.schema_editor() as editor:
with mock.patch(
- "django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_gist_indexes",
+ "django.db.backends.postgresql.features.DatabaseFeatures."
+ "supports_covering_gist_indexes",
False,
):
with self.assertRaisesMessage(NotSupportedError, msg):
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index f57e7a7c80..100e570092 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -519,7 +519,8 @@ class SchemaTests(PostgreSQLTestCase):
msg = "Covering GiST indexes require PostgreSQL 12+."
with self.assertRaisesMessage(NotSupportedError, msg):
with mock.patch(
- "django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_gist_indexes",
+ "django.db.backends.postgresql.features.DatabaseFeatures."
+ "supports_covering_gist_indexes",
False,
):
with connection.schema_editor() as editor:
@@ -632,7 +633,8 @@ class SchemaTests(PostgreSQLTestCase):
msg = "Covering SP-GiST indexes require PostgreSQL 14+."
with self.assertRaisesMessage(NotSupportedError, msg):
with mock.patch(
- "django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_spgist_indexes",
+ "django.db.backends.postgresql.features.DatabaseFeatures."
+ "supports_covering_spgist_indexes",
False,
):
with connection.schema_editor() as editor:
diff --git a/tests/postgres_tests/test_introspection.py b/tests/postgres_tests/test_introspection.py
index 670be46536..3179b47cc9 100644
--- a/tests/postgres_tests/test_introspection.py
+++ b/tests/postgres_tests/test_introspection.py
@@ -23,10 +23,15 @@ class InspectDBTests(PostgreSQLTestCase):
self.assertFieldsInModel(
"postgres_tests_rangesmodel",
[
- "ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, null=True)",
- "bigints = django.contrib.postgres.fields.BigIntegerRangeField(blank=True, null=True)",
- "decimals = django.contrib.postgres.fields.DecimalRangeField(blank=True, null=True)",
- "timestamps = django.contrib.postgres.fields.DateTimeRangeField(blank=True, null=True)",
- "dates = django.contrib.postgres.fields.DateRangeField(blank=True, null=True)",
+ "ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, "
+ "null=True)",
+ "bigints = django.contrib.postgres.fields.BigIntegerRangeField("
+ "blank=True, null=True)",
+ "decimals = django.contrib.postgres.fields.DecimalRangeField("
+ "blank=True, null=True)",
+ "timestamps = django.contrib.postgres.fields.DateTimeRangeField("
+ "blank=True, null=True)",
+ "dates = django.contrib.postgres.fields.DateRangeField(blank=True, "
+ "null=True)",
],
)
diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py
index 7563b4ffff..aaef47d6be 100644
--- a/tests/postgres_tests/test_ranges.py
+++ b/tests/postgres_tests/test_ranges.py
@@ -550,13 +550,14 @@ class TestSerialization(PostgreSQLSimpleTestCase):
test_data = (
'[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", '
'\\"bounds\\": \\"[)\\"}", "decimals": "{\\"empty\\": true}", '
- '"bigints": null, "timestamps": "{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
+ '"bigints": null, "timestamps": '
+ '"{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
'\\"lower\\": \\"2014-01-01T00:00:00+00:00\\", \\"bounds\\": \\"[)\\"}", '
'"timestamps_inner": null, '
'"timestamps_closed_bounds": "{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
'\\"lower\\": \\"2014-01-01T00:00:00+00:00\\", \\"bounds\\": \\"()\\"}", '
- '"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", \\"bounds\\": \\"[)\\"}", '
- '"dates_inner": null }, '
+ '"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", '
+ '\\"bounds\\": \\"[)\\"}", "dates_inner": null }, '
'"model": "postgres_tests.rangesmodel", "pk": null}]'
)
@@ -730,8 +731,10 @@ class TestFormField(PostgreSQLSimpleTestCase):
</th><td>
<input type="text" name="datetime_field_0" id="id_datetime_field_0">
<input type="text" name="datetime_field_1" id="id_datetime_field_1">
- <input type="hidden" name="initial-datetime_field_0" id="initial-id_datetime_field_0">
- <input type="hidden" name="initial-datetime_field_1" id="initial-id_datetime_field_1">
+ <input type="hidden" name="initial-datetime_field_0"
+ id="initial-id_datetime_field_0">
+ <input type="hidden" name="initial-datetime_field_1"
+ id="initial-id_datetime_field_1">
</td></tr>
""",
)
@@ -751,10 +754,10 @@ class TestFormField(PostgreSQLSimpleTestCase):
value="2010-01-01 11:13:00" id="id_datetime_field_0">
<input type="text" name="datetime_field_1"
value="2020-12-12 16:59:00" id="id_datetime_field_1">
- <input type="hidden" name="initial-datetime_field_0" value="2010-01-01 11:13:00"
- id="initial-id_datetime_field_0">
- <input type="hidden" name="initial-datetime_field_1" value="2020-12-12 16:59:00"
- id="initial-id_datetime_field_1"></td></tr>
+ <input type="hidden" name="initial-datetime_field_0"
+ value="2010-01-01 11:13:00" id="initial-id_datetime_field_0">
+ <input type="hidden" name="initial-datetime_field_1"
+ value="2020-12-12 16:59:00" id="initial-id_datetime_field_1"></td></tr>
""",
)
@@ -1074,11 +1077,13 @@ class TestWidget(PostgreSQLSimpleTestCase):
f = pg_forms.ranges.DateTimeRangeField()
self.assertHTMLEqual(
f.widget.render("datetimerange", ""),
- '<input type="text" name="datetimerange_0"><input type="text" name="datetimerange_1">',
+ '<input type="text" name="datetimerange_0">'
+ '<input type="text" name="datetimerange_1">',
)
self.assertHTMLEqual(
f.widget.render("datetimerange", None),
- '<input type="text" name="datetimerange_0"><input type="text" name="datetimerange_1">',
+ '<input type="text" name="datetimerange_0">'
+ '<input type="text" name="datetimerange_1">',
)
dt_range = DateTimeTZRange(
datetime.datetime(2006, 1, 10, 7, 30), datetime.datetime(2006, 2, 12, 9, 50)