Compare commits
No commits in common. "12881d934508300fc54fdc65a033983d1de1c18a" and "1a8da002cf4ba19b8b225d045ef4f9688edfa87d" have entirely different histories.
12881d9345
...
1a8da002cf
@ -54,7 +54,7 @@ class Taggable(models.Model):
|
|||||||
|
|
||||||
tags = TaggableManager(blank=True)
|
tags = TaggableManager(blank=True)
|
||||||
|
|
||||||
class Mapable(models.Model):
|
class MapablePoint(models.Model):
|
||||||
'''
|
'''
|
||||||
This abstract model class represents an object that can be
|
This abstract model class represents an object that can be
|
||||||
displayed on a map.
|
displayed on a map.
|
||||||
@ -109,7 +109,7 @@ class Voucher(models.Model):
|
|||||||
return "Voucher " + str(self.code)
|
return "Voucher " + str(self.code)
|
||||||
|
|
||||||
|
|
||||||
class Place(Submittable, Taggable, Mapable):
|
class Place(Submittable, Taggable, MapablePoint):
|
||||||
"""
|
"""
|
||||||
Place defines a lost place (location, name, description etc.).
|
Place defines a lost place (location, name, description etc.).
|
||||||
"""
|
"""
|
||||||
|
@ -6,7 +6,7 @@ from django.contrib.auth.models import User
|
|||||||
|
|
||||||
from lostplaces_app.models import (
|
from lostplaces_app.models import (
|
||||||
Taggable,
|
Taggable,
|
||||||
Mapable,
|
MapablePoint,
|
||||||
Submittable
|
Submittable
|
||||||
)
|
)
|
||||||
from lostplaces_app.tests.models import ModelTestCase
|
from lostplaces_app.tests.models import ModelTestCase
|
||||||
@ -22,9 +22,9 @@ class TaggableTestCase(ModelTestCase):
|
|||||||
self.assertField('tags', TaggableManager)
|
self.assertField('tags', TaggableManager)
|
||||||
|
|
||||||
|
|
||||||
class MapableTestCase(ModelTestCase):
|
class MapablePointTestCase(ModelTestCase):
|
||||||
|
|
||||||
model = Mapable
|
model = MapablePoint
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self):
|
||||||
self.assertCharField(
|
self.assertCharField(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from lostplaces_app.models import Taggable, Mapable
|
from lostplaces_app.models import Taggable, MapablePoint
|
||||||
|
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class ViewTestCase(TestCase):
|
|||||||
'''
|
'''
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.status_code, code,
|
response.status_code, code,
|
||||||
msg='Expecting an HTTP %s response, but got HTTP %s' % (
|
"Expected an HTTP %s response, but got HTTP %s" % (
|
||||||
code,
|
code,
|
||||||
response.status_code
|
response.status_code
|
||||||
)
|
)
|
||||||
@ -165,9 +165,9 @@ class TaggableViewTestCaseMixin:
|
|||||||
msg='Expecting delete_url_name to be of type string'
|
msg='Expecting delete_url_name to be of type string'
|
||||||
)
|
)
|
||||||
|
|
||||||
class MapableViewTestCaseMixin:
|
class MapablePointViewTestCaseMixin:
|
||||||
|
|
||||||
def assertMapableContext(self, context):
|
def assertMapablePointContext(self, context):
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'all_points' in context,
|
'all_points' in context,
|
||||||
msg='Expecting the context for mapable point to contain \'all_points\' attribute'
|
msg='Expecting the context for mapable point to contain \'all_points\' attribute'
|
||||||
@ -175,9 +175,9 @@ class MapableViewTestCaseMixin:
|
|||||||
|
|
||||||
for point in context['all_points']:
|
for point in context['all_points']:
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
isinstance(point, Mapable),
|
isinstance(point, MapablePoint),
|
||||||
msg='Expecting all entries to be an instance of %s, got %s' % (
|
msg='Expecting all entries to be an instance of %s, got %s' % (
|
||||||
str(Mapable),
|
str(MapablePoint),
|
||||||
str(type(point))
|
str(type(point))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,7 @@ from lostplaces_app.forms import PlaceImageCreateForm, PlaceForm
|
|||||||
from lostplaces_app.tests.views import (
|
from lostplaces_app.tests.views import (
|
||||||
ViewTestCase,
|
ViewTestCase,
|
||||||
TaggableViewTestCaseMixin,
|
TaggableViewTestCaseMixin,
|
||||||
MapableViewTestCaseMixin
|
MapablePointViewTestCaseMixin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class TestPlaceListView(ViewTestCase):
|
|||||||
self.assertContext(response, 'mapping_config')
|
self.assertContext(response, 'mapping_config')
|
||||||
|
|
||||||
|
|
||||||
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapablePointViewTestCaseMixin, ViewTestCase):
|
||||||
view = PlaceDetailView
|
view = PlaceDetailView
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -123,4 +123,4 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
|||||||
str(self.view)
|
str(self.view)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.assertMapableContext(response.context['mapping_config'])
|
self.assertMapablePointContext(response.context['mapping_config'])
|
||||||
|
Loading…
Reference in New Issue
Block a user