#42 Testing place level on place list
This commit is contained in:
parent
e11151858b
commit
4cd0635d5f
@ -37,9 +37,36 @@ class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123',
|
||||
)
|
||||
user.explorer.level = 3
|
||||
user.explorer.save()
|
||||
|
||||
# default level should be 1, not setting required
|
||||
other_user = User.objects.create_user(
|
||||
username='blubberbernd',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
superuser = User.objects.create_user(
|
||||
username='toor',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
superuser.is_superuser = True
|
||||
superuser.save()
|
||||
|
||||
Place.objects.create(
|
||||
name='Im a own place',
|
||||
submitted_when=timezone.now(),
|
||||
submitted_by=other_user.explorer,
|
||||
location='Test %d town' % 5,
|
||||
latitude=50.5 + 5/10,
|
||||
longitude=7.0 - 5/10,
|
||||
description='This is just a test, do not worry %d' % 5,
|
||||
level=3
|
||||
)
|
||||
|
||||
for i in range(12):
|
||||
place = Place.objects.create(
|
||||
name='Im a place %d' % i,
|
||||
@ -48,7 +75,8 @@ 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 %d' % i,
|
||||
level=3
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
@ -91,6 +119,33 @@ class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
|
||||
msg='Expecting the place list to be paginated like [first] [previous] [item] at least 2 times [next] [last]'
|
||||
)
|
||||
|
||||
def test_not_eligible_to_see_because_of_low_level(self):
|
||||
self.client.login(username='blubberbernd', password='Develop123')
|
||||
response = self.client.get(reverse('place_list'))
|
||||
|
||||
self.assertFalse(
|
||||
'Im a place' in response.content.decode(),
|
||||
msg='Expecting the user to not see any places'
|
||||
)
|
||||
|
||||
def test_not_eligible_to_see_because_of_low_level_superuser(self):
|
||||
self.client.login(username='toor', password='Develop123')
|
||||
response = self.client.get(reverse('place_list'))
|
||||
|
||||
self.assertTrue(
|
||||
'Im a place' in response.content.decode(),
|
||||
msg='Expecting the superuser to see all places'
|
||||
)
|
||||
|
||||
def test_not_eligible_to_see_because_of_low_level_own_place(self):
|
||||
self.client.login(username='blubberbernd', password='Develop123')
|
||||
response = self.client.get(reverse('place_list'))
|
||||
|
||||
self.assertTrue(
|
||||
'Im a own place' in response.content.decode(),
|
||||
msg='Expecting the user to see it\'s own places'
|
||||
)
|
||||
|
||||
class TestPlaceCreateView(ViewTestCase):
|
||||
view = PlaceCreateView
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user