Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fractalis
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Fractalis
fractalis
Commits
813e6d41
Commit
813e6d41
authored
7 years ago
by
Sascha Herzinger
Browse files
Options
Downloads
Patches
Plain Diff
some test cases for the new code that will probably fail
parent
da5f7c47
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/functional/test_state.py
+55
-0
55 additions, 0 deletions
tests/functional/test_state.py
with
55 additions
and
0 deletions
tests/functional/test_state.py
0 → 100644
+
55
−
0
View file @
813e6d41
"""
This module tests the state controller module.
"""
from
uuid
import
UUID
,
uuid4
import
flask
import
pytest
from
fractalis
import
redis
,
sync
# noinspection PyMissingOrEmptyDocstring,PyMissingTypeHints
class
TestState
:
@pytest.fixture
(
scope
=
'
function
'
)
def
test_client
(
self
):
sync
.
cleanup_all
()
from
fractalis
import
app
app
.
testing
=
True
with
app
.
test_client
()
as
test_client
:
yield
test_client
sync
.
cleanup_all
()
def
test_save_state_saves_and_returns
(
self
,
test_client
):
rv
=
test_client
.
post
(
'
/state
'
,
data
=
flask
.
json
.
dumps
(
'
test
'
))
body
=
flask
.
json
.
loads
(
rv
.
get_data
())
assert
rv
.
status_code
==
201
,
body
assert
UUID
(
body
[
'
state_id
'
])
assert
redis
.
get
(
'
state:{}
'
.
format
(
body
[
'
state_id
'
]))
==
'
test
'
def
test_404_if_request_invalid_state_id
(
self
,
test_client
):
rv
=
test_client
.
post
(
'
/state/{}
'
.
format
(
str
(
uuid4
())))
assert
rv
.
status_code
==
404
def
test_error_if_state_id_is_no_uuid
(
self
,
test_client
):
rv
=
test_client
.
post
(
'
/state/123
'
)
assert
rv
.
status_code
==
400
def
test_error_if_task_id_is_no_etl_id
(
self
,
test_client
):
uuid
=
str
(
uuid4
())
redis
.
set
(
'
state:{}
'
.
format
(
uuid
),
'
foo
'
)
rv
=
test_client
.
post
(
'
/state/{}
'
.
format
(
uuid
))
body
=
flask
.
json
.
loads
(
rv
.
get_data
())
assert
rv
.
status_code
==
400
,
body
assert
'
error
'
in
body
assert
'
given payload cannot be saved
'
in
body
[
'
error
'
]
def
test_201_and_valid_state_if_valid_conditions
(
self
,
test_client
):
uuid
=
str
(
uuid4
())
redis
.
set
(
'
state:{}
'
.
format
(
uuid
),
{
'
meta
'
:
{
'
descriptor
'
:
'
foo
'
}})
rv
=
test_client
.
post
(
'
/state/{}
'
.
format
(
uuid
))
assert
rv
.
status_code
==
201
with
test_client
.
session_transaction
()
as
sess
:
assert
sess
[
'
data_tasks
'
]
assert
sess
[
'
state_access
'
]
assert
sess
[
'
data_tasks
'
]
==
sess
[
'
state_access
'
]
assert
[
UUID
(
uuid
)
for
id
in
sess
[
'
data_tasks
'
]]
\ No newline at end of file
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