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
22904141
Commit
22904141
authored
7 years ago
by
martinRenou
Browse files
Options
Downloads
Patches
Plain Diff
Create first version of a Probe class for a KPICalculator
parent
b90f7f74
No related branches found
No related tags found
1 merge request
!101
Create probe classes for tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
force_bdss/tests/probe_classes.py
+91
-0
91 additions, 0 deletions
force_bdss/tests/probe_classes.py
with
91 additions
and
0 deletions
force_bdss/tests/probe_classes.py
0 → 100644
+
91
−
0
View file @
22904141
try
:
import
mock
except
ImportError
:
from
unittest
import
mock
from
envisage.plugin
import
Plugin
from
traits.api
import
HasStrictTraits
,
Bool
,
Function
,
Str
,
Int
,
Dict
from
force_bdss.api
import
(
BaseKPICalculatorFactory
,
BaseKPICalculatorModel
,
BaseKPICalculator
,
Slot
)
class
ProbeEvaluator
(
HasStrictTraits
):
run_function
=
Function
input_slots_type
=
Str
(
'
PRESSURE
'
)
output_slots_type
=
Str
(
'
PRESSURE
'
)
input_slots_size
=
Int
(
0
)
output_slots_size
=
Int
(
0
)
run_called
=
Bool
(
False
)
slots_called
=
Bool
(
False
)
def
run
(
self
,
model
,
parameters
):
self
.
run_called
=
True
self
.
run_function
(
model
,
parameters
)
def
slots
(
self
,
model
):
self
.
slots_called
=
True
return
(
tuple
(
Slot
(
type
=
self
.
input_slots_type
)
for
_
in
range
(
self
.
input_slots_size
))
),
(
tuple
(
Slot
(
type
=
self
.
output_slots_type
)
for
_
in
range
(
self
.
output_slots_size
))
)
class
ProbeEvaluatorFactory
(
HasStrictTraits
):
run_function
=
Function
input_slots_type
=
Str
(
'
PRESSURE
'
)
output_slots_type
=
Str
(
'
PRESSURE
'
)
input_slots_size
=
Int
(
0
)
output_slots_size
=
Int
(
0
)
model_data
=
Dict
()
class
ProbeKPICalculator
(
BaseKPICalculator
,
ProbeEvaluator
):
pass
class
ProbeKPICalculatorModel
(
BaseKPICalculatorModel
):
def
__init__
(
self
,
factory
,
model_data
,
*
args
,
**
kwargs
):
for
key
,
value
in
model_data
.
items
():
setattr
(
self
,
key
,
value
)
super
(
ProbeKPICalculatorModel
,
self
).
__init__
(
self
,
factory
,
*
args
,
**
kwargs
)
class
ProbeKPICalculatorFactory
(
BaseKPICalculatorFactory
,
ProbeEvaluatorFactory
):
id
=
Str
(
'
enthought.test.datasource
'
)
name
=
Str
(
'
test_datasource
'
)
def
__init__
(
self
,
plugin
=
None
,
*
args
,
**
kwargs
):
if
plugin
is
None
:
plugin
=
mock
.
Mock
(
Plugin
)
super
(
ProbeKPICalculatorFactory
,
self
).
__init__
(
plugin
=
plugin
,
*
args
,
**
kwargs
)
def
create_model
(
self
,
model_data
=
None
):
return
ProbeKPICalculatorModel
(
self
,
self
.
model_data
)
def
create_kpi_calculator
(
self
):
return
ProbeKPICalculator
(
factory
=
self
,
run_function
=
self
.
run_function
,
input_slots_type
=
self
.
input_slots_type
,
output_slots_type
=
self
.
output_slots_type
,
input_slots_size
=
self
.
input_slots_size
,
output_slots_size
=
self
.
output_slots_size
)
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