Fakultas Ilmu Komputer UI

Commit 3618cef0 authored by Joshua Casey's avatar Joshua Casey
Browse files

[#140654507] #15 #16 Revised documentation and added testing for register

parent 86332029
# __init__.py
from core.tests.test_accounts import LoginTests
from core.tests.test_accounts import LoginTests, RegisterTests
from core.tests.test_vacancies import ApplicationTests, BookmarkApplicationTests
......@@ -76,3 +76,20 @@ class LoginTests(APITestCase):
url = '/api/login/'
response = self.client.post(url, {'username': 'lalala', 'password': 'lalalala', 'login-type' : 'lalala'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
class RegisterTests(APITestCase):
def test_create_and_recreate(self):
url = '/api/register/'
tc_post = {'username': 'dummy.company', 'password': 'corporatepass', 'name':'tutuplapak', 'description':'menutup lapak', 'email': 'email@email.com'}
response = self.client.post(url, tc_post, format='multipart')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
response = self.client.post(url, tc_post, format='multipart')
self.assertEqual(response.status_code, status.HTTP_409_CONFLICT)
def test_bad_request(self):
url = '/api/register/'
response = self.client.post(url, {'username': 'lalala'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
......@@ -139,6 +139,39 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet):
parser_classes = (MultiPartParser, FormParser,)
def create(self, request):
"""
Create a new company user
---
parameters:
- name: username
description: username of the new account
required: true
type: string
- name: password
description: password of the new acoount
required: true
type: string
- name: email
description: email address of the new acoount
required: true
type: string
- name: name
description: the new company's name
required: true
type: string
- name: description
description: description of the new company
required: true
type: string
- name: logo
description: logo of the new company
required: false
type: image
- name: address
description: address of the new acoount
required: false
type: string
"""
username = request.data.get('username')
password = request.data.get('password')
email = request.data.get('email')
......
......@@ -40,7 +40,7 @@ class ApplicationViewSet(viewsets.GenericViewSet):
---
parameters:
- name: body
description: JSON object containing only one string: vacancy_id
description: JSON object containing an integer 'vacancy_id' and a string 'cover_letter'
required: true
type: string
paramType: body
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment