diff --git a/app/tests.py b/app/tests.py index 2b65c523038a63a196033069604832b23b10bd92..b29a6b63e41e9b2053cee187576261cafe5c97da 100644 --- a/app/tests.py +++ b/app/tests.py @@ -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): diff --git a/app/views.py b/app/views.py index d204493a86f270c11059acfb7a7b9a35c2908081..576858cff10f62a4878ebd2de81ddbc1b6d4ad59 100644 --- a/app/views.py +++ b/app/views.py @@ -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