Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jass
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor 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
Léo HENCHES
jass
Commits
d9ff51f5
Commit
d9ff51f5
authored
1 year ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
update python tests, raise 404 when initTable does not exist
parent
68b2b25a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
jass/server.py
+4
-1
4 additions, 1 deletion
jass/server.py
jass/test/__init__.py
+4
-0
4 additions, 0 deletions
jass/test/__init__.py
jass/test/test_server.py
+30
-4
30 additions, 4 deletions
jass/test/test_server.py
with
38 additions
and
5 deletions
jass/server.py
+
4
−
1
View file @
d9ff51f5
...
...
@@ -55,7 +55,10 @@ async def read_index():
@app.post
(
"
/api/phenotypes
"
,
response_model
=
List
[
Phenotype
])
def
phenotypes_list
(
project_name
:
ProjectNameModel
):
"""
List phenotypes
"""
return
get_available_phenotypes
(
os
.
path
.
join
(
config
[
"
DATA_DIR
"
],
project_name
.
initTableName
))
try
:
return
get_available_phenotypes
(
os
.
path
.
join
(
config
[
"
DATA_DIR
"
],
project_name
.
initTableName
))
except
FileNotFoundError
as
e
:
# initTable does not exists
raise
HTTPException
(
status_code
=
404
,
detail
=
str
(
e
))
@app.get
(
"
/api/initmeta
"
)
def
inittable_meta
():
...
...
This diff is collapsed.
Click to expand it.
jass/test/__init__.py
+
4
−
0
View file @
d9ff51f5
...
...
@@ -30,6 +30,10 @@ class JassWebClientTestCase(JassTestCase):
self
.
test_dir
=
tempfile
.
mkdtemp
()
config
[
"
DATA_DIR
"
]
=
self
.
test_dir
shutil
.
copy
(
self
.
get_file_path_fn
(
"
initTable.hdf5
"
),
self
.
test_dir
)
try
:
shutil
.
copy
(
self
.
get_file_path_fn
(
"
initTableTest1.hdf5
"
),
self
.
test_dir
)
except
FileNotFoundError
:
pass
from
jass.server
import
app
self
.
testing_client
=
TestClient
(
app
)
...
...
This diff is collapsed.
Click to expand it.
jass/test/test_server.py
+
30
−
4
View file @
d9ff51f5
...
...
@@ -13,22 +13,48 @@ from . import JassWebClientTestCase
class
TestDefaultController
(
JassWebClientTestCase
):
"""
DefaultController integration test stubs
"""
test_folder
=
"
data_
test1
"
test_folder
=
"
data_
real
"
def
test_phenotypes_
ge
t
(
self
):
def
test_phenotypes_
pos
t
(
self
):
"""
Test case retrieving available phenotypes
"""
response
=
self
.
testing_client
.
ge
t
(
"
/api/phenotypes
"
)
response
=
self
.
testing_client
.
pos
t
(
"
/api/phenotypes
"
,
json
=
{}
)
self
.
assert200
(
response
,
"
Response body is :
"
+
response
.
content
.
decode
(
"
utf-8
"
))
response
=
self
.
testing_client
.
post
(
"
/api/phenotypes
"
,
json
=
{
"
initTableName
"
:
"
initTable.hdf5
"
},
)
self
.
assert200
(
response
,
"
Response body is :
"
+
response
.
content
.
decode
(
"
utf-8
"
))
json_response_main
=
json
.
loads
(
response
.
content
.
decode
(
"
utf-8
"
))
phenotypes_main
=
set
(
p
[
"
id
"
]
for
p
in
json_response_main
)
response
=
self
.
testing_client
.
post
(
"
/api/phenotypes
"
,
json
=
{
"
initTableName
"
:
"
initTableTest1.hdf5
"
},
)
self
.
assert200
(
response
,
"
Response body is :
"
+
response
.
content
.
decode
(
"
utf-8
"
))
json_response_t1
=
json
.
loads
(
response
.
content
.
decode
(
"
utf-8
"
))
phenotypes_t1
=
set
(
p
[
"
id
"
]
for
p
in
json_response_t1
)
self
.
assertNotEqual
(
json_response_t1
,
json_response_main
)
self
.
assertNotEqual
(
phenotypes_main
,
phenotypes_t1
)
self
.
assertEqual
(
phenotypes_main
.
intersection
(
phenotypes_t1
),
set
())
response
=
self
.
testing_client
.
post
(
"
/api/phenotypes
"
,
json
=
{
"
initTableName
"
:
"
initTableMissing.hdf5
"
},
)
self
.
assertEqual
(
response
.
status_code
,
404
,
response
.
content
.
decode
(
"
utf-8
"
))
def
test_create_project
(
self
):
"""
Test case for creating a project
"""
response
=
self
.
testing_client
.
post
(
"
/api/projects
"
,
json
=
{
"
phenotypeID
"
:
[
"
z_
DISNEY_POCAHONT
"
]},
json
=
{
"
phenotypeID
"
:
[
"
z_
MAGIC_FAST-GLUCOSE
"
]},
)
self
.
assert200
(
response
,
"
Response body is :
"
+
response
.
content
.
decode
(
"
utf-8
"
))
...
...
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