Fakultas Ilmu Komputer UI

Commit e1abf1fe authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[RED] Add test for phone and email validator

parent 1dcd8cfe
Pipeline #46119 failed with stages
in 16 minutes and 59 seconds
......@@ -25,7 +25,7 @@ class AccountFactory(factory.DjangoModelFactory):
user = factory.SubFactory(UserFactory)
name = faker.name()
email = faker.email()
phone_number = faker.phone_number()
phone_number = "+999999999999"
area = faker.city()
is_active = True
is_verified = True
......@@ -88,7 +88,7 @@ class AccountViewTest(APITestCase):
"username": _account_id,
"password": "justpass",
"email": _account_id,
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": True,
}
......@@ -110,7 +110,7 @@ class AccountViewTest(APITestCase):
"username": _account_id,
"password": "justpass",
"email": _account_id,
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": True,
......@@ -145,7 +145,7 @@ class AccountViewTest(APITestCase):
"username": "user_1",
"password": "justpass",
"email": self.faker.email(),
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": True,
......@@ -163,21 +163,21 @@ class AccountViewTest(APITestCase):
"email": _account_id,
"username": _account_id,
"password": "12345678",
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
}
response = self.client.post(path=url, data=data, format="json",)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_edit_account_success_by(self):
def test_edit_account_success(self):
url = self.BASE_URL + str(self.officer.id) + "/"
data = {
"id": str(self.officer.id),
"name": self.faker.name(),
"email": self.faker.email(),
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": True,
......@@ -213,13 +213,43 @@ class AccountViewTest(APITestCase):
data = {
"id": str(self.officer.id),
"phone_number": self.faker.phone_number(),
"phone_number": "+999999999999",
"area": self.faker.city(),
}
response = self.client.put(path=url, data=data, format="json",)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_edit_account_fail_with_wrong_email_or_phone_format(self):
url = self.BASE_URL + str(self.officer.id) + "/"
data = {
"id": str(self.officer.id),
"name": self.faker.name(),
"email": self.faker.email(),
"phone_number": "+999aaa999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": True,
"is_active": True,
}
response = self.client.put(path=url, data=data, format="json",)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
data = {
"id": str(self.officer.id),
"name": self.faker.name(),
"email": "email",
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": True,
"is_active": True,
}
response = self.client.put(path=url, data=data, format="json",)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_delete_success(self):
url = self.BASE_URL + str(self.officer.id) + "/"
......
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