#64 place mode and filtering of place modes in list views
This commit is contained in:
		@@ -13,6 +13,7 @@ from django.utils.translation import gettext as _
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from lostplaces.models import Place
 | 
			
		||||
from lostplaces.models import PLACE_MODES
 | 
			
		||||
from lostplaces.views import (
 | 
			
		||||
    PlaceCreateView,
 | 
			
		||||
    PlaceListView,
 | 
			
		||||
@@ -154,6 +155,38 @@ class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
 | 
			
		||||
            'Im a own place' in response.content.decode(),
 | 
			
		||||
            msg='Expecting the user to see places where their level is high enough'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_place_mode_filter(self):
 | 
			
		||||
        explorer = User.objects.get(username='testpeter').explorer
 | 
			
		||||
        Place.objects.all().delete()
 | 
			
		||||
 | 
			
		||||
        for mode in PLACE_MODES:
 | 
			
		||||
            place = Place.objects.create(
 | 
			
		||||
                name='Im a place in mode %s' % mode[0],
 | 
			
		||||
                submitted_when=timezone.now(),
 | 
			
		||||
                submitted_by=explorer,
 | 
			
		||||
                location='Test town',
 | 
			
		||||
                latitude=50.5,
 | 
			
		||||
                longitude=7.0,
 | 
			
		||||
                description='This is just a test, do not worry %s' % mode[0],
 | 
			
		||||
                level=3,
 | 
			
		||||
                mode=mode[0]
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        self.client.login(username='testpeter', password='Develop123')
 | 
			
		||||
        response = self.client.get(reverse('place_list'))
 | 
			
		||||
 | 
			
		||||
        for mode in PLACE_MODES:
 | 
			
		||||
            if ('Im a place in mode %s' % mode[0]) in response.content.decode():
 | 
			
		||||
                self.assertTrue(
 | 
			
		||||
                    mode[0] == 'live',
 | 
			
		||||
                    msg='Expecting only places in mode \'live\' to be listed, saw a place in mode %s' % mode[0]
 | 
			
		||||
                )
 | 
			
		||||
            elif mode[0] == 'live':
 | 
			
		||||
                self.fail(
 | 
			
		||||
                    msg='Expecting at least one place in mode \'live\' to be listed'
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
class TestPlaceCreateView(ViewTestCase):
 | 
			
		||||
    view = PlaceCreateView
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user