Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Adham Hashibon
force-bdss
Commits
d1829c4b
Commit
d1829c4b
authored
7 years ago
by
martinRenou
Browse files
Options
Downloads
Patches
Plain Diff
Fix and add tests
parent
2e4166b8
No related branches found
No related tags found
1 merge request
!86
Improve event handling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
force_bdss/tests/test_core_mco_driver.py
+28
-6
28 additions, 6 deletions
force_bdss/tests/test_core_mco_driver.py
with
28 additions
and
6 deletions
force_bdss/tests/test_core_mco_driver.py
+
28
−
6
View file @
d1829c4b
import
unittest
from
testfixtures
import
LogCapture
from
force_bdss.mco.events
import
MCOStartEvent
from
force_bdss.core_driver_events
import
(
MCOStartEvent
,
MCOFinishEvent
,
MCOProgressEvent
)
from
force_bdss.notification_listeners.base_notification_listener
import
\
BaseNotificationListener
from
force_bdss.tests
import
fixtures
...
...
@@ -47,16 +48,37 @@ class TestCoreMCODriver(unittest.TestCase):
)
self
.
assertEqual
(
len
(
driver
.
listeners
),
1
)
def
test_event_handling
(
self
):
def
test_
start_
event_handling
(
self
):
driver
=
CoreMCODriver
(
application
=
self
.
mock_application
,
)
listener
=
driver
.
listeners
[
0
]
mock_deliver
=
mock
.
Mock
()
listener
.
__dict__
[
"
deliver
"
]
=
mock_deliver
event
=
MCOStartEvent
()
driver
.
mco
.
event
=
event
self
.
assertTrue
(
mock_deliver
.
call_args
[
0
][
0
],
event
)
driver
.
mco
.
started
=
True
self
.
assertIsInstance
(
mock_deliver
.
call_args
[
0
][
0
],
MCOStartEvent
)
def
test_finished_event_handling
(
self
):
driver
=
CoreMCODriver
(
application
=
self
.
mock_application
,
)
listener
=
driver
.
listeners
[
0
]
mock_deliver
=
mock
.
Mock
()
listener
.
__dict__
[
"
deliver
"
]
=
mock_deliver
driver
.
mco
.
finished
=
True
self
.
assertIsInstance
(
mock_deliver
.
call_args
[
0
][
0
],
MCOFinishEvent
)
def
test_progress_event_handling
(
self
):
driver
=
CoreMCODriver
(
application
=
self
.
mock_application
,
)
listener
=
driver
.
listeners
[
0
]
mock_deliver
=
mock
.
Mock
()
listener
.
__dict__
[
"
deliver
"
]
=
mock_deliver
driver
.
mco
.
new_data
=
{
'
input
'
:
(
1
,
2
),
'
output
'
:
(
3
,
4
)}
self
.
assertIsInstance
(
mock_deliver
.
call_args
[
0
][
0
],
MCOProgressEvent
)
self
.
assertEqual
(
mock_deliver
.
call_args
[
0
][
0
].
input
,
(
1
,
2
))
self
.
assertEqual
(
mock_deliver
.
call_args
[
0
][
0
].
output
,
(
3
,
4
))
def
test_listener_init_exception
(
self
):
driver
=
CoreMCODriver
(
...
...
@@ -90,7 +112,7 @@ class TestCoreMCODriver(unittest.TestCase):
listener
.
__dict__
[
"
deliver
"
]
=
mock_deliver
mock_deliver
.
side_effect
=
Exception
()
with
LogCapture
()
as
capture
:
driver
.
mco
.
event
=
MCOStartEvent
()
driver
.
mco
.
started
=
True
self
.
assertTrue
(
mock_deliver
.
called
)
capture
.
check
(
...
...
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