Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
6c14976f
Commit
6c14976f
authored
Oct 31, 2020
by
Bunga Amalia Kurniawati
🌺
Browse files
[RED] Add test to sort material by comment count
parent
c320f26c
Pipeline
#60109
failed with stages
in 18 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/tests.py
View file @
6c14976f
...
...
@@ -228,7 +228,48 @@ class DaftarKatalogSortingByJumlahTampilanTest(TestCase):
self
.
client
.
get
(
self
.
url
)
response
=
self
.
client
.
get
(
"/?sort=jumlah_tampilan"
)
self
.
assertRegex
(
str
(
response
.
content
),
rf
'.*Materi 2.*Materi 1.*'
)
class
DaftarKatalogSortingByJumlahKomentarTest
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
Client
()
self
.
contributor_credential
=
{
"email"
:
"kontributor@gov.id"
,
"password"
:
"passwordtest"
}
self
.
contributor_credential_2
=
{
"email"
:
"kontributor2@gov.id"
,
"password"
:
"passwordtest"
}
self
.
contributor
=
get_user_model
().
objects
.
create_user
(
**
self
.
contributor_credential
,
name
=
"Kontributor 1"
,
is_contributor
=
True
)
self
.
contributor2
=
get_user_model
().
objects
.
create_user
(
**
self
.
contributor_credential_2
,
name
=
"Kontributor 2"
,
is_contributor
=
True
)
self
.
cover
=
SimpleUploadedFile
(
"Cherprang_Areekul40_nJM9dGt.jpg"
,
b
"Test file"
)
self
.
content
=
SimpleUploadedFile
(
"Bahan_PA_RKK.pdf"
,
b
"Test file"
)
Materi
(
title
=
"Materi 1"
,
author
=
"Agas"
,
uploader
=
self
.
contributor
,
publisher
=
"Kelas SC"
,
descriptions
=
"Deskripsi Materi 1"
,
status
=
"APPROVE"
,
cover
=
self
.
cover
,
content
=
self
.
content
).
save
()
time
.
sleep
(
1
)
Materi
(
title
=
"Materi 2"
,
author
=
"Agas"
,
uploader
=
self
.
contributor
,
publisher
=
"Kelas SC"
,
descriptions
=
"Deskripsi Materi 2"
,
status
=
"APPROVE"
,
cover
=
self
.
cover
,
content
=
self
.
content
).
save
()
self
.
last_uploaded_material
=
Materi
.
objects
.
last
()
url
=
f
"/materi/
{
self
.
last_uploaded_material
.
id
}
/"
self
.
client
.
login
(
**
self
.
contributor_credential_2
)
self
.
client
.
post
(
url
,
{
"comment"
:
"This is new comment by Kontributor 2"
})
def
test_sorting_by_jumlah_komentar
(
self
):
response
=
self
.
client
.
get
(
"/?sort=jumlah_komentar"
)
self
.
assertRegex
(
str
(
response
.
content
),
rf
'.*Materi 2.*Materi 1.*'
)
class
DaftarKatalogPerKontributorTest
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
Client
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment