Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Marc Feger
The Social Network
Commits
eb11b3c1
Commit
eb11b3c1
authored
Dec 07, 2021
by
Andreas Burbach
Browse files
add more tests
parent
0f5173d3
Pipeline
#76048
passed with stages
in 1 minute and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
social_network/the_social_network/tests.py
View file @
eb11b3c1
...
@@ -618,7 +618,7 @@ class TestGetStatementFeed(APITestCase):
...
@@ -618,7 +618,7 @@ class TestGetStatementFeed(APITestCase):
def
test_feed_contains_correct_data_pagination
(
self
):
def
test_feed_contains_correct_data_pagination
(
self
):
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
response
:
Response
=
self
.
client
.
get
(
path
=
"/contents/statements/feed/pagination/?page=1&size=
5
"
)
response
:
Response
=
self
.
client
.
get
(
path
=
"/contents/statements/feed/pagination/?page=1&size=
3
"
)
result
=
response
.
data
[
"data"
]
result
=
response
.
data
[
"data"
]
result_total
=
response
.
data
[
"total"
]
result_total
=
response
.
data
[
"total"
]
self
.
assertTrue
(
len
(
result
),
3
)
self
.
assertTrue
(
len
(
result
),
3
)
...
@@ -630,6 +630,22 @@ class TestGetStatementFeed(APITestCase):
...
@@ -630,6 +630,22 @@ class TestGetStatementFeed(APITestCase):
self
.
assertTrue
(
result
[
0
].
get
(
"created"
)
>
result
[
1
].
get
(
"created"
))
self
.
assertTrue
(
result
[
0
].
get
(
"created"
)
>
result
[
1
].
get
(
"created"
))
self
.
assertTrue
(
result
[
1
].
get
(
"id"
)
>
result
[
2
].
get
(
"id"
))
self
.
assertTrue
(
result
[
1
].
get
(
"id"
)
>
result
[
2
].
get
(
"id"
))
self
.
assertTrue
(
result
[
1
].
get
(
"created"
)
>
result
[
2
].
get
(
"created"
))
self
.
assertTrue
(
result
[
1
].
get
(
"created"
)
>
result
[
2
].
get
(
"created"
))
def
test_feed_load_over_size_pagination
(
self
):
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
response
:
Response
=
self
.
client
.
get
(
path
=
"/contents/statements/feed/pagination/?page=1&size=4"
)
result
=
response
.
data
[
"data"
]
result_total
=
response
.
data
[
"total"
]
self
.
assertTrue
(
len
(
result
),
3
)
self
.
assertTrue
(
result_total
,
3
)
def
test_feed_load_under_size_pagination
(
self
):
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
response
:
Response
=
self
.
client
.
get
(
path
=
"/contents/statements/feed/pagination/?page=1&size=2"
)
result
=
response
.
data
[
"data"
]
result_total
=
response
.
data
[
"total"
]
self
.
assertTrue
(
len
(
result
),
2
)
self
.
assertTrue
(
result_total
,
3
)
def
test_feed_contains_no_data_pagination
(
self
):
def
test_feed_contains_no_data_pagination
(
self
):
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
str
(
self
.
token_beate
))
...
...
social_network/the_social_network/views/contentViews.py
View file @
eb11b3c1
...
@@ -127,7 +127,7 @@ class ShowStatementFeedPagination(APIView):
...
@@ -127,7 +127,7 @@ class ShowStatementFeedPagination(APIView):
else
:
else
:
if
last
>=
total
:
if
last
>=
total
:
last
=
None
last
=
None
feed
=
feed
[
first
:
last
]
feed
=
feed
[
first
:
last
]
serializer
:
StatementSerializer
=
StatementSerializer
(
instance
=
feed
,
many
=
True
)
serializer
:
StatementSerializer
=
StatementSerializer
(
instance
=
feed
,
many
=
True
)
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
{
"data"
:
serializer
.
data
,
"total"
:
total
})
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
{
"data"
:
serializer
.
data
,
"total"
:
total
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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