Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-base-APU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tor Martin Frøberg Wang
tdt4242-base-APU
Commits
b576d8ca
Commit
b576d8ca
authored
4 years ago
by
Tobias Ørstad
Browse files
Options
Downloads
Patches
Plain Diff
Complete likes integration test
parent
b8eb64dc
No related branches found
No related tags found
3 merge requests
!18
Dev
,
!15
Dev
,
!14
Integrationtests
Pipeline
#114111
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/secfit/workouts/tests.py
+37
-2
37 additions, 2 deletions
backend/secfit/workouts/tests.py
with
37 additions
and
2 deletions
backend/secfit/workouts/tests.py
+
37
−
2
View file @
b576d8ca
...
@@ -576,7 +576,6 @@ class LeaderboardIntegrationTestCase(TestCase):
...
@@ -576,7 +576,6 @@ class LeaderboardIntegrationTestCase(TestCase):
self
.
client2
=
APIClient
()
self
.
client2
=
APIClient
()
self
.
client2
.
force_authenticate
(
user
=
self
.
user_2
)
self
.
client2
.
force_authenticate
(
user
=
self
.
user_2
)
self
.
client
.
post
(
'
http://testserver/api/exercises/
'
,
json
.
dumps
({
"
name
"
:
"
test
"
,
"
description
"
:
"
test
"
,
"
unit
"
:
"
kilos
"
}),
content_type
=
'
application/json
'
)
self
.
client
.
post
(
'
http://testserver/api/exercises/
'
,
json
.
dumps
({
"
name
"
:
"
test
"
,
"
description
"
:
"
test
"
,
"
unit
"
:
"
kilos
"
}),
content_type
=
'
application/json
'
)
self
.
exercise_object
=
{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}
def
test_user_is_on_leaderboard_no_workouts
(
self
):
def
test_user_is_on_leaderboard_no_workouts
(
self
):
...
@@ -683,3 +682,39 @@ class LikesIntegrationTestCase(TestCase):
...
@@ -683,3 +682,39 @@ class LikesIntegrationTestCase(TestCase):
self
.
client2
.
force_authenticate
(
user
=
self
.
user_2
)
self
.
client2
.
force_authenticate
(
user
=
self
.
user_2
)
self
.
client
.
post
(
'
http://testserver/api/exercises/
'
,
json
.
dumps
({
"
name
"
:
"
test
"
,
"
description
"
:
"
test
"
,
"
unit
"
:
"
kilos
"
}),
content_type
=
'
application/json
'
)
self
.
client
.
post
(
'
http://testserver/api/exercises/
'
,
json
.
dumps
({
"
name
"
:
"
test
"
,
"
description
"
:
"
test
"
,
"
unit
"
:
"
kilos
"
}),
content_type
=
'
application/json
'
)
self
.
exercise_object
=
{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}
self
.
exercise_object
=
{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}
def
test_automatically_liked_own_post
(
self
):
workout_request
=
json
.
loads
(
'
{
"
name
"
:
"
bobs workout
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}],
"
filename
"
: []}
'
)
id1
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
workout_request
),
content_type
=
'
application/json
'
).
data
[
'
id
'
]
data
=
self
.
client
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
1
)
def
test_cannot_like_post_again
(
self
):
workout_request
=
json
.
loads
(
'
{
"
name
"
:
"
bobs workout
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}],
"
filename
"
: []}
'
)
id1
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
workout_request
),
content_type
=
'
application/json
'
).
data
[
'
id
'
]
data
=
self
.
client
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
1
)
self
.
client
.
post
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
)
data
=
self
.
client
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
1
)
def
test_user_can_like_others_post
(
self
):
workout_request
=
json
.
loads
(
'
{
"
name
"
:
"
bobs workout
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
3
"
,
"
sets
"
:
"
5
"
}],
"
filename
"
: []}
'
)
id1
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
workout_request
),
content_type
=
'
application/json
'
).
data
[
'
id
'
]
data
=
self
.
client
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
1
)
data
=
self
.
client2
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertTrue
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
1
)
self
.
client2
.
post
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
)
data
=
self
.
client2
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
2
)
self
.
client2
.
post
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
)
data
=
self
.
client2
.
get
(
'
http://testserver/api/workoutLiking/
'
+
str
(
id1
)
+
'
/
'
).
data
self
.
assertFalse
(
data
[
0
])
self
.
assertEquals
(
data
[
1
],
2
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment