#64 Testing place modes
This commit is contained in:
parent
c9d83dfc2c
commit
7a7c06882a
@ -242,6 +242,11 @@ class TestPlaceCreateView(ViewTestCase):
|
||||
'success',
|
||||
msg='Expecting a visible success message'
|
||||
)
|
||||
self.assertEqual(
|
||||
Place.objects.get(name='test place 486').mode,
|
||||
'live',
|
||||
msg='Expeting the place to be in \'live\' mode'
|
||||
)
|
||||
|
||||
def test_positive_image(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
@ -291,6 +296,11 @@ class TestPlaceCreateView(ViewTestCase):
|
||||
'success',
|
||||
msg='Expecting a visible success message'
|
||||
)
|
||||
self.assertEqual(
|
||||
Place.objects.get(name='test place 894').mode,
|
||||
'live',
|
||||
msg='Expeting the place to be in \'live\' mode'
|
||||
)
|
||||
|
||||
def test_negative_no_name(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
@ -396,6 +406,31 @@ class TestPlaceCreateView(ViewTestCase):
|
||||
msg='Expecing a visible error message'
|
||||
)
|
||||
|
||||
def test_positve_save_as_draft(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.post(
|
||||
reverse('place_create'),
|
||||
{
|
||||
'name': 'test name 6483',
|
||||
'location': 'wurstwasser',
|
||||
'latitude': 45.4654,
|
||||
'longitude': 68.135489,
|
||||
'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.
|
||||
""",
|
||||
'draft': True
|
||||
},
|
||||
follow=True
|
||||
)
|
||||
|
||||
self.assertHttpOK(response)
|
||||
self.assertEqual(
|
||||
Place.objects.get(name='test name 6483').mode,
|
||||
'draft',
|
||||
msg='Expeting the place to be in \'draft\' mode'
|
||||
)
|
||||
|
||||
|
||||
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
||||
view = PlaceDetailView
|
||||
|
||||
@ -449,6 +484,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
||||
self.client.login(username='blubberbernd', password='Develop123')
|
||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||
|
||||
self.assertHttpForbidden(response)
|
||||
self.assertFalse(
|
||||
'Im a place' in response.content.decode(),
|
||||
msg='Expecting the user to not see the places'
|
||||
@ -458,6 +494,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
||||
self.client.login(username='toor', password='Develop123')
|
||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||
|
||||
self.assertHttpOK(response)
|
||||
self.assertTrue(
|
||||
'Im a place' in response.content.decode(),
|
||||
msg='Expecting the superuser to see all places'
|
||||
@ -467,6 +504,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
||||
self.client.login(username='blubberbernd', password='Develop123')
|
||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 2}))
|
||||
|
||||
self.assertHttpOK(response)
|
||||
self.assertTrue(
|
||||
'Im a own place' in response.content.decode(),
|
||||
msg='Expecting the user to see it\'s own places'
|
||||
@ -476,6 +514,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 2}))
|
||||
|
||||
self.assertHttpOK(response)
|
||||
self.assertTrue(
|
||||
'Im a own place' in response.content.decode(),
|
||||
msg='Expecting the user to see places where their level is high enough'
|
||||
|
@ -113,6 +113,9 @@ class PlaceCreateView(MultiplePlaceImageUploadMixin, IsAuthenticatedMixin, View)
|
||||
place = place_form.save(commit=False)
|
||||
# Save logged in user as "submitted_by"
|
||||
place.submitted_by = submitter
|
||||
if place_form.cleaned_data['draft']:
|
||||
place.mode = 'draft';
|
||||
|
||||
place.save()
|
||||
|
||||
self.handle_place_images(request, place)
|
||||
|
Loading…
Reference in New Issue
Block a user