diff options
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_array.py | 38 | ||||
| -rw-r--r-- | tests/postgres_tests/test_constraints.py | 3 | ||||
| -rw-r--r-- | tests/postgres_tests/test_indexes.py | 3 | ||||
| -rw-r--r-- | tests/postgres_tests/test_introspection.py | 15 | ||||
| -rw-r--r-- | tests/postgres_tests/test_ranges.py | 26 |
5 files changed, 58 insertions, 27 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 b1211d7673..1337c5730d 100644 --- a/tests/postgres_tests/test_constraints.py +++ b/tests/postgres_tests/test_constraints.py @@ -843,7 +843,8 @@ class ExclusionConstraintTests(PostgreSQLTestCase): msg = "Covering exclusion constraints requires PostgreSQL 12+." 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 5eb060e7f5..ab5cdfda32 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 requires 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: 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 d100d40713..d5ab0c5335 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -492,10 +492,12 @@ 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, ' - '"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", \\"bounds\\": \\"[)\\"}", ' + '"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", ' + '\\"bounds\\": \\"[)\\"}", ' '"dates_inner": null }, ' '"model": "postgres_tests.rangesmodel", "pk": null}]' ) @@ -660,8 +662,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> """, ) @@ -681,10 +685,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> """, ) @@ -983,11 +987,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) |
