Fakultas Ilmu Komputer UI

Commit fd8d7bd0 authored by Ahmad Fauzan Amirul Isnain's avatar Ahmad Fauzan Amirul Isnain
Browse files

[#117] Bugfix: Error On Detail Materi Page

parent 4a7c10fe
......@@ -35,6 +35,11 @@ from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
from app.forms import SuntingProfilForm
from app.utils.fileManagementUtil import get_random_filename, remove_image_exifdata
from datetime import datetime
import pandas as pd
class DaftarKatalogTest(TestCase):
def test_daftar_katalog_url_exist(self):
url = "/"
......@@ -146,6 +151,16 @@ class DetailMateriTest(TestCase):
self.materi1 = Materi.objects.first()
self.url = "/materi/" + str(self.materi1.id) + "/"
self.materi_with_published_date = Materi.objects.create(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="APPROVE", cover=self.cover, content=self.content,
date_modified=datetime.now(), date_created=datetime.now())
self.materi_with_published_date_url = "/materi/" + str(self.materi_with_published_date.id) + "/"
VerificationReport.objects.create(report='{"feedback": "Something", "kriteria": [{"title": "Kriteria 1", "status": true},' + \
' {"title": "Kriteria 2", "status": true}, {"title": "Kriteria 3", "status": true}]}', \
timestamp="2020-10-09 06:21:33", status="Diterima", materi= self.materi_with_published_date, \
user=self.materi_with_published_date.uploader)
def test_detail_materi_url_exist(self):
response = Client().get(self.url)
self.assertEqual(response.status_code, 200)
......@@ -232,17 +247,28 @@ class DetailMateriTest(TestCase):
response = self.client.get(self.url)
self.assertContains(response, 'Citate APA')
def test_hasil_citasi_APA(self):
def test_hasil_citasi_APA_materi_has_no_published_date(self):
response = self.client.get(self.url)
publishedDate = ''
if(self.materi1.published_date == None):
publishedDate = 'n.d'
else :
publishedDate = self.materi1.published_date
expected = self.materi1.author+' . (' + publishedDate +') . ' + self.materi1.title +' . '+ self.materi1.publisher
expected = self.materi1.author + \
' . (n.d) . ' + \
self.materi1.title + \
' . ' + \
self.materi1.publisher
self.assertIn(expected,
response.context["citationAPA"])
def test_hasil_citasi_APA_materi_has_published_date(self):
response = self.client.get(self.materi_with_published_date_url)
published_date = self.materi_with_published_date.published_date.strftime('%Y-%m-%d %H:%M')
expected = self.materi_with_published_date.author + \
' . (' + \
published_date + \
') . ' + \
self.materi_with_published_date.title + \
' . ' + \
self.materi_with_published_date.publisher
self.assertIn(expected,
response.context["citationAPA"])
class PostsViewTest(TestCase):
......
......@@ -126,7 +126,7 @@ class DetailMateri(TemplateView):
if(materi.published_date == None):
publishedDate = 'n.d'
else :
publishedDate = materi.published_date
publishedDate = materi.published_date.strftime('%Y-%m-%d %H:%M')
citationAPA = materi.author+' . (' + publishedDate +') . ' + materi.title +' . '+materi.publisher
context["citationAPA"] = citationAPA
context['materi_rating_score'] = 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