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
fc9ece08
Commit
fc9ece08
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Transported UI hooks probe and integrated it
parent
1b931729
No related branches found
No related tags found
1 merge request
!105
Introduced interface for FactoryRegistryPlugin
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
force_bdss/tests/probe_classes/factory_registry_plugin.py
+6
-0
6 additions, 0 deletions
force_bdss/tests/probe_classes/factory_registry_plugin.py
force_bdss/tests/probe_classes/ui_hooks.py
+52
-0
52 additions, 0 deletions
force_bdss/tests/probe_classes/ui_hooks.py
with
58 additions
and
0 deletions
force_bdss/tests/probe_classes/factory_registry_plugin.py
+
6
−
0
View file @
fc9ece08
...
@@ -6,6 +6,7 @@ from .mco import ProbeMCOFactory
...
@@ -6,6 +6,7 @@ from .mco import ProbeMCOFactory
from
.kpi_calculator
import
ProbeKPICalculatorFactory
from
.kpi_calculator
import
ProbeKPICalculatorFactory
from
.data_source
import
ProbeDataSourceFactory
from
.data_source
import
ProbeDataSourceFactory
from
.notification_listener
import
ProbeNotificationListenerFactory
from
.notification_listener
import
ProbeNotificationListenerFactory
from
.ui_hooks
import
ProbeUIHooksFactory
@provides
(
IFactoryRegistryPlugin
)
@provides
(
IFactoryRegistryPlugin
)
...
@@ -14,6 +15,7 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
...
@@ -14,6 +15,7 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
kpi_calculator_factories
=
List
()
kpi_calculator_factories
=
List
()
data_source_factories
=
List
()
data_source_factories
=
List
()
notification_listener_factories
=
List
()
notification_listener_factories
=
List
()
ui_hooks_factories
=
List
()
def
_mco_factories_default
(
self
):
def
_mco_factories_default
(
self
):
return
[
ProbeMCOFactory
(
None
)]
return
[
ProbeMCOFactory
(
None
)]
...
@@ -27,6 +29,9 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
...
@@ -27,6 +29,9 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
def
_notification_listener_factories_default
(
self
):
def
_notification_listener_factories_default
(
self
):
return
[
ProbeNotificationListenerFactory
(
None
)]
return
[
ProbeNotificationListenerFactory
(
None
)]
def
_ui_hooks_factories_default
(
self
):
return
[
ProbeUIHooksFactory
(
None
)]
def
data_source_factory_by_id
(
self
,
id
):
def
data_source_factory_by_id
(
self
,
id
):
for
ds
in
self
.
data_source_factories
:
for
ds
in
self
.
data_source_factories
:
if
ds
.
id
==
id
:
if
ds
.
id
==
id
:
...
@@ -63,3 +68,4 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
...
@@ -63,3 +68,4 @@ class ProbeFactoryRegistryPlugin(HasStrictTraits):
return
nl
return
nl
raise
KeyError
(
id
)
raise
KeyError
(
id
)
This diff is collapsed.
Click to expand it.
force_bdss/tests/probe_classes/ui_hooks.py
0 → 100644
+
52
−
0
View file @
fc9ece08
try
:
import
mock
except
ImportError
:
from
unittest
import
mock
from
envisage.api
import
Plugin
from
traits.api
import
Bool
from
force_bdss.api
import
BaseUIHooksFactory
,
BaseUIHooksManager
class
ProbeUIHooksManager
(
BaseUIHooksManager
):
before_execution_called
=
Bool
()
after_execution_called
=
Bool
()
before_save_called
=
Bool
()
# Set this one to raise an exception in the methods
before_execution_raises
=
Bool
(
False
)
after_execution_raises
=
Bool
(
False
)
before_save_raises
=
Bool
(
False
)
def
before_execution
(
self
,
task
):
self
.
before_execution_called
=
True
if
self
.
before_execution_raises
:
raise
Exception
(
"
Boom
"
)
def
after_execution
(
self
,
task
):
self
.
after_execution_called
=
True
if
self
.
after_execution_raises
:
raise
Exception
(
"
Boom
"
)
def
before_save
(
self
,
task
):
self
.
before_save_called
=
True
if
self
.
before_save_raises
:
raise
Exception
(
"
Boom
"
)
class
ProbeUIHooksFactory
(
BaseUIHooksFactory
):
create_ui_hooks_manager_raises
=
Bool
()
def
__init__
(
self
,
plugin
=
None
,
*
args
,
**
kwargs
):
if
plugin
is
None
:
plugin
=
mock
.
Mock
(
Plugin
)
super
(
ProbeUIHooksFactory
,
self
).
__init__
(
plugin
=
plugin
,
*
args
,
**
kwargs
)
def
create_ui_hooks_manager
(
self
):
if
self
.
create_ui_hooks_manager_raises
:
raise
Exception
(
"
Boom
"
)
return
ProbeUIHooksManager
(
self
)
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