Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CloWM Workflow Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Computational Metagenomics
CloWM
CloWM Workflow Service
Commits
c8b5d24e
Verified
Commit
c8b5d24e
authored
1 year ago
by
Daniel Göbel
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for workflow statistics endpoint
#24
parent
68b6beda
No related branches found
No related tags found
1 merge request
!30
Resolve "Workflow usage statistics"
Pipeline
#28081
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/tests/api/test_workflow.py
+30
-1
30 additions, 1 deletion
app/tests/api/test_workflow.py
app/tests/crud/test_workflow.py
+21
-1
21 additions, 1 deletion
app/tests/crud/test_workflow.py
with
51 additions
and
2 deletions
app/tests/api/test_workflow.py
+
30
−
1
View file @
c8b5d24e
from
datetime
import
date
from
io
import
BytesIO
from
io
import
BytesIO
from
uuid
import
UUID
,
uuid4
from
uuid
import
UUID
,
uuid4
import
pytest
import
pytest
from
clowmdb.models
import
Workflow
,
WorkflowVersion
from
clowmdb.models
import
Workflow
,
WorkflowExecution
,
WorkflowVersion
from
fastapi
import
status
from
fastapi
import
status
from
httpx
import
AsyncClient
from
httpx
import
AsyncClient
from
sqlalchemy
import
delete
,
select
from
sqlalchemy
import
delete
,
select
...
@@ -380,6 +381,34 @@ class TestWorkflowRoutesGet(_TestWorkflowRoutes):
...
@@ -380,6 +381,34 @@ class TestWorkflowRoutesGet(_TestWorkflowRoutes):
)
)
assert
response
.
status_code
==
status
.
HTTP_404_NOT_FOUND
assert
response
.
status_code
==
status
.
HTTP_404_NOT_FOUND
@pytest.mark.asyncio
async
def
test_get_workflow_statistics
(
self
,
client
:
AsyncClient
,
random_user
:
UserWithAuthHeader
,
random_workflow
:
WorkflowOut
,
random_workflow_execution
:
WorkflowExecution
,
)
->
None
:
"""
Test for getting a non-existing workflow.
Parameters
----------
client : httpx.AsyncClient
HTTP Client to perform the request on. pytest fixture.
random_user : app.tests.utils.user.UserWithAuthHeader
Random user for testing. pytest fixture.
"""
response
=
await
client
.
get
(
"
/
"
.
join
([
self
.
base_path
,
str
(
random_workflow
.
workflow_id
),
"
statistics
"
]),
headers
=
random_user
.
auth_headers
,
)
assert
response
.
status_code
==
status
.
HTTP_200_OK
statistics
=
response
.
json
()
assert
len
(
statistics
)
==
1
assert
statistics
[
0
][
"
day
"
]
==
str
(
date
.
today
())
assert
statistics
[
0
][
"
count
"
]
==
1
class
TestWorkflowRoutesDelete
(
_TestWorkflowRoutes
):
class
TestWorkflowRoutesDelete
(
_TestWorkflowRoutes
):
@pytest.mark.asyncio
@pytest.mark.asyncio
...
...
This diff is collapsed.
Click to expand it.
app/tests/crud/test_workflow.py
+
21
−
1
View file @
c8b5d24e
import
random
import
random
from
datetime
import
date
import
pytest
import
pytest
from
clowmdb.models
import
Workflow
,
WorkflowVersion
from
clowmdb.models
import
Workflow
,
WorkflowExecution
,
WorkflowVersion
from
sqlalchemy
import
delete
,
select
from
sqlalchemy
import
delete
,
select
from
sqlalchemy.ext.asyncio
import
AsyncSession
from
sqlalchemy.ext.asyncio
import
AsyncSession
...
@@ -134,6 +135,25 @@ class TestWorkflowCRUDGet:
...
@@ -134,6 +135,25 @@ class TestWorkflowCRUDGet:
assert
workflow
is
not
None
assert
workflow
is
not
None
assert
workflow
.
workflow_id
==
random_workflow
.
workflow_id
assert
workflow
.
workflow_id
==
random_workflow
.
workflow_id
@pytest.mark.asyncio
async
def
test_get_workflow_statistics
(
self
,
db
:
AsyncSession
,
random_workflow
:
WorkflowOut
,
random_workflow_execution
:
WorkflowExecution
)
->
None
:
"""
Test for getting a workflow by its name from CRUD Repository.
Parameters
----------
db : sqlalchemy.ext.asyncio.AsyncSession.
Async database session to perform query on. pytest fixture.
random_workflow : app.schemas.workflow.WorkflowOut
Random bucket for testing. pytest fixture.
"""
statistics
=
await
CRUDWorkflow
.
statistics
(
db
,
random_workflow
.
workflow_id
)
assert
len
(
statistics
)
==
1
assert
statistics
[
0
].
day
==
date
.
today
()
assert
statistics
[
0
].
count
==
1
class
TestWorkflowCRUDCreate
:
class
TestWorkflowCRUDCreate
:
@pytest.mark.asyncio
@pytest.mark.asyncio
...
...
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