def test_list_should_have_some_perms_in_context(self): view = TouristicEventList() view.object_list = [] view.request = RequestFactory().get('/fake-path') view.request.user = self.user context = view.get_context_data() self.assertEqual(context['can_add'], True) self.assertEqual(context['can_export'], False)
def test_list_should_render_some_perms_in_template(self): request = RequestFactory().get('/fake-path') request.user = self.user request.session = {} view = TouristicEventList.as_view() response = view(request) html = response.render() self.assertTrue(b'btn-group disabled' in html.content) self.assertTrue(b'Add a new touristic event</a>' in html.content)
def test_views_name_depend_on_model(self): view = TouristicEventList() self.assertEqual(view.get_view_perm(), 'tourism.read_touristicevent')
def test_mapentity_template_is_last_candidate(self): listview = TouristicEventList() listview.object_list = TouristicEvent.objects.none() self.assertEqual(listview.get_template_names()[-1], 'mapentity/mapentity_list.html')