Fakultas Ilmu Komputer UI

Commit 1537444c authored by Fakhira Devina's avatar Fakhira Devina
Browse files

Merge branch 'dev-ariq' into 'PBI-2-deployment'

remove repeated code at base test, make more general method

See merge request !7
parents 817060dd 4b527286
Pipeline #64729 passed with stages
in 18 minutes and 44 seconds
......@@ -141,29 +141,26 @@ class InformasiFasilitasTest(TestCase):
dislike_test.save()
return dislike_test
def client_user_token(self):
Client().post(REGISTER, self.user_post)
test_user = User.objects.get(username=self.user_post["email"])
def get_client_from_user(self, user_dict):
Client().post(REGISTER, user_dict)
test_user = User.objects.get(username=user_dict['email'])
test_user.is_active = True
test_user.save()
token_response = Client().post(TOKEN_AUTH, {'username': self.user_post["email"],
'password': self.user_post["password"]})
token_response = Client().post(TOKEN_AUTH, {'username': user_dict["email"],
'password': user_dict["password"]})
content = json.loads(token_response.content.decode('utf-8'))
token = content['token']
client = Client(HTTP_AUTHORIZATION=TOKEN_SUFFIX+token)
return client
def client_user_token(self):
return self.get_client_from_user(self.user_post)
def client_user_token2(self):
Client().post(REGISTER, self.user_post)
test_user = User.objects.get(username=self.default_username_email)
test_user.is_active = True
test_user.save()
token_response = Client().post(TOKEN_AUTH, {'username': self.default_username_email,
'password': self.default_password})
content = json.loads(token_response.content.decode('utf-8'))
token = content['token']
client = Client(HTTP_AUTHORIZATION=TOKEN_SUFFIX+token)
return client
return self.get_client_from_user({'name': self.default_username_email,
'email': self.default_username_email,
'phone_number': self.default_no_telp,
'password': self.default_password})
class InformasiFasilitasViewTest(InformasiFasilitasTest):
......
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