Last active
February 14, 2019 13:11
-
-
Save CryceTruly/128da5494e62cdd419548242ab02291e to your computer and use it in GitHub Desktop.
Simple DJANGO rest api test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from rest_framework.test import APIClient | |
class TestClass(): | |
def setUp(): | |
self.client = APIClient() | |
self.register_url=reverse('authentication:register') | |
def test_create_user(self): | |
"""Tests if a user can create an account""" | |
valid_register_data = { | |
'user': { | |
'email': '[email protected]', | |
'username': 'aquaman', | |
'password': 'testpass!XY' | |
} | |
response = self.client.post(self.register_url, | |
data=json.dumps( | |
valid_register_data), | |
content_type='application/json') | |
self.assertEqual(response.status_code, status.HTTP_201_CREATED) |
Author
CryceTruly
commented
Feb 14, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment