Refs #25979 -- Dropped compatiblity for running tests on PostgreSQL < 9.2.

This commit is contained in:
Tim Graham 2016-02-12 09:59:13 -05:00
parent 18afd50a2b
commit 36f1f5cfb0
3 changed files with 18 additions and 48 deletions

View File

@ -141,9 +141,6 @@ class Migration(migrations.Migration):
('when', models.DateTimeField(null=True, default=None)), ('when', models.DateTimeField(null=True, default=None)),
] ]
), ),
]
pg_92_operations = [
migrations.CreateModel( migrations.CreateModel(
name='RangesModel', name='RangesModel',
fields=[ fields=[
@ -199,8 +196,6 @@ class Migration(migrations.Migration):
except AttributeError: except AttributeError:
pass # We are probably not on PostgreSQL pass # We are probably not on PostgreSQL
else: else:
if PG_VERSION >= 90200:
self.operations = self.operations + self.pg_92_operations
if PG_VERSION >= 90400: if PG_VERSION >= 90400:
self.operations = self.operations + self.pg_94_operations self.operations = self.operations + self.pg_94_operations
return super(Migration, self).apply(project_state, schema_editor, collect_sql) return super(Migration, self).apply(project_state, schema_editor, collect_sql)

View File

@ -52,30 +52,21 @@ class TextFieldModel(models.Model):
field = models.TextField() field = models.TextField()
# Only create this model for postgres >= 9.2 class RangesModel(PostgreSQLModel):
if connection.vendor == 'postgresql' and connection.pg_version >= 90200: ints = IntegerRangeField(blank=True, null=True)
class RangesModel(PostgreSQLModel): bigints = BigIntegerRangeField(blank=True, null=True)
ints = IntegerRangeField(blank=True, null=True) floats = FloatRangeField(blank=True, null=True)
bigints = BigIntegerRangeField(blank=True, null=True) timestamps = DateTimeRangeField(blank=True, null=True)
floats = FloatRangeField(blank=True, null=True) dates = DateRangeField(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: class RangeLookupsModel(PostgreSQLModel):
# create an object with this name so we don't have failing imports parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True)
class RangesModel(object): integer = models.IntegerField(blank=True, null=True)
pass big_integer = models.BigIntegerField(blank=True, null=True)
float = models.FloatField(blank=True, null=True)
class RangeLookupsModel(object): timestamp = models.DateTimeField(blank=True, null=True)
pass date = models.DateField(blank=True, null=True)
# Only create this model for postgres >= 9.4 # Only create this model for postgres >= 9.4

View File

@ -1,12 +1,10 @@
import datetime import datetime
import json import json
import unittest
from django import forms from django import forms
from django.core import exceptions, serializers from django.core import exceptions, serializers
from django.db import connection
from django.db.models import F 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 django.utils import timezone
from . import PostgreSQLTestCase from . import PostgreSQLTestCase
@ -22,18 +20,7 @@ except ImportError:
pass pass
def skipUnlessPG92(test): class TestSaveLoad(PostgreSQLTestCase):
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):
def test_all_fields(self): def test_all_fields(self):
now = timezone.now() now = timezone.now()
@ -94,8 +81,7 @@ class TestSaveLoad(TestCase):
self.assertIsNone(loaded.ints) self.assertIsNone(loaded.ints)
@skipUnlessPG92 class TestQuerying(PostgreSQLTestCase):
class TestQuerying(TestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
@ -198,8 +184,7 @@ class TestQuerying(TestCase):
) )
@skipUnlessPG92 class TestQueryingWithRanges(PostgreSQLTestCase):
class TestQueryingWithRanges(TestCase):
def test_date_range(self): def test_date_range(self):
objs = [ objs = [
RangeLookupsModel.objects.create(date='2015-01-01'), RangeLookupsModel.objects.create(date='2015-01-01'),
@ -288,8 +273,7 @@ class TestQueryingWithRanges(TestCase):
) )
@skipUnlessPG92 class TestSerialization(PostgreSQLTestCase):
class TestSerialization(TestCase):
test_data = ( test_data = (
'[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", ' '[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", '
'\\"bounds\\": \\"[)\\"}", "floats": "{\\"empty\\": true}", ' '\\"bounds\\": \\"[)\\"}", "floats": "{\\"empty\\": true}", '