Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
944205d4
Commit
944205d4
authored
4 years ago
by
robban64
Browse files
Options
Downloads
Patches
Plain Diff
fix: single items response
parent
f08baf88
No related branches found
No related tags found
1 merge request
!43
Resolve "Implement marshmallow"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/app/apis/__init__.py
+1
-1
1 addition, 1 deletion
server/app/apis/__init__.py
server/tests/test_app.py
+7
-7
7 additions, 7 deletions
server/tests/test_app.py
with
8 additions
and
8 deletions
server/app/apis/__init__.py
+
1
−
1
View file @
944205d4
...
@@ -37,7 +37,7 @@ def list_response(items, total=None, code=200):
...
@@ -37,7 +37,7 @@ def list_response(items, total=None, code=200):
def
item_response
(
item
,
code
=
200
):
def
item_response
(
item
,
code
=
200
):
if
isinstance
(
item
,
list
):
if
isinstance
(
item
,
list
):
abort
(
codes
.
INTERNAL_SERVER_ERROR
)
abort
(
codes
.
INTERNAL_SERVER_ERROR
)
return
{
"
item
s
"
:
[
item
],
"
count
"
:
1
,
"
total_count
"
:
1
}
,
code
return
item
,
code
from
flask_restx
import
Api
from
flask_restx
import
Api
...
...
This diff is collapsed.
Click to expand it.
server/tests/test_app.py
+
7
−
7
View file @
944205d4
...
@@ -46,12 +46,12 @@ def test_competition(client):
...
@@ -46,12 +46,12 @@ def test_competition(client):
data
=
{
"
name
"
:
"
c1
"
,
"
year
"
:
2020
,
"
city_id
"
:
1
,
"
style_id
"
:
1
}
data
=
{
"
name
"
:
"
c1
"
,
"
year
"
:
2020
,
"
city_id
"
:
1
,
"
style_id
"
:
1
}
response
,
body
=
post
(
client
,
"
/api/competitions
"
,
data
,
headers
=
headers
)
response
,
body
=
post
(
client
,
"
/api/competitions
"
,
data
,
headers
=
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert
body
[
"
items
"
][
0
][
"
name
"
]
==
"
c1
"
assert
body
[
"
name
"
]
==
"
c1
"
# Get competition
# Get competition
response
,
body
=
get
(
client
,
"
/api/competitions/1
"
,
headers
=
headers
)
response
,
body
=
get
(
client
,
"
/api/competitions/1
"
,
headers
=
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert
body
[
"
items
"
][
0
][
"
name
"
]
==
"
c1
"
assert
body
[
"
name
"
]
==
"
c1
"
response
,
body
=
post
(
client
,
"
/api/competitions/1/slides
"
,
{},
headers
=
headers
)
response
,
body
=
post
(
client
,
"
/api/competitions/1/slides
"
,
{},
headers
=
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
...
@@ -87,9 +87,9 @@ def test_app(client):
...
@@ -87,9 +87,9 @@ def test_app(client):
register_data
=
{
"
email
"
:
"
test1@test.se
"
,
"
password
"
:
"
abc123
"
,
"
role_id
"
:
2
,
"
city_id
"
:
1
}
register_data
=
{
"
email
"
:
"
test1@test.se
"
,
"
password
"
:
"
abc123
"
,
"
role_id
"
:
2
,
"
city_id
"
:
1
}
response
,
body
=
post
(
client
,
"
/api/auth/signup
"
,
register_data
,
headers
)
response
,
body
=
post
(
client
,
"
/api/auth/signup
"
,
register_data
,
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert
body
[
"
items
"
][
0
][
"
id
"
]
==
2
assert
body
[
"
id
"
]
==
2
assert
"
password
"
not
in
body
[
"
items
"
][
0
]
assert
"
password
"
not
in
body
assert
"
_password
"
not
in
body
[
"
items
"
][
0
]
assert
"
_password
"
not
in
body
# Try loggin with wrong PASSWORD
# Try loggin with wrong PASSWORD
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test1@test.se
"
,
"
password
"
:
"
abc1234
"
})
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test1@test.se
"
,
"
password
"
:
"
abc1234
"
})
...
@@ -107,12 +107,12 @@ def test_app(client):
...
@@ -107,12 +107,12 @@ def test_app(client):
# Get the current user
# Get the current user
response
,
body
=
get
(
client
,
"
/api/users
"
,
headers
=
headers
)
response
,
body
=
get
(
client
,
"
/api/users
"
,
headers
=
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert
body
[
"
items
"
][
0
][
"
email
"
]
==
"
test1@test.se
"
assert
body
[
"
email
"
]
==
"
test1@test.se
"
# Edit current user name
# Edit current user name
response
,
body
=
put
(
client
,
"
/api/users
"
,
{
"
name
"
:
"
carl carlsson
"
},
headers
=
headers
)
response
,
body
=
put
(
client
,
"
/api/users
"
,
{
"
name
"
:
"
carl carlsson
"
},
headers
=
headers
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert
body
[
"
items
"
][
0
][
"
name
"
]
==
"
Carl Carlsson
"
assert
body
[
"
name
"
]
==
"
Carl Carlsson
"
# Delete created user
# Delete created user
response
,
body
=
delete
(
client
,
"
/api/auth/delete/1
"
,
{},
headers
=
headers
)
response
,
body
=
delete
(
client
,
"
/api/auth/delete/1
"
,
{},
headers
=
headers
)
...
...
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