~ubuntuone-pqm-team/django/stable

« back to all changes in this revision

Viewing changes to django/contrib/gis/tests/geoapp/test_regress.py

  • Committer: Matias Bordese
  • Date: 2014-08-21 21:22:40 UTC
  • Revision ID: matias.bordese@canonical.com-20140821212240-tij4ms6qzjbdiioz
Tags: 1.5.9
Imported Django 1.5.9 from released tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
from datetime import datetime
5
5
 
6
 
from django.contrib.gis.geos import HAS_GEOS
7
6
from django.contrib.gis.tests.utils import no_mysql, no_spatialite
8
7
from django.contrib.gis.shortcuts import render_to_kmz
9
 
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
10
8
from django.db.models import Count, Min
11
9
from django.test import TestCase
12
 
from django.utils.unittest import skipUnless
13
 
 
14
 
if HAS_GEOS:
15
 
    from .models import City, PennsylvaniaCity, State, Truth
16
 
 
17
 
 
18
 
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
 
10
 
 
11
from .models import City, PennsylvaniaCity, State, Truth
 
12
 
 
13
 
19
14
class GeoRegressionTests(TestCase):
20
15
 
21
16
    def test_update(self):
54
49
        founded = datetime(1857, 5, 23)
55
50
        mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)',
56
51
                                                    founded=founded)
57
 
        self.assertEqual(founded, PennsylvaniaCity.objects.datetimes('founded', 'day')[0])
 
52
        self.assertEqual(founded, PennsylvaniaCity.objects.dates('founded', 'day')[0])
58
53
        self.assertEqual(founded, PennsylvaniaCity.objects.aggregate(Min('founded'))['founded__min'])
59
54
 
60
55
    def test_empty_count(self):
77
72
        t1 = Truth.objects.create(val=True)
78
73
        t2 = Truth.objects.create(val=False)
79
74
 
80
 
        val1 = Truth.objects.get(pk=t1.pk).val
81
 
        val2 = Truth.objects.get(pk=t2.pk).val
 
75
        val1 = Truth.objects.get(pk=1).val
 
76
        val2 = Truth.objects.get(pk=2).val
82
77
        # verify types -- should't be 0/1
83
78
        self.assertIsInstance(val1, bool)
84
79
        self.assertIsInstance(val2, bool)