Package madrona :: Package heatmap :: Module tests
[hide private]

Source Code for Module madrona.heatmap.tests

 1  from django.test import TestCase 
 2  from madrona.features.tests import TestMpa, TestFolder 
 3  from django.contrib.auth.models import User 
 4  from django.core.urlresolvers import reverse 
 5  from madrona.common.utils import enable_sharing 
 6   
7 -class HeatmapTest(TestCase):
8 fixtures = ['example_data'] 9
10 - def setUp(self):
11 enable_sharing() 12 13 self.user1 = User.objects.create_user( 14 'user1', 'featuretest@madrona.org', password='pword') 15 self.user2 = User.objects.create_user( 16 'user2', 'othertest@madrona.org', password='pword') 17 18 self.mpa1 = TestMpa(user=self.user1, name="My Mpa") 19 self.mpa1.save() 20 self.folder1 = TestFolder(user=self.user1, name="My Folder") 21 self.folder1.save() 22 self.mpa1.add_to_collection(self.folder1) 23 24 self.tif_url = reverse("heatmap-collection-geotiff", kwargs={'collection_uids': self.folder1.uid}) 25 self.kmz_url = reverse("heatmap-collection-kmz", kwargs={'collection_uids': self.folder1.uid})
26
27 - def test_noauth(self):
28 response = self.client.get(self.tif_url) 29 self.assertEqual(response.status_code, 401) 30 31 self.client.login(username=self.user2.username, password='pword') 32 response = self.client.get(self.tif_url) 33 self.assertEqual(response.status_code, 403)
34
35 - def test_urls(self):
36 self.client.login(username=self.user1.username, password='pword') 37 response = self.client.get(self.tif_url) 38 self.assertEqual(response.status_code, 200) 39 40 response = self.client.get(self.kmz_url) 41 self.assertEqual(response.status_code, 200)
42