Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scodoc_issue_976
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis Dormael
scodoc_issue_976
Commits
e6f86d65
Commit
e6f86d65
authored
11 months ago
by
ilona
Browse files
Options
Downloads
Patches
Plain Diff
API FormSemestreDescription + test
parent
513fb3d4
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/api/formsemestres.py
+25
-0
25 additions, 0 deletions
app/api/formsemestres.py
tests/api/test_api_formsemestre.py
+48
-0
48 additions, 0 deletions
tests/api/test_api_formsemestre.py
tests/api/test_api_permissions.py
+1
-1
1 addition, 1 deletion
tests/api/test_api_permissions.py
with
74 additions
and
1 deletion
app/api/formsemestres.py
+
25
−
0
View file @
e6f86d65
...
...
@@ -33,6 +33,7 @@ from app.models import (
Departement
,
Evaluation
,
FormSemestre
,
FormSemestreDescription
,
FormSemestreEtape
,
FormSemestreInscription
,
Identite
,
...
...
@@ -812,6 +813,30 @@ def formsemestre_get_description(formsemestre_id: int):
return
formsemestre
.
description
.
to_dict
()
if
formsemestre
.
description
else
{}
@bp.post
(
"
/formsemestre/<int:formsemestre_id>/description/edit
"
)
@api_web_bp.post
(
"
/formsemestre/<int:formsemestre_id>/description/edit
"
)
@login_required
@scodoc
@permission_required
(
Permission
.
ScoView
)
@as_json
def
formsemestre_edit_description
(
formsemestre_id
:
int
):
"""
Modifie description externe du formsemestre
formsemestre_id : l
'
id du formsemestre
SAMPLES
-------
/formsemestre/<int:formsemestre_id>/description/edit;{
""
description
""
:
""
descriptif du semestre
""
,
""
dispositif
""
:1}
"""
formsemestre
=
FormSemestre
.
get_formsemestre
(
formsemestre_id
)
args
=
request
.
get_json
(
force
=
True
)
# may raise 400 Bad Request
if
not
formsemestre
.
description
:
formsemestre
.
description
=
FormSemestreDescription
()
formsemestre
.
description
.
from_dict
(
args
)
db
.
session
.
commit
()
return
formsemestre
.
description
.
to_dict
()
@bp.route
(
"
/formsemestre/<int:formsemestre_id>/description/image
"
)
@api_web_bp.route
(
"
/formsemestre/<int:formsemestre_id>/description/image
"
)
@login_required
...
...
This diff is collapsed.
Click to expand it.
tests/api/test_api_formsemestre.py
+
48
−
0
View file @
e6f86d65
...
...
@@ -28,8 +28,10 @@ from tests.api.setup_test_api import (
API_URL
,
CHECK_CERTIFICATE
,
GET
,
POST
,
api_headers
,
api_admin_headers
,
set_headers
,
)
from
tests.api.tools_test_api
import
(
...
...
@@ -780,3 +782,49 @@ def _compare_formsemestre_resultat(res: list[dict], ref: list[dict]):
if
"
nbabs
"
in
k
:
continue
assert
res_d
[
k
]
==
ref_d
[
k
],
f
"
values for key
{
k
}
differ.
"
def
test_formsemestre_description
(
api_admin_headers
):
"""
Test accès et modification de la description
"""
set_headers
(
api_admin_headers
)
formsemestre_id
=
1
r
=
GET
(
f
"
/formsemestre/
{
formsemestre_id
}
"
)
assert
"
description
"
not
in
r
r
=
POST
(
f
"
/formsemestre/
{
formsemestre_id
}
/description/edit
"
,
data
=
{
"
description
"
:
"
une description
"
,
"
horaire
"
:
"
un horaire
"
,
"
salle
"
:
"
une salle
"
,
"
dispositif
"
:
1
,
"
wip
"
:
True
,
},
)
assert
r
[
"
description
"
]
==
"
une description
"
assert
r
[
"
horaire
"
]
==
"
un horaire
"
assert
r
[
"
salle
"
]
==
"
une salle
"
assert
r
[
"
dispositif
"
]
==
1
assert
r
[
"
wip
"
]
is
True
r
=
GET
(
f
"
/formsemestre/
{
formsemestre_id
}
/description
"
)
assert
r
[
"
description
"
]
==
"
une description
"
assert
r
[
"
horaire
"
]
==
"
un horaire
"
assert
r
[
"
salle
"
]
==
"
une salle
"
assert
r
[
"
dispositif
"
]
==
1
assert
r
[
"
wip
"
]
is
True
r
=
POST
(
f
"
/formsemestre/
{
formsemestre_id
}
/description/edit
"
,
data
=
{
"
description
"
:
""
,
"
horaire
"
:
""
,
"
salle
"
:
""
,
"
dispositif
"
:
0
,
"
wip
"
:
False
,
},
)
assert
r
[
"
description
"
]
==
""
assert
r
[
"
horaire
"
]
==
""
assert
r
[
"
salle
"
]
==
""
assert
r
[
"
dispositif
"
]
==
0
assert
r
[
"
wip
"
]
is
False
This diff is collapsed.
Click to expand it.
tests/api/test_api_permissions.py
+
1
−
1
View file @
e6f86d65
...
...
@@ -100,7 +100,7 @@ def test_permissions(api_headers):
verify
=
CHECK_CERTIFICATE
,
timeout
=
scu
.
SCO_TEST_API_TIMEOUT
,
)
assert
r
.
status_code
==
200
assert
r
.
status_code
//
100
==
2
# 2xx success
# Même chose sans le jeton:
for
rule
in
api_rules
:
...
...
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