Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created April 17, 2013 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIII/cd554daf69a01f134c71 to your computer and use it in GitHub Desktop.
Save EdwardIII/cd554daf69a01f134c71 to your computer and use it in GitHub Desktop.
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
from django.contrib.auth.models import User
class ApiAccessTest(TestCase):
@override_settings(DEBUG=True)
def setUp(self):
pw = 'secret'
self.logged_in_user = User.objects.create(username='fakeuser@example.com', password=pw)
self.logged_in_user.save()
self.c = Client()
self.login_response = self.c.post('/account/login/', {'username': self.logged_in_user.username, 'password': pw})
@override_settings(DEBUG=True)
def test_logged_in_ok(self):
self.assertEquals(self.login_response.status_code, 200)
@override_settings(DEBUG=True)
def test_can_access_own_practices(self):
resp = self.c.get('/dashboard/api/v1/practice/?format=json')
self.assertEquals(resp.status_code, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment