Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
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
Paul Milleville
SCODOC_R6A06
Commits
2093a7f3
Commit
2093a7f3
authored
10 months ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
API: fix route dept etudiants + ajout tests unitaires.
parent
86d77dc5
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/api/etudiants.py
+12
-3
12 additions, 3 deletions
app/api/etudiants.py
sco_version.py
+1
-1
1 addition, 1 deletion
sco_version.py
tests/api/setup_test_api.py
+5
-2
5 additions, 2 deletions
tests/api/setup_test_api.py
tests/api/test_api_etudiants.py
+37
-3
37 additions, 3 deletions
tests/api/test_api_etudiants.py
with
55 additions
and
9 deletions
app/api/etudiants.py
+
12
−
3
View file @
2093a7f3
...
...
@@ -601,7 +601,10 @@ def etudiant_edit(
-------
/etudiant/ine/INE1/edit;{
""
prenom
""
:
""
Nouveau Prénom
""
,
""
adresses
""
:[{
""
email
""
:
""
nouvelle@adresse.fr
""
}]}
"""
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
g
.
scodoc_dept
)
dept
:
Departement
=
(
db
.
session
.
get
(
Departement
,
g
.
scodoc_dept_id
)
if
g
.
scodoc_dept
else
None
)
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
dept
)
if
not
ok
:
return
etud
# json error
#
...
...
@@ -662,7 +665,10 @@ def etudiant_annotation(
"""
if
not
current_user
.
has_permission
(
Permission
.
ViewEtudData
):
return
json_error
(
403
,
"
non autorisé (manque ViewEtudData)
"
)
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
g
.
scodoc_dept
)
dept
:
Departement
=
(
db
.
session
.
get
(
Departement
,
g
.
scodoc_dept_id
)
if
g
.
scodoc_dept
else
None
)
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
dept
)
if
not
ok
:
return
etud
# json error
#
...
...
@@ -704,7 +710,10 @@ def etudiant_annotation_delete(
`code`: la valeur du code
`annotation_id` : id de l
'
annotation
"""
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
g
.
scodoc_dept
)
dept
:
Departement
=
(
db
.
session
.
get
(
Departement
,
g
.
scodoc_dept_id
)
if
g
.
scodoc_dept
else
None
)
ok
,
etud
=
_get_etud_by_code
(
code_type
,
code
,
dept
)
if
not
ok
:
return
etud
# json error
annotation
=
EtudAnnotation
.
query
.
filter_by
(
...
...
This diff is collapsed.
Click to expand it.
sco_version.py
+
1
−
1
View file @
2093a7f3
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION
=
"
9.7.2
4
"
SCOVERSION
=
"
9.7.2
5
"
SCONAME
=
"
ScoDoc
"
...
...
This diff is collapsed.
Click to expand it.
tests/api/setup_test_api.py
+
5
−
2
View file @
2093a7f3
...
...
@@ -45,6 +45,7 @@ API_PASSWORD = os.environ.get("API_PASSWORD", os.environ.get("API_PASSWD", "test
API_USER_ADMIN
=
os
.
environ
.
get
(
"
API_USER_ADMIN
"
,
"
admin_api
"
)
API_PASSWORD_ADMIN
=
os
.
environ
.
get
(
"
API_PASSWD_ADMIN
"
,
"
admin_api
"
)
DEPT_ACRONYM
=
"
TAPI
"
API_DEPT_URL
=
f
"
{
SCODOC_URL
}
/ScoDoc/
{
DEPT_ACRONYM
}
/api
"
SCO_TEST_API_TIMEOUT
=
5
print
(
f
"
SCODOC_URL=
{
SCODOC_URL
}
"
)
print
(
f
"
API URL=
{
API_URL
}
"
)
...
...
@@ -93,7 +94,9 @@ def set_headers(headers: dict):
_DefaultHeaders
.
headers
=
headers
def
GET
(
path
:
str
,
headers
:
dict
=
None
,
errmsg
=
None
,
dept
=
None
,
raw
=
False
):
def
GET
(
path
:
str
,
headers
:
dict
=
None
,
errmsg
=
None
,
dept
:
str
|
None
=
None
,
raw
=
False
):
"""
Get and optionaly returns as JSON
Special case for non json result (image or pdf):
return Content-Disposition string (inline or attachment)
...
...
@@ -147,7 +150,7 @@ def POST(
data
:
dict
=
None
,
headers
:
dict
=
None
,
errmsg
=
None
,
dept
=
None
,
dept
:
str
|
None
=
None
,
raw
=
False
,
):
"""
Post
...
...
This diff is collapsed.
Click to expand it.
tests/api/test_api_etudiants.py
+
37
−
3
View file @
2093a7f3
...
...
@@ -26,6 +26,7 @@ from app.scodoc import sco_utils as scu
from
tests.api.setup_test_api
import
(
API_PASSWORD_ADMIN
,
API_URL
,
API_DEPT_URL
,
API_USER_ADMIN
,
CHECK_CERTIFICATE
,
DEPT_ACRONYM
,
...
...
@@ -134,8 +135,8 @@ def test_etudiant(api_headers):
etud
=
r
.
json
()
assert
verify_fields
(
etud
,
ETUD_FIELDS_RESTRICTED
)
is
True
code_nip
=
r
.
json
()
[
"
code_nip
"
]
code_ine
=
r
.
json
()
[
"
code_ine
"
]
code_nip
=
etud
[
"
code_nip
"
]
code_ine
=
etud
[
"
code_ine
"
]
######### Test code nip #########
...
...
@@ -165,6 +166,19 @@ def test_etudiant(api_headers):
assert
etud
==
etud_nip
==
etud_ine
# test route départementale
r
=
requests
.
get
(
API_DEPT_URL
+
f
"
/etudiant/etudid/
{
ETUDID
}
"
,
headers
=
api_headers
,
verify
=
CHECK_CERTIFICATE
,
timeout
=
scu
.
SCO_TEST_API_TIMEOUT
,
)
assert
r
.
status_code
==
200
etud
=
r
.
json
()
assert
code_nip
==
etud
[
"
code_nip
"
]
assert
code_ine
==
etud
[
"
code_ine
"
]
assert
verify_fields
(
etud
,
ETUD_FIELDS_RESTRICTED
)
is
True
def
test_etudiants
(
api_headers
):
"""
...
...
@@ -303,7 +317,7 @@ def test_etudiant_annotations(api_headers):
etud
=
GET
(
f
"
/etudiant/etudid/
{
etudid
}
"
,
headers
=
api_headers
)
assert
etud
[
"
nom
"
]
assert
etud
[
"
annotations
"
]
==
[]
#
a
joute annotation
#
A
joute annotation
annotation
=
POST
(
f
"
/etudiant/etudid/
{
etudid
}
/annotation
"
,
{
"
comment
"
:
"
annotation 1
"
},
...
...
@@ -324,6 +338,26 @@ def test_etudiant_annotations(api_headers):
)
etud
=
GET
(
f
"
/etudiant/etudid/
{
etudid
}
"
,
headers
=
api_headers
)
assert
len
(
etud
[
"
annotations
"
])
==
0
# Ajoute annotation via route départementale
annotation
=
POST
(
f
"
/etudiant/etudid/
{
etudid
}
/annotation
"
,
{
"
comment
"
:
"
annotation dept
"
},
headers
=
admin_header
,
dept
=
DEPT_ACRONYM
,
)
assert
annotation
annotation_id
=
annotation
[
"
id
"
]
etud
=
GET
(
f
"
/etudiant/etudid/
{
etudid
}
"
,
headers
=
admin_header
,
dept
=
DEPT_ACRONYM
)
assert
len
(
etud
[
"
annotations
"
])
==
1
# ok avec admin
assert
etud
[
"
annotations
"
][
0
][
"
comment
"
]
==
"
annotation dept
"
# Supprime annotation via route départementale
POST
(
f
"
/etudiant/etudid/
{
etudid
}
/annotation/
{
annotation_id
}
/delete
"
,
headers
=
admin_header
,
dept
=
DEPT_ACRONYM
,
)
etud
=
GET
(
f
"
/etudiant/etudid/
{
etudid
}
"
,
headers
=
api_headers
,
dept
=
DEPT_ACRONYM
)
assert
len
(
etud
[
"
annotations
"
])
==
0
def
test_etudiant_photo
(
api_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