Refs #25979 -- Dropped compatiblity for running tests on PostgreSQL < 9.2.
This commit is contained in:
parent
18afd50a2b
commit
36f1f5cfb0
|
@ -141,9 +141,6 @@ class Migration(migrations.Migration):
|
|||
('when', models.DateTimeField(null=True, default=None)),
|
||||
]
|
||||
),
|
||||
]
|
||||
|
||||
pg_92_operations = [
|
||||
migrations.CreateModel(
|
||||
name='RangesModel',
|
||||
fields=[
|
||||
|
@ -199,8 +196,6 @@ class Migration(migrations.Migration):
|
|||
except AttributeError:
|
||||
pass # We are probably not on PostgreSQL
|
||||
else:
|
||||
if PG_VERSION >= 90200:
|
||||
self.operations = self.operations + self.pg_92_operations
|
||||
if PG_VERSION >= 90400:
|
||||
self.operations = self.operations + self.pg_94_operations
|
||||
return super(Migration, self).apply(project_state, schema_editor, collect_sql)
|
||||
|
|
|
@ -52,30 +52,21 @@ class TextFieldModel(models.Model):
|
|||
field = models.TextField()
|
||||
|
||||
|
||||
# Only create this model for postgres >= 9.2
|
||||
if connection.vendor == 'postgresql' and connection.pg_version >= 90200:
|
||||
class RangesModel(PostgreSQLModel):
|
||||
ints = IntegerRangeField(blank=True, null=True)
|
||||
bigints = BigIntegerRangeField(blank=True, null=True)
|
||||
floats = FloatRangeField(blank=True, null=True)
|
||||
timestamps = DateTimeRangeField(blank=True, null=True)
|
||||
dates = DateRangeField(blank=True, null=True)
|
||||
class RangesModel(PostgreSQLModel):
|
||||
ints = IntegerRangeField(blank=True, null=True)
|
||||
bigints = BigIntegerRangeField(blank=True, null=True)
|
||||
floats = FloatRangeField(blank=True, null=True)
|
||||
timestamps = DateTimeRangeField(blank=True, null=True)
|
||||
dates = DateRangeField(blank=True, null=True)
|
||||
|
||||
class RangeLookupsModel(PostgreSQLModel):
|
||||
parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True)
|
||||
integer = models.IntegerField(blank=True, null=True)
|
||||
big_integer = models.BigIntegerField(blank=True, null=True)
|
||||
float = models.FloatField(blank=True, null=True)
|
||||
timestamp = models.DateTimeField(blank=True, null=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
|
||||
else:
|
||||
# create an object with this name so we don't have failing imports
|
||||
class RangesModel(object):
|
||||
pass
|
||||
|
||||
class RangeLookupsModel(object):
|
||||
pass
|
||||
class RangeLookupsModel(PostgreSQLModel):
|
||||
parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True)
|
||||
integer = models.IntegerField(blank=True, null=True)
|
||||
big_integer = models.BigIntegerField(blank=True, null=True)
|
||||
float = models.FloatField(blank=True, null=True)
|
||||
timestamp = models.DateTimeField(blank=True, null=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
|
||||
|
||||
# Only create this model for postgres >= 9.4
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import datetime
|
||||
import json
|
||||
import unittest
|
||||
|
||||
from django import forms
|
||||
from django.core import exceptions, serializers
|
||||
from django.db import connection
|
||||
from django.db.models import F
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test import override_settings
|
||||
from django.utils import timezone
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
|
@ -22,18 +20,7 @@ except ImportError:
|
|||
pass
|
||||
|
||||
|
||||
def skipUnlessPG92(test):
|
||||
try:
|
||||
PG_VERSION = connection.pg_version
|
||||
except AttributeError:
|
||||
PG_VERSION = 0
|
||||
if PG_VERSION < 90200:
|
||||
return unittest.skip('PostgreSQL >= 9.2 required')(test)
|
||||
return test
|
||||
|
||||
|
||||
@skipUnlessPG92
|
||||
class TestSaveLoad(TestCase):
|
||||
class TestSaveLoad(PostgreSQLTestCase):
|
||||
|
||||
def test_all_fields(self):
|
||||
now = timezone.now()
|
||||
|
@ -94,8 +81,7 @@ class TestSaveLoad(TestCase):
|
|||
self.assertIsNone(loaded.ints)
|
||||
|
||||
|
||||
@skipUnlessPG92
|
||||
class TestQuerying(TestCase):
|
||||
class TestQuerying(PostgreSQLTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
@ -198,8 +184,7 @@ class TestQuerying(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@skipUnlessPG92
|
||||
class TestQueryingWithRanges(TestCase):
|
||||
class TestQueryingWithRanges(PostgreSQLTestCase):
|
||||
def test_date_range(self):
|
||||
objs = [
|
||||
RangeLookupsModel.objects.create(date='2015-01-01'),
|
||||
|
@ -288,8 +273,7 @@ class TestQueryingWithRanges(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@skipUnlessPG92
|
||||
class TestSerialization(TestCase):
|
||||
class TestSerialization(PostgreSQLTestCase):
|
||||
test_data = (
|
||||
'[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", '
|
||||
'\\"bounds\\": \\"[)\\"}", "floats": "{\\"empty\\": true}", '
|
||||
|
|
Loading…
Reference in New Issue