Compare commits
No commits in common. "51addd8fbb5c5e0165843a32b1f2260a378649a4" and "4f465b3162b740576dd257db95da97a361ef6b8f" have entirely different histories.
51addd8fbb
...
4f465b3162
@ -28,6 +28,6 @@ from lostplaces.views import SignUpView
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('signup/', SignUpView.as_view(), name='signup'),
|
path('signup/', SignUpView.as_view(), name='signup'),
|
||||||
path('explorer/', include('django.contrib.auth.urls')),
|
path('explorers/', include('django.contrib.auth.urls')),
|
||||||
path('', include('lostplaces.urls')),
|
path('', include('lostplaces.urls')),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{{config.submit_url}}">
|
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{% url config.submit_url_name tagged_id=config.tagged_item.id%}">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">{% translate 'Add tags' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Add tags' %}</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
@ -17,20 +17,6 @@ class ViewTestCase(TestCase):
|
|||||||
'''
|
'''
|
||||||
view = None
|
view = None
|
||||||
|
|
||||||
def assertMessage(self, response, message_text, message_type, msg=None):
|
|
||||||
self.assertNotEqual(
|
|
||||||
None,
|
|
||||||
re.search(
|
|
||||||
"""<div.*message.*%s.*>.*%s.*</div>""" % (
|
|
||||||
message_type.lower(),
|
|
||||||
message_text.lower()
|
|
||||||
),
|
|
||||||
response.content.decode().replace('\n', '').lower()
|
|
||||||
),
|
|
||||||
msg
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def assertContext(self, response, key, value=None):
|
def assertContext(self, response, key, value=None):
|
||||||
'''
|
'''
|
||||||
Checks weather the response's context has the given key
|
Checks weather the response's context has the given key
|
||||||
|
@ -9,7 +9,6 @@ from django.urls import reverse
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
|
|
||||||
|
|
||||||
from lostplaces.models import Place
|
from lostplaces.models import Place
|
||||||
@ -100,7 +99,7 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse('place_create'),
|
reverse('place_create'),
|
||||||
data={
|
{
|
||||||
'name': 'test place 486',
|
'name': 'test place 486',
|
||||||
'location': 'test location',
|
'location': 'test location',
|
||||||
'latitude': 45.804192,
|
'latitude': 45.804192,
|
||||||
@ -108,27 +107,23 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
'description': """
|
'description': """
|
||||||
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
"""
|
"""
|
||||||
},
|
}
|
||||||
follow=True
|
|
||||||
)
|
)
|
||||||
self.assertHttpOK(response)
|
self.assertHttpRedirect(response)
|
||||||
place = Place.objects.get(name='test place 486')
|
place = Place.objects.get(name='test place 486')
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
None,
|
None,
|
||||||
place,
|
place,
|
||||||
msg='Submitted place not found in database / model'
|
msg='Submitted place not found in database / model'
|
||||||
),
|
),
|
||||||
self.assertEqual(
|
self.assertNotEqual(
|
||||||
reverse(
|
None,
|
||||||
|
re.search(
|
||||||
|
""".*%s""" % reverse(
|
||||||
'place_detail', kwargs={'pk': place.id}
|
'place_detail', kwargs={'pk': place.id}
|
||||||
),
|
),
|
||||||
response.redirect_chain[-1][0]
|
response.url
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Successfully created place'),
|
|
||||||
'success',
|
|
||||||
msg='Expecting a visible success message'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_positive_image(self):
|
def test_positive_image(self):
|
||||||
@ -143,7 +138,7 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse('place_create'),
|
reverse('place_create'),
|
||||||
data={
|
{
|
||||||
'name': 'test place 894',
|
'name': 'test place 894',
|
||||||
'location': 'test location',
|
'location': 'test location',
|
||||||
'latitude': 45.804192,
|
'latitude': 45.804192,
|
||||||
@ -152,33 +147,29 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
""",
|
""",
|
||||||
'filename': [image]
|
'filename': [image]
|
||||||
},
|
}
|
||||||
follow=True
|
|
||||||
)
|
)
|
||||||
self.assertHttpOK(response)
|
self.assertHttpRedirect(response)
|
||||||
place = Place.objects.get(name='test place 894')
|
place = Place.objects.get(name='test place 894')
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
None,
|
None,
|
||||||
place,
|
place,
|
||||||
msg='Submitted place not found in database / model'
|
msg='Submitted place not found in database / model'
|
||||||
),
|
),
|
||||||
self.assertEqual(
|
self.assertNotEqual(
|
||||||
reverse(
|
None,
|
||||||
|
re.search(
|
||||||
|
""".*%s""" % reverse(
|
||||||
'place_detail', kwargs={'pk': place.id}
|
'place_detail', kwargs={'pk': place.id}
|
||||||
),
|
),
|
||||||
response.redirect_chain[-1][0]
|
response.url
|
||||||
|
)
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(place.placeimages.all()),
|
len(place.placeimages.all()),
|
||||||
1,
|
1,
|
||||||
msg='Expecting the place to have exactly 1 place image'
|
msg='Expecting the place to have exactly 1 place image'
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Successfully created place'),
|
|
||||||
'success',
|
|
||||||
msg='Expecting a visible success message'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_negative_no_name(self):
|
def test_negative_no_name(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
@ -199,12 +190,6 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
0,
|
0,
|
||||||
msg='Expecting no place to be created'
|
msg='Expecting no place to be created'
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Please fill in all required fields.'),
|
|
||||||
'error',
|
|
||||||
msg='Expecing a visible error message'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_negative_no_location(self):
|
def test_negative_no_location(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
@ -225,12 +210,6 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
0,
|
0,
|
||||||
msg='Expecting no place to be created'
|
msg='Expecting no place to be created'
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Please fill in all required fields.'),
|
|
||||||
'error',
|
|
||||||
msg='Expecing a visible error message'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_negative_no_latitude(self):
|
def test_negative_no_latitude(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
@ -251,12 +230,6 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
0,
|
0,
|
||||||
msg='Expecting no place to be created'
|
msg='Expecting no place to be created'
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Please fill in all required fields.'),
|
|
||||||
'error',
|
|
||||||
msg='Expecing a visible error message'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_negative_no_longitude(self):
|
def test_negative_no_longitude(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
@ -277,12 +250,6 @@ class TestPlaceCreateView(ViewTestCase):
|
|||||||
0,
|
0,
|
||||||
msg='Expecting no place to be created'
|
msg='Expecting no place to be created'
|
||||||
)
|
)
|
||||||
self.assertMessage(
|
|
||||||
response,
|
|
||||||
_('Please fill in all required fields.'),
|
|
||||||
'error',
|
|
||||||
msg='Expecing a visible error message'
|
|
||||||
)
|
|
||||||
|
|
||||||
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
||||||
view = PlaceDetailView
|
view = PlaceDetailView
|
||||||
@ -306,19 +273,6 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
|||||||
place.tags.add('I a tag', 'testlocation')
|
place.tags.add('I a tag', 'testlocation')
|
||||||
place.save()
|
place.save()
|
||||||
|
|
||||||
def test_not_authenticated(self):
|
|
||||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
|
||||||
self.assertHttpRedirect(response)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
'%s?next=%s' % (
|
|
||||||
reverse('login'),
|
|
||||||
reverse('place_detail', kwargs={'pk': 1})
|
|
||||||
),
|
|
||||||
response.url,
|
|
||||||
msg='Expecting unauthenticated user to be redirected to login page, using the \'next\' GET-Param to store the places details page'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_context(self):
|
def test_context(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
@ -50,7 +50,7 @@ class PlaceDetailView(IsAuthenticatedMixin, View):
|
|||||||
'all_tags': Tag.objects.all(),
|
'all_tags': Tag.objects.all(),
|
||||||
'submit_form': TagSubmitForm(),
|
'submit_form': TagSubmitForm(),
|
||||||
'tagged_item': place,
|
'tagged_item': place,
|
||||||
'submit_url': reverse('place_tag_submit', kwargs={'tagged_id': place.id}),
|
'submit_url_name': 'place_tag_submit',
|
||||||
'delete_url_name': 'place_tag_delete'
|
'delete_url_name': 'place_tag_delete'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user