Fakultas Ilmu Komputer UI

Commit af51da87 authored by JONATHAN EDWIN's avatar JONATHAN EDWIN
Browse files

Merge branch '1606891500-17' into 'master'

1606891500 - 17 (Menghandle input nomor telepon yang invalid)

See merge request !28
parents c3eb012d bcd0017c
Pipeline #21981 failed with stages
in 12 minutes and 59 seconds
No preview for this file type
......@@ -2,7 +2,7 @@ import os
import uuid
from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator
from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator
from django.db import models
from core.lib.validators import validate_document_file_extension, validate_image_file_extension, validate_npm
......@@ -55,7 +55,7 @@ class Student(models.Model):
user = models.OneToOneField(User)
npm = models.IntegerField(validators=[validate_npm], unique=True)
resume = models.FileField(upload_to=get_student_resume_file_path, null=True, blank=True, validators=[validate_document_file_extension])
phone_number = models.CharField(max_length=100, blank=True, db_index=True, null=True)
phone_number = models.CharField(max_length=12, blank=True, db_index=True, null=True, validators=[RegexValidator(r'^0\d{1,11}$')])
bookmarked_vacancies = models.ManyToManyField('core.Vacancy', related_name="bookmarked_vacancies", blank=True)
applied_vacancies = models.ManyToManyField('core.Vacancy', related_name="applied_vacancies",
blank=True, through='core.Application')
......
# __init__.py
from core.tests.test_accounts import LoginTests, RegisterTests
from core.tests.test_accounts import LoginTests, RegisterTests, ProfileUpdateTests
from core.tests.test_vacancies import ApplicationTests, BookmarkApplicationTests, CompanyListsTests
from core.tests.test_feedbacks import FeedbacksTests
......@@ -136,7 +136,7 @@ class ProfileUpdateTests(APITestCase):
"angkatan": "2017"
}]
}, status_code=200)
print("Hello World!")
url = '/api/login/'
response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'},
format='json')
......@@ -160,6 +160,10 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'email': 'saasdasd'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
url = '/api/students/' + str(student_id) + "/profile/"
response = self.client.patch(url, {'phone_number': '````'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
url = '/api/students/123123123/profile/'
response = self.client.patch(url, {'phone_number': '08123123123'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
......
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