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
fbbc62c5
Commit
fbbc62c5
authored
4 years ago
by
Haakon Gunleiksrud
Browse files
Options
Downloads
Patches
Plain Diff
add some tests of permisssions.py
parent
ef204525
No related branches found
Branches containing commit
No related tags found
3 merge requests
!15
Dev
,
!10
Dev
,
!9
Fr5 bb testing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/secfit/workouts/tests.py
+23
-4
23 additions, 4 deletions
backend/secfit/workouts/tests.py
with
23 additions
and
4 deletions
backend/secfit/workouts/tests.py
+
23
−
4
View file @
fbbc62c5
...
...
@@ -3,6 +3,8 @@ Tests for the workouts application.
"""
from
django.test
import
TestCase
from
workouts.models
import
Workout
from
users.models
import
User
from
rest_framework.test
import
RequestsClient
# Create your tests here.
"""
...
...
@@ -11,12 +13,29 @@ Tests for ./permissions.py
class
IsOwnerTestCase
(
TestCase
):
def
setUp
(
self
):
#Workout
.objects.create(
name="testworkou
t")
#testworkout = Workout.objects.get
return
super
().
setUp
(
)
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secre
t
"
)
User
.
objects
.
create
(
id
=
"
2
"
,
username
=
"
Alice
"
,
password
=
"
supersecret
"
)
Workout
.
objects
.
create
(
id
=
"
1
"
,
name
=
"
workout
"
,
date
=
"
2021-02-23 14:00
"
,
owner_id
=
"
1
"
)
def
test_has_object_permission
(
self
):
self
.
assertEqual
(
True
,
True
)
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
user_2
=
User
.
objects
.
get
(
id
=
"
2
"
)
workout
=
Workout
.
objects
.
get
(
name
=
"
workout
"
)
client1
=
RequestsClient
()
client1
.
login
(
username
=
"
Bill
"
,
password
=
"
secret
"
)
client2
=
RequestsClient
()
client2
.
login
(
username
=
"
Alice
"
,
password
=
"
supersecret
"
)
#Disse må fort endres når vi setter de inn i CI.
request1
=
client1
.
get
(
"
/api/workouts/1
"
)
request2
=
client2
.
get
(
"
/api/workouts/1
"
)
#self.assertEqual(user_1.username,client1.)
self
.
assertEqual
(
request1
.
client
,
client1
)
self
.
assertTrue
(
workout
.
owner_id
==
user_1
.
id
)
self
.
assertFalse
(
workout
.
owner_id
==
user_2
.
id
)
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