Fakultas Ilmu Komputer UI

Commit 85eab5ae authored by Bimo Iman Smartadi's avatar Bimo Iman Smartadi
Browse files

[GREEN] Added more test that is already passed on like dislike

parent 4b752b0f
Pipeline #44744 passed with stages
in 6 minutes
......@@ -70,8 +70,9 @@ class FasilitasRelatedViewTest(InformasiFasilitasViewTest):
def test_cannot_post_detail_fasilitas(self):
fasilitas = self.create_fasilitas_test()
response = Client().post(reverse('detail-fasilitas', kwargs={'nama_lokasi': self.default_lokasi_name,
'id': fasilitas.id}))
response = Client().post(reverse('detail-fasilitas',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': fasilitas.id}))
self.assertEqual(response.status_code, HTTPStatus.METHOD_NOT_ALLOWED)
def test_get_detail_fasilitas_not_found(self):
......
......@@ -62,3 +62,19 @@ class KomentarRelatedViewTest(InformasiFasilitasViewTest):
response_json = json.loads(response.content.decode('utf-8'))
expected_json = {"response": "Bad Request. 'deskripsi' key is needed"}
self.assertEqual(expected_json, response_json)
def test_get_list_komentar(self):
client = self.client_user_token()
self.create_fasilitas_test()
urls = reverse('add-komentar',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
})
comment_data = {"deskripsi": "halo saya komen"}
client.post(urls, comment_data)
urls_get = reverse('list-komentar',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
})
response = client.get(urls_get)
self.assertEqual(response.status_code, HTTPStatus.OK)
......@@ -78,6 +78,25 @@ class LikeDislikeRelatedViewTest(InformasiFasilitasViewTest):
count = Likes.objects.filter(fasilitas=fasilitas).count()
self.assertEqual(count, 1)
def test_like_dislike_facility_count_like(self):
client = self.client_user_token()
fasilitas = self.create_fasilitas_test()
urls_like = reverse('update-like-fasilitas',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
'operation': "like"
})
urls_dislike = reverse('update-like-fasilitas',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
'operation': "dislike"
})
client.put(urls_like)
client.put(urls_dislike) # like and dislike
count = Likes.objects.filter(fasilitas=fasilitas).count()
self.assertEqual(count, 0)
def test_can_dislike_facility(self):
client = self.client_user_token()
fasilitas = self.create_fasilitas_test()
......@@ -139,3 +158,23 @@ class LikeDislikeRelatedViewTest(InformasiFasilitasViewTest):
client.put(urls) # Dislike and dislike
count = Dislikes.objects.filter(fasilitas=fasilitas).count()
self.assertEqual(count, 1)
def test_dislike_like_facility_count_dislike(self):
client = self.client_user_token()
fasilitas = self.create_fasilitas_test()
urls_like = reverse('update-like-fasilitas',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
'operation': "like"
})
urls_dislike = reverse('update-like-fasilitas',
kwargs={'nama_lokasi': self.default_lokasi_name,
'id': 1,
'operation': "dislike"
})
client.put(urls_dislike)
client.put(urls_like)
count = Dislikes.objects.filter(fasilitas=fasilitas).count()
self.assertEqual(count, 0)
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