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
2b1abf48
Commit
2b1abf48
authored
4 years ago
by
Haakon Gunleiksrud
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into hg_backend_smells
parents
ba4326a0
90318c09
No related branches found
Branches containing commit
No related tags found
2 merge requests
!31
Complete exercise 3
,
!29
Hg backend smells
Pipeline
#128974
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/secfit/comments/tests.py
+25
-3
25 additions, 3 deletions
backend/secfit/comments/tests.py
backend/secfit/users/tests.py
+38
-0
38 additions, 0 deletions
backend/secfit/users/tests.py
backend/secfit/users/views.py
+1
-2
1 addition, 2 deletions
backend/secfit/users/views.py
with
64 additions
and
5 deletions
backend/secfit/comments/tests.py
+
25
−
3
View file @
2b1abf48
...
...
@@ -24,15 +24,37 @@ class CommentsTestCase(TestCase):
post
=
self
.
client
.
post
(
self
.
commentURL
,({
"
workout
"
:
self
.
workout1URL
,
"
content
"
:
"
asd
"
}),
format
=
'
json
'
)
self
.
assertEquals
(
post
.
status_code
,
201
)
def
testGetComments
(
self
):
def
testGet
Public
Comments
(
self
):
Workout
.
objects
.
create
(
id
=
"
1
"
,
name
=
"
workout
"
,
date
=
timezone
.
now
(),
owner
=
self
.
user_1
,
visibility
=
"
PU
"
)
Workout
.
objects
.
create
(
id
=
"
2
"
,
name
=
"
workout
"
,
date
=
timezone
.
now
(),
owner
=
self
.
user_2
,
visibility
=
"
PR
"
)
post
=
self
.
client
.
post
(
self
.
commentURL
,({
"
workout
"
:
self
.
workout1URL
,
"
content
"
:
"
asd
"
}),
format
=
'
json
'
)
self
.
assertEquals
(
post
.
status_code
,
201
)
user1get
=
self
.
client
.
get
(
"
http://testserver/api/comments/
"
)
datadict
=
dict
(
user1get
.
data
)
self
.
assertEquals
(
len
(
datadict
[
"
results
"
]),
1
)
user2get
=
self
.
client2
.
get
(
"
http://testserver/api/comments/
"
)
datadict2
=
dict
(
user2get
.
data
)
self
.
assertEquals
(
len
(
datadict2
[
"
results
"
]),
1
)
def
testGetPrivateComments
(
self
):
Workout
.
objects
.
create
(
id
=
"
2
"
,
name
=
"
workout
"
,
date
=
timezone
.
now
(),
owner
=
self
.
user_2
,
visibility
=
"
PR
"
)
self
.
client2
.
post
(
self
.
commentURL
,({
"
workout
"
:
"
http://testserver/api/workouts/2/
"
,
"
content
"
:
"
assdsdd
"
}),
format
=
'
json
'
)
user1get
=
self
.
client
.
get
(
"
http://testserver/api/comments/
"
)
datadict
=
dict
(
user1get
.
data
)
self
.
assertEquals
(
len
(
datadict
[
"
results
"
]),
0
)
user2get
=
self
.
client2
.
get
(
"
http://testserver/api/comments/
"
)
datadict2
=
dict
(
user2get
.
data
)
self
.
assertEquals
(
len
(
datadict2
[
"
results
"
]),
1
)
def
testGetCoachComment
(
self
):
User
.
objects
.
create
(
id
=
"
3
"
,
username
=
"
Bill3
"
,
password
=
"
secret
"
,
email
=
"
hei2
"
,
coach
=
self
.
user_1
)
self
.
user_3
=
User
.
objects
.
get
(
id
=
"
3
"
)
self
.
client3
=
APIClient
()
self
.
client3
.
force_authenticate
(
user
=
self
.
user_3
)
Workout
.
objects
.
create
(
id
=
"
3
"
,
name
=
"
workout
"
,
date
=
timezone
.
now
(),
owner
=
self
.
user_3
,
visibility
=
"
CO
"
)
self
.
client3
.
post
(
self
.
commentURL
,({
"
workout
"
:
"
http://testserver/api/workouts/3/
"
,
"
content
"
:
"
asd
"
}),
format
=
'
json
'
)
user1get
=
self
.
client
.
get
(
"
http://testserver/api/comments/
"
)
datadict
=
dict
(
user1get
.
data
)
self
.
assertEquals
(
len
(
datadict
[
"
results
"
]),
1
)
user2get
=
self
.
client2
.
get
(
"
http://testserver/api/comments/
"
)
datadict2
=
dict
(
user2get
.
data
)
self
.
assertEquals
(
len
(
datadict2
[
"
results
"
]),
2
)
\ No newline at end of file
self
.
assertEquals
(
len
(
datadict2
[
"
results
"
]),
0
)
This diff is collapsed.
Click to expand it.
backend/secfit/users/tests.py
+
38
−
0
View file @
2b1abf48
...
...
@@ -727,3 +727,41 @@ class Register2WayDomainTestCase(TestCase):
try
:
self
.
assertEquals
((
status
==
201
),
expectedstatus
)
except
AssertionError
:
failures
.
append
({
field1
:
value1
,
field2
:
value2
})
print
(
failures
)
class
offerlistTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
,
email
=
"
hei
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
User
.
objects
.
create
(
id
=
"
2
"
,
username
=
"
Bill2
"
,
password
=
"
secret
"
,
email
=
"
hei1
"
)
self
.
user_2
=
User
.
objects
.
get
(
id
=
"
2
"
)
self
.
client2
=
APIClient
()
self
.
client2
.
force_authenticate
(
user
=
self
.
user_2
)
User
.
objects
.
create
(
id
=
"
3
"
,
username
=
"
Bill1
"
,
password
=
"
secret
"
,
email
=
"
hei2
"
)
self
.
user_3
=
User
.
objects
.
get
(
id
=
"
3
"
)
self
.
client3
=
APIClient
()
self
.
client3
.
force_authenticate
(
user
=
self
.
user_3
)
self
.
recURL
=
"
http://testserver/api/offers/?status=p&category=received
"
self
.
sentURL
=
"
http://testserver/api/offers/?status=p&category=sent
"
def
test_recipient
(
self
):
post
=
self
.
client
.
post
(
"
http://testserver/api/offers/
"
,{
"
status
"
:
"
p
"
,
"
recipient
"
:
"
http://testserver/api/users/2/
"
},
format
=
'
json
'
)
self
.
assertEquals
(
post
.
status_code
,
201
)
get
=
self
.
client
.
get
(
self
.
recURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
0
)
get
=
self
.
client2
.
get
(
self
.
recURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
1
)
get
=
self
.
client3
.
get
(
self
.
recURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
0
)
def
test_sent
(
self
):
post
=
self
.
client
.
post
(
"
http://testserver/api/offers/
"
,{
"
status
"
:
"
p
"
,
"
recipient
"
:
"
http://testserver/api/users/2/
"
},
format
=
'
json
'
)
self
.
assertEquals
(
post
.
status_code
,
201
)
get
=
self
.
client
.
get
(
self
.
sentURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
1
)
get
=
self
.
client2
.
get
(
self
.
sentURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
0
)
get
=
self
.
client3
.
get
(
self
.
sentURL
)
self
.
assertEquals
(
dict
(
get
.
data
)[
"
count
"
],
0
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/secfit/users/views.py
+
1
−
2
View file @
2b1abf48
import
django
from
rest_framework
import
mixins
,
generics
from
rest_framework
import
mixins
,
generics
,
permissions
from
workouts.mixins
import
CreateListModelMixin
from
rest_framework
import
permissions
from
users.serializers
import
(
UserSerializer
,
OfferSerializer
,
...
...
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