1 """
2 This file demonstrates two different styles of tests (one doctest and one
3 unittest). These will both pass when you run "manage.py test".
4
5 Replace these with more appropriate tests for your application.
6 """
7
8 from django.test import TestCase, Client
9 from madrona.studyregion.models import StudyRegion
10 from django.conf.urls.defaults import *
11 from django.conf import settings
12 from django.contrib.gis.geos import GEOSGeometry
13
14 urlpatterns = patterns('',
15
16 (r'/studyregion/', include('madrona.studyregion.urls')),
17 )
18
20 fixtures = ['example_data']
21
28
30 """
31 Check computing of lookat values
32 """
33 g1 = GEOSGeometry(
34 'SRID=4326;MULTIPOLYGON(((-120.42 34.37, -119.64 34.32, -119.63 34.12, -120.44 34.15, -120.42 34.37)))')
35 g1.transform(settings.GEOMETRY_DB_SRID)
36 region = StudyRegion.objects.create(geometry=g1, name="Test region", active=True)
37 region.lookAt_Lat = 0
38 region.lookAt_Lon = 0
39 self.assertEquals(region.lookAt_Lat, 0.0)
40 self.assertEquals(region.lookAt_Lon, 0.0)
41 lookat_kml = region.lookAtKml()
42 self.assertAlmostEquals(region.lookAt_Lat, 34.239691894000003)
43 self.assertAlmostEquals(region.lookAt_Lon, -120.03929305)
44
46 """
47 test views.regionLookAtKml
48 """
49 response = self.client.get('/studyregion/lookAtKml/', {})
50 self.assertEquals(response.status_code, 200)
51
52
53
54
55
56
57
58
59
61 """
62 test views.kml
63 """
64 response = self.client.get('/studyregion/kml/', {})
65 self.assertEquals(response.status_code, 200)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
81 settings.DEBUG = True
82 response = self.client.get('/media/studyregion/styles.kml', {})
83 self.assertEquals(response.status_code, 200)
84
94