Compare commits

..

No commits in common. "ab669b9f5e591f0b266deb92feb16592d93ed8b9" and "51addd8fbb5c5e0165843a32b1f2260a378649a4" have entirely different histories.

2 changed files with 5 additions and 148 deletions

View File

@ -242,13 +242,13 @@ class TaggableViewTestCaseMixin:
)
self.assertTrue(
'submit_url' in context,
msg='Expecting the context for taggable to contain \'submit_url\' attribute'
'submit_url_name' in context,
msg='Expecting the context for taggable to contain \'submit_url_name\' attribute'
)
self.assertTrue(
type(context['submit_url']) == str,
msg='Expecting submit_url to be of type string'
type(context['submit_url_name']) == str,
msg='Expecting submit_url_name to be of type string'
)
self.assertTrue(

View File

@ -48,7 +48,7 @@ class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
location='Test %d town' % i,
latitude=50.5 + i/10,
longitude=7.0 - i/10,
description='This is just a test, do not worry %d' % i
description='This is just a test, do not worry'
)
place.tags.add('I a tag', 'testlocation')
place.save()
@ -63,21 +63,6 @@ class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
self.assertContext(response, 'mapping_config')
self.assertGlobal(response)
def test_first_places(self):
self.client.login(username='testpeter', password='Develop123')
response = self.client.get(reverse('place_list'))
for i in range(1, 4):
place = Place.objects.get(id=i)
self.assertTrue(
place.name in response.content.decode(),
msg='Expecting the %dth place name to be on the first page of list' % i
)
self.assertTrue(
place.description in response.content.decode(),
msg='Expecting the %dth place description to be on the first page of list' % i
)
def test_pagination(self):
self.client.login(username='testpeter', password='Develop123')
response = self.client.get(reverse('place_list'))
@ -353,131 +338,3 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
)
)
self.assertMapableContext(response.context['mapping_config'])
def test_place_data(self):
self.client.login(username='testpeter', password='Develop123')
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
place = Place.objects.get(id=1)
self.assertTrue(
place.name in response.content.decode(),
msg='Expecting the places name to be on the page'
)
self.assertTrue(
place.description in response.content.decode(),
msg='Expecting the places description to be on the page'
)
self.assertTrue(
str(place.latitude) in response.content.decode(),
msg='Expecting the places latitude to be on the page'
)
self.assertTrue(
str(place.longitude) in response.content.decode(),
msg='Expecting the places longitude to be on the page'
)
def test_favorite(self):
self.client.login(username='testpeter', password='Develop123')
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
user = User.objects.get(username='testpeter')
place = Place.objects.get(id=1)
self.assertTrue(
reverse('place_favorite', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) create favorite url to be on the page '
)
response = self.client.get(
reverse('place_favorite', kwargs={'place_id': 1}),
follow=True
)
self.assertHttpOK(response)
self.assertTrue(
reverse('place_unfavorite', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) delete favorite url to be on the page '
)
self.assertTrue(
place in user.explorer.favorite_places.all(),
msg='Expecting the place to be in the explorers favorites'
)
self.assertTrue(
user.explorer in place.explorer_favorites.all(),
msg='Expecting the explorere to be in the reverse list of favorites'
)
response = self.client.get(
reverse('place_unfavorite', kwargs={'place_id': 1}),
follow=True
)
self.assertHttpOK(response)
self.assertTrue(
reverse('place_favorite', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) create favorite url to be on the page after unfavorite'
)
self.assertTrue(
place not in user.explorer.favorite_places.all(),
msg='Expecting the place to not be in the explorers favorites after unfavorite'
)
self.assertTrue(
user.explorer not in place.explorer_favorites.all(),
msg='Expecting the explorere to not be in the reverse list of favorites after unfavorite'
)
def test_visit(self):
self.client.login(username='testpeter', password='Develop123')
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
user = User.objects.get(username='testpeter')
place = Place.objects.get(id=1)
self.assertTrue(
reverse('place_visit_create', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) create visit url to be on the page '
)
response = self.client.get(
reverse('place_visit_create', kwargs={'place_id': 1}),
follow=True
)
self.assertHttpOK(response)
self.assertTrue(
reverse('place_visit_delete', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) delete visist url to be on the page '
)
self.assertTrue(
place in user.explorer.visited_places.all(),
msg='Expecting the place to be in the explorers visits'
)
self.assertTrue(
user.explorer in place.explorer_visits.all(),
msg='Expecting the explorer to be in the reverse list of visits'
)
response = self.client.get(
reverse('place_visit_delete', kwargs={'place_id': 1}),
follow=True
)
self.assertHttpOK(response)
self.assertTrue(
reverse('place_visit_create', kwargs={'place_id': 1}) in response.content.decode(),
msg='Expecting the (right) create favorite url to be on the page after deleting visit'
)
self.assertTrue(
place not in user.explorer.visited_places.all(),
msg='Expecting the place to not be in the explorers visits after deleting visit'
)
self.assertTrue(
user.explorer not in place.explorer_visits.all(),
msg='Expecting the explorer to not be in the reverse list of visits after deleting visit'
)