From 1e96df7c76f0e96175eeed62d345a2f42365b312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vegard=20Sporst=C3=B8l?= <vegarms@stud.ntnu.no> Date: Fri, 5 Mar 2021 11:23:49 +0100 Subject: [PATCH] inital test for user registration --- backend/secfit/users/tests.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/secfit/users/tests.py b/backend/secfit/users/tests.py index 7ce503c..da6ff2a 100644 --- a/backend/secfit/users/tests.py +++ b/backend/secfit/users/tests.py @@ -1,3 +1,23 @@ +import json + +from django.contrib.auth.models import User +from django.urls import reverse +from rest_framework import status +from rest_framework.authtoken.models import Token +from rest_framework.test import APITestCase + +from users.serializers import UserSerializer +from users.models import User + from django.test import TestCase -# Create your tests here. +class RegistrationTestCase(APITestCase): + + def test_registration(self): + data = {"username": "testcase", "email": "test@test.no", + "password": "strong_pwd", "password1": "strong_pwd", + "phone_number": "95080764", "country": "Norway", + "city": "Trondheim", "street_address": "Tors Veg 11C"} + response = self.client.post("/api/users/", data) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + -- GitLab