I want to test some views in DRF project. The problem comes when i try to check views that have arguments in the urls.
urls.py url(r'^(? < Pcompany_hash>[\d\w]+)/(? < Ptimestamp>[\.\d]*)/employees/$', EmployeeList.as_view(), name='employeelist'), views.py class EmployeeList(ListCreateAPIView): serializer_class = EmployeeDirectorySerializer def inner_company(self): company_hash = self.kwargs['company_hash'] return get_company(company_hash) def get_queryset(self): return Employee.objects.filter(company=self.inner_company()) test.py class ApiTests(APITestCase): def setUp(self): self.factory = APIRequestFactory() self.staff = mommy.make('directory.Employee', user__is_staff=True) self.employee = mommy.make('directory.Employee') self.hash = self.employee.company.company_hash def getResponse(self, url, myView): view = myView.as_view() request = self.factory.get(url, kwargs) force_authenticate(request, user=user) response = view(request) return response def test_EmployeeList(self): kwargs = {'timestamp': 0, 'company_hash': self.hash} url = reverse('employeelist', kwargs=kwargs) testedView = EmployeeList response = self.getResponse(url, testedView, kwargs=kwargs) self.assertEqual(response.status_code, 200) im getting this error company_hash = self.kwargs['company_hash'] KeyError: 'company_hash' That is the args aren't been passed to the view. I've tryed in so different ways to pass by the args, cant find a sollution. Any help is welcomed! This question has also been asked in Stackoverflow for if you preefer to answer there! http://stackoverflow.com/questions/31406106/how-can-i-correctly-pass-arguments-to-classbasedviews-testing-django-rest-framew -- *monoBOT* Visite mi sitio(Visit my site): monobotsoft.es/blog/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BxOsGAi8UxtXOV8HngqWXX6G31%2BfY7%3DDBCoYZk%3DToEed4eoHA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.