On Wednesday, December 2, 2015 at 10:48:52 PM UTC-8, Xavier Ordoquy wrote:
>
> Hi, 
>
> > Le 3 déc. 2015 à 00:12, learn django <siddhesh...@gmail.com 
> <javascript:>> a écrit : 
> > 
> > My app uses rest framework. 
> > I am writing test cases which involve standard requests like 
> GET/POST/DELETE/PUT. 
> > What is the best approach to write the test cases ? 
>
> Django REST framework comes with a test client named APIClient. 
> It will go through the middleware and urls before calling your API entry 
> points which seems to be what you’re looking for. 
> The documentation about it is available at 
> http://www.django-rest-framework.org/api-guide/testing/#apiclient 
>
> Regards, 
> Xavier, 
> Linovia. 
>
>
Hi Linovia,

Yes, I started with that.
Initially I was getting 403 (auth failure) since my backend handlers have 
@login_required decorator.

To overcome that i created a super user (python manage.py superuser) &
used those credentials as below.

        # url = '/orca/api/v2/customer/'
        # data = {'c_name':'Pnc', 'c_role':'API-Admin'}
        # client = APIClient()
        # client.login(username='admin', password='admin')
        # response = client.post(url, data, format='json') 

After this I started was getting 302 (redirects).
Have you encountered similar issue before ?

-- 
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/d0dab1a9-6b99-462b-911e-f098a4aea79e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to