Fakultas Ilmu Komputer UI

Commit 2fd4c4e8 authored by Irwanto's avatar Irwanto
Browse files

[RED] Add creating account without auth token test

parent da6ce204
......@@ -35,6 +35,7 @@ class AccountViewTest(APITestCase):
cls.faker = Faker()
def setUp(self):
self.noAuthClient = APIClient()
self.client = APIClient(HTTP_AUTHORIZATION=HEADER_PREFIX + self.token_1.key)
def test_string_representation(self):
......@@ -138,6 +139,30 @@ class AccountViewTest(APITestCase):
f'"action_type":"{ACTIVITY_TYPE_CREATE}"', response_string
)
def test_create_new_officer_success_without_auth_token(self):
url = self.BASE_URL
_account_id = self.faker.email()
officer_prev_count = Account.objects.filter(is_admin=False).count()
data = {
"name": self.faker.name(),
"username": _account_id,
"password": "justpass",
"email": _account_id,
"phone_number": "+999999999999",
"area": self.faker.city(),
"is_admin": False,
"is_verified": False,
"is_active": False,
}
response = self.noAuthClient.post(path=url, data=data, format="json",)
officer_current_count = Account.objects.filter(is_admin=False).count()
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(officer_current_count, officer_prev_count + 1)
def test_create_existing_user_fails(self):
url = self.BASE_URL
data = {
......
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