Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andreas Rimolsrønning
tdt4242-base
Commits
fb04c43b
Commit
fb04c43b
authored
Apr 19, 2021
by
Einar Uvsløkk
Browse files
Clean up workout-detail test case
Add more assert statements, and remove unused code.
parent
ca4c23b6
Pipeline
#129564
passed with stage
in 1 minute and 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/secfit/workouts/tests/test_views.py
View file @
fb04c43b
...
...
@@ -192,6 +192,7 @@ class WorkoutDetailTest(APITestCase):
self
.
client
.
force_authenticate
(
self
.
user
)
workout
=
Workout
.
objects
.
get
(
pk
=
1
)
data
=
self
.
serialize
(
workout
)
self
.
assertEqual
(
len
(
data
[
"files"
]),
0
)
file_path
=
data_dir
/
"test-file.txt"
file_obj
=
SimpleUploadedFile
(
...
...
@@ -200,21 +201,9 @@ class WorkoutDetailTest(APITestCase):
content_type
=
"multipart/form-data"
,
)
data
[
"files"
].
append
(
dict
(
file
=
file_obj
))
dump_data
(
data
,
"Raw Payload Data"
)
self
.
assertEqual
(
len
(
data
[
"files"
]),
1
)
response
=
self
.
put
(
1
,
data
)
# XXX Alternative using the APIRequestFactory
# view = WorkoutDetail.as_view()
# request = self.factory.put(
# self.url(1), create_payload(data), format="multipart"
# )
# force_authenticate(request, self.user)
# response = view(request, pk=1)
dump_data
(
response
.
data
,
"Response data"
)
self
.
assertTrue
(
status
.
is_success
(
response
.
status_code
))
self
.
assertEqual
(
len
(
response
.
data
[
"files"
]),
len
(
data
[
"files"
]))
...
...
@@ -225,14 +214,3 @@ class WorkoutDetailTest(APITestCase):
self
.
assertTrue
(
status
.
is_success
(
response
.
status_code
))
workouts
=
Workout
.
objects
.
all
()
self
.
assertListEqual
(
list
(
workouts
),
list
())
def
dump_data
(
data
,
name
=
None
):
from
pprint
import
pprint
line
=
"-"
*
50
print
(
"
\n
"
+
line
)
if
name
:
print
(
name
)
pprint
(
data
)
print
(
line
+
"
\n
"
)
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