mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Name PostgreSQL correctly.
This commit is contained in:
parent
33ea472f69
commit
00e8e514e1
@ -5,5 +5,5 @@ from django.test import TestCase
|
|||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests")
|
@unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests")
|
||||||
class PostgresSQLTestCase(TestCase):
|
class PostgreSQLTestCase(TestCase):
|
||||||
pass
|
pass
|
||||||
|
@ -6,11 +6,11 @@ from django.contrib.postgres.aggregates import (
|
|||||||
from django.db.models.expressions import F, Value
|
from django.db.models.expressions import F, Value
|
||||||
from django.test.utils import Approximate
|
from django.test.utils import Approximate
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import AggregateTestModel, StatTestModel
|
from .models import AggregateTestModel, StatTestModel
|
||||||
|
|
||||||
|
|
||||||
class TestGeneralAggregate(PostgresSQLTestCase):
|
class TestGeneralAggregate(PostgreSQLTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
AggregateTestModel.objects.create(boolean_field=True, char_field='Foo1', integer_field=0)
|
AggregateTestModel.objects.create(boolean_field=True, char_field='Foo1', integer_field=0)
|
||||||
@ -111,7 +111,7 @@ class TestGeneralAggregate(PostgresSQLTestCase):
|
|||||||
self.assertEqual(values, {'stringagg': ''})
|
self.assertEqual(values, {'stringagg': ''})
|
||||||
|
|
||||||
|
|
||||||
class TestStatisticsAggregate(PostgresSQLTestCase):
|
class TestStatisticsAggregate(PostgreSQLTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
StatTestModel.objects.create(
|
StatTestModel.objects.create(
|
||||||
|
@ -10,7 +10,7 @@ from django.db import IntegrityError, connection, models
|
|||||||
from django.test import TransactionTestCase, override_settings
|
from django.test import TransactionTestCase, override_settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import (
|
from .models import (
|
||||||
ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel, IntegerArrayModel,
|
ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel, IntegerArrayModel,
|
||||||
NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel,
|
NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel,
|
||||||
@ -23,7 +23,7 @@ except ImportError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestSaveLoad(PostgresSQLTestCase):
|
class TestSaveLoad(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_integer(self):
|
def test_integer(self):
|
||||||
instance = IntegerArrayModel(field=[1, 2, 3])
|
instance = IntegerArrayModel(field=[1, 2, 3])
|
||||||
@ -98,7 +98,7 @@ class TestSaveLoad(PostgresSQLTestCase):
|
|||||||
self.assertEqual(instance.decimals, loaded.decimals)
|
self.assertEqual(instance.decimals, loaded.decimals)
|
||||||
|
|
||||||
|
|
||||||
class TestQuerying(PostgresSQLTestCase):
|
class TestQuerying(PostgreSQLTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.objs = [
|
self.objs = [
|
||||||
@ -229,7 +229,7 @@ class TestQuerying(PostgresSQLTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestChecks(PostgresSQLTestCase):
|
class TestChecks(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_field_checks(self):
|
def test_field_checks(self):
|
||||||
field = ArrayField(models.CharField())
|
field = ArrayField(models.CharField())
|
||||||
@ -294,7 +294,7 @@ class TestMigrations(TransactionTestCase):
|
|||||||
self.assertNotIn(table_name, connection.introspection.table_names(cursor))
|
self.assertNotIn(table_name, connection.introspection.table_names(cursor))
|
||||||
|
|
||||||
|
|
||||||
class TestSerialization(PostgresSQLTestCase):
|
class TestSerialization(PostgreSQLTestCase):
|
||||||
test_data = '[{"fields": {"field": "[\\"1\\", \\"2\\"]"}, "model": "postgres_tests.integerarraymodel", "pk": null}]'
|
test_data = '[{"fields": {"field": "[\\"1\\", \\"2\\"]"}, "model": "postgres_tests.integerarraymodel", "pk": null}]'
|
||||||
|
|
||||||
def test_dumping(self):
|
def test_dumping(self):
|
||||||
@ -307,7 +307,7 @@ class TestSerialization(PostgresSQLTestCase):
|
|||||||
self.assertEqual(instance.field, [1, 2])
|
self.assertEqual(instance.field, [1, 2])
|
||||||
|
|
||||||
|
|
||||||
class TestValidation(PostgresSQLTestCase):
|
class TestValidation(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_unbounded(self):
|
def test_unbounded(self):
|
||||||
field = ArrayField(models.IntegerField())
|
field = ArrayField(models.IntegerField())
|
||||||
@ -345,7 +345,7 @@ class TestValidation(PostgresSQLTestCase):
|
|||||||
self.assertEqual(cm.exception.messages[0], 'Item 0 in the array did not validate: Ensure this value is greater than or equal to 1.')
|
self.assertEqual(cm.exception.messages[0], 'Item 0 in the array did not validate: Ensure this value is greater than or equal to 1.')
|
||||||
|
|
||||||
|
|
||||||
class TestSimpleFormField(PostgresSQLTestCase):
|
class TestSimpleFormField(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_valid(self):
|
def test_valid(self):
|
||||||
field = SimpleArrayField(forms.CharField())
|
field = SimpleArrayField(forms.CharField())
|
||||||
@ -417,7 +417,7 @@ class TestSimpleFormField(PostgresSQLTestCase):
|
|||||||
self.assertEqual(form_field.max_length, 4)
|
self.assertEqual(form_field.max_length, 4)
|
||||||
|
|
||||||
|
|
||||||
class TestSplitFormField(PostgresSQLTestCase):
|
class TestSplitFormField(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_valid(self):
|
def test_valid(self):
|
||||||
class SplitForm(forms.Form):
|
class SplitForm(forms.Form):
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
from django.core import exceptions, serializers
|
from django.core import exceptions, serializers
|
||||||
from django.forms import Form
|
from django.forms import Form
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import HStoreModel
|
from .models import HStoreModel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -14,7 +14,7 @@ except ImportError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SimpleTests(PostgresSQLTestCase):
|
class SimpleTests(PostgreSQLTestCase):
|
||||||
apps = ['django.contrib.postgres']
|
apps = ['django.contrib.postgres']
|
||||||
|
|
||||||
def test_save_load_success(self):
|
def test_save_load_success(self):
|
||||||
@ -38,7 +38,7 @@ class SimpleTests(PostgresSQLTestCase):
|
|||||||
self.assertEqual(reloaded.field, value)
|
self.assertEqual(reloaded.field, value)
|
||||||
|
|
||||||
|
|
||||||
class TestQuerying(PostgresSQLTestCase):
|
class TestQuerying(PostgreSQLTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.objs = [
|
self.objs = [
|
||||||
@ -133,7 +133,7 @@ class TestQuerying(PostgresSQLTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestSerialization(PostgresSQLTestCase):
|
class TestSerialization(PostgreSQLTestCase):
|
||||||
test_data = '[{"fields": {"field": "{\\"a\\": \\"b\\"}"}, "model": "postgres_tests.hstoremodel", "pk": null}]'
|
test_data = '[{"fields": {"field": "{\\"a\\": \\"b\\"}"}, "model": "postgres_tests.hstoremodel", "pk": null}]'
|
||||||
|
|
||||||
def test_dumping(self):
|
def test_dumping(self):
|
||||||
@ -146,7 +146,7 @@ class TestSerialization(PostgresSQLTestCase):
|
|||||||
self.assertEqual(instance.field, {'a': 'b'})
|
self.assertEqual(instance.field, {'a': 'b'})
|
||||||
|
|
||||||
|
|
||||||
class TestValidation(PostgresSQLTestCase):
|
class TestValidation(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_not_a_string(self):
|
def test_not_a_string(self):
|
||||||
field = HStoreField()
|
field = HStoreField()
|
||||||
@ -156,7 +156,7 @@ class TestValidation(PostgresSQLTestCase):
|
|||||||
self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string.')
|
self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string.')
|
||||||
|
|
||||||
|
|
||||||
class TestFormField(PostgresSQLTestCase):
|
class TestFormField(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_valid(self):
|
def test_valid(self):
|
||||||
field = forms.HStoreField()
|
field = forms.HStoreField()
|
||||||
@ -192,7 +192,7 @@ class TestFormField(PostgresSQLTestCase):
|
|||||||
self.assertFalse(form_w_hstore.has_changed())
|
self.assertFalse(form_w_hstore.has_changed())
|
||||||
|
|
||||||
|
|
||||||
class TestValidator(PostgresSQLTestCase):
|
class TestValidator(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_simple_valid(self):
|
def test_simple_valid(self):
|
||||||
validator = KeysValidator(keys=['a', 'b'])
|
validator = KeysValidator(keys=['a', 'b'])
|
||||||
|
@ -5,7 +5,7 @@ from django.core import exceptions, serializers
|
|||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import JSONModel
|
from .models import JSONModel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -219,7 +219,7 @@ class TestSerialization(TestCase):
|
|||||||
self.assertEqual(instance.field, {'a': 'b'})
|
self.assertEqual(instance.field, {'a': 'b'})
|
||||||
|
|
||||||
|
|
||||||
class TestValidation(PostgresSQLTestCase):
|
class TestValidation(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_not_serializable(self):
|
def test_not_serializable(self):
|
||||||
field = JSONField()
|
field = JSONField()
|
||||||
@ -229,7 +229,7 @@ class TestValidation(PostgresSQLTestCase):
|
|||||||
self.assertEqual(cm.exception.message % cm.exception.params, "Value must be valid JSON.")
|
self.assertEqual(cm.exception.message % cm.exception.params, "Value must be valid JSON.")
|
||||||
|
|
||||||
|
|
||||||
class TestFormField(PostgresSQLTestCase):
|
class TestFormField(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_valid(self):
|
def test_valid(self):
|
||||||
field = forms.JSONField()
|
field = forms.JSONField()
|
||||||
|
@ -8,7 +8,7 @@ from django.db import connection
|
|||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import RangesModel
|
from .models import RangesModel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -222,7 +222,7 @@ class TestSerialization(TestCase):
|
|||||||
self.assertEqual(instance.dates, None)
|
self.assertEqual(instance.dates, None)
|
||||||
|
|
||||||
|
|
||||||
class TestValidators(PostgresSQLTestCase):
|
class TestValidators(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_max(self):
|
def test_max(self):
|
||||||
validator = RangeMaxValueValidator(5)
|
validator = RangeMaxValueValidator(5)
|
||||||
@ -241,7 +241,7 @@ class TestValidators(PostgresSQLTestCase):
|
|||||||
self.assertEqual(cm.exception.code, 'min_value')
|
self.assertEqual(cm.exception.code, 'min_value')
|
||||||
|
|
||||||
|
|
||||||
class TestFormField(PostgresSQLTestCase):
|
class TestFormField(PostgreSQLTestCase):
|
||||||
|
|
||||||
def test_valid_integer(self):
|
def test_valid_integer(self):
|
||||||
field = pg_forms.IntegerRangeField()
|
field = pg_forms.IntegerRangeField()
|
||||||
@ -508,7 +508,7 @@ class TestFormField(PostgresSQLTestCase):
|
|||||||
self.assertIsInstance(form_field, pg_forms.DateTimeRangeField)
|
self.assertIsInstance(form_field, pg_forms.DateTimeRangeField)
|
||||||
|
|
||||||
|
|
||||||
class TestWidget(PostgresSQLTestCase):
|
class TestWidget(PostgreSQLTestCase):
|
||||||
def test_range_widget(self):
|
def test_range_widget(self):
|
||||||
f = pg_forms.ranges.DateTimeRangeField()
|
f = pg_forms.ranges.DateTimeRangeField()
|
||||||
self.assertHTMLEqual(
|
self.assertHTMLEqual(
|
||||||
|
@ -3,12 +3,12 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.test import modify_settings
|
from django.test import modify_settings
|
||||||
|
|
||||||
from . import PostgresSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import CharFieldModel, TextFieldModel
|
from .models import CharFieldModel, TextFieldModel
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
|
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
|
||||||
class UnaccentTest(PostgresSQLTestCase):
|
class UnaccentTest(PostgreSQLTestCase):
|
||||||
|
|
||||||
Model = CharFieldModel
|
Model = CharFieldModel
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user