143
143
reverse('wlmaps_view', args=('a-map-that-doesnt-exist',)))
144
144
self.assertEqual(c.status_code, 404)
150
class TestWLMapsViews_Rating(_LoginToSite):
153
_LoginToSite.setUp(self)
156
nm = Map.objects.create(
162
descr='a good map to play with',
163
minimap='/wlmaps/minimaps/Map.png',
164
world_name='blackland',
167
uploader_comment='Rockdamap'
172
def test_RatingNonExistingMap_Except404(self):
173
c = self.client.post(
174
reverse('wlmaps_rate', args=('a-map-that-doesnt-exist',)),
176
self.assertEqual(c.status_code, 404)
178
def test_RatingGet_Except405(self):
180
reverse('wlmaps_rate', args=('map',)),
182
self.assertEqual(c.status_code, 405)
184
def test_RatingInvalidValue_Except400(self):
185
c = self.client.post(
186
reverse('wlmaps_rate', args=('map',)),
188
self.assertEqual(c.status_code, 400)
190
def test_RatingNonIntegerValue_Except400(self):
191
c = self.client.post(
192
reverse('wlmaps_rate', args=('map',)),
194
self.assertEqual(c.status_code, 400)
196
def test_RatingExistingMap_ExceptCorrectResult(self):
197
c = self.client.post(
198
reverse('wlmaps_rate', args=('map',)),
201
self.assertEqual(c.status_code, 302)
203
# We have to refetch this map, because
204
# votes doesn't hit the database
205
m = Map.objects.get(slug='map')
207
self.assertEqual(m.rating.votes, 1)
208
self.assertEqual(m.rating.score, 7)