def test_context_data(self): # Setup request and view queryset = UserService.objects.all() request = self.factory.get('/') request.user = self.user view = UserServiceListView( template_name='services/services.html', context_object_name="services_list", object_list=queryset) view = setup_view(view, request) context = view.get_context_data() if request.user.is_authenticated(): nb_user_service = nb_service = 20 context, action = self.get_action_context(context, nb_user_service, nb_service) self.assertEqual(context['action'], action) nb_user_service = 19 nb_service = 20 context, action = self.get_action_context(context, nb_user_service, nb_service) self.assertEqual(context['action'], action)
def test_context_data(self): # Setup request and view queryset = UserService.objects.all() request = self.factory.get(reverse('user_services')) request.user = self.user response = UserServiceListView.as_view()(request) self.assertEqual(response.status_code, 200) view = UserServiceListView(template_name='services/services.html', context_object_name="services_list", object_list=queryset) view = setup_view(view, request) context = view.get_context_data() self.assertIn('service_list_remaining', context)
def test_context_data(self): # Setup request and view queryset = UserService.objects.all() request = self.factory.get(reverse('user_services')) request.user = self.user response = UserServiceListView.as_view()(request) self.assertEqual(response.status_code, 200) view = UserServiceListView( template_name='services/services.html', context_object_name="services_list", object_list=queryset) view = setup_view(view, request) context = view.get_context_data() self.assertIn('service_list_remaining', context)