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
ff7edeb8
Commit
ff7edeb8
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Added Null plugin to mock the execution of the core evaluation driver
parent
90986bc0
No related branches found
No related tags found
1 merge request
!55
Remove application and model from bundles. Added plugin reference.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
force_bdss/tests/test_core_evaluation_driver.py
+114
-0
114 additions, 0 deletions
force_bdss/tests/test_core_evaluation_driver.py
with
114 additions
and
0 deletions
force_bdss/tests/test_core_evaluation_driver.py
0 → 100644
+
114
−
0
View file @
ff7edeb8
import
unittest
from
force_bdss.bundle_registry_plugin
import
BundleRegistryPlugin
from
force_bdss.data_sources.base_data_source
import
BaseDataSource
from
force_bdss.data_sources.base_data_source_bundle
import
\
BaseDataSourceBundle
from
force_bdss.data_sources.base_data_source_model
import
BaseDataSourceModel
from
force_bdss.kpi.base_kpi_calculator
import
BaseKPICalculator
from
force_bdss.kpi.base_kpi_calculator_bundle
import
BaseKPICalculatorBundle
from
force_bdss.kpi.base_kpi_calculator_model
import
BaseKPICalculatorModel
from
force_bdss.mco.base_mco
import
BaseMCO
from
force_bdss.mco.base_mco_bundle
import
BaseMCOBundle
from
force_bdss.mco.base_mco_communicator
import
BaseMCOCommunicator
from
force_bdss.mco.base_mco_model
import
BaseMCOModel
from
force_bdss.tests
import
fixtures
try
:
import
mock
except
ImportError
:
from
unittest
import
mock
from
envisage.api
import
Application
from
force_bdss.core_evaluation_driver
import
CoreEvaluationDriver
class
NullMCOModel
(
BaseMCOModel
):
pass
class
NullMCO
(
BaseMCO
):
def
run
(
self
,
model
):
pass
class
NullMCOCommunicator
(
BaseMCOCommunicator
):
def
send_to_mco
(
self
,
model
,
kpi_results
):
pass
def
receive_from_mco
(
self
,
model
):
pass
class
NullMCOBundle
(
BaseMCOBundle
):
def
create_model
(
self
,
model_data
=
None
):
return
NullMCOModel
(
self
)
def
create_communicator
(
self
):
return
NullMCOCommunicator
(
self
)
def
create_optimizer
(
self
):
return
NullMCO
(
self
)
class
NullKPICalculatorModel
(
BaseKPICalculatorModel
):
pass
class
NullKPICalculator
(
BaseKPICalculator
):
def
run
(
self
,
model
,
data_source_results
):
pass
class
NullKPICalculatorBundle
(
BaseKPICalculatorBundle
):
def
create_model
(
self
,
model_data
=
None
):
return
NullKPICalculatorModel
(
self
)
def
create_kpi_calculator
(
self
):
return
NullKPICalculator
(
self
)
class
NullDataSourceModel
(
BaseDataSourceModel
):
pass
class
NullDataSource
(
BaseDataSource
):
def
run
(
self
,
model
,
parameters
):
pass
class
NullDataSourceBundle
(
BaseDataSourceBundle
):
def
create_model
(
self
,
model_data
=
None
):
return
NullDataSourceModel
(
self
)
def
create_data_source
(
self
):
return
NullDataSource
(
self
)
def
mock_bundle_registry_plugin
():
bundle_registry_plugin
=
mock
.
Mock
(
spec
=
BundleRegistryPlugin
)
bundle_registry_plugin
.
mco_bundle_by_id
=
mock
.
Mock
(
return_value
=
NullMCOBundle
(
bundle_registry_plugin
))
bundle_registry_plugin
.
kpi_calculator_bundle_by_id
=
mock
.
Mock
(
return_value
=
NullKPICalculatorBundle
(
bundle_registry_plugin
))
bundle_registry_plugin
.
data_source_bundle_by_id
=
mock
.
Mock
(
return_value
=
NullDataSourceBundle
(
bundle_registry_plugin
))
return
bundle_registry_plugin
class
TestCoreEvaluationDriver
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
mock_bundle_registry_plugin
=
mock_bundle_registry_plugin
()
application
=
mock
.
Mock
(
spec
=
Application
)
application
.
get_plugin
=
mock
.
Mock
(
return_value
=
self
.
mock_bundle_registry_plugin
)
application
.
workflow_filepath
=
fixtures
.
get
(
"
test_csv.json
"
)
self
.
mock_application
=
application
def
test_initialization
(
self
):
driver
=
CoreEvaluationDriver
(
application
=
self
.
mock_application
,
)
driver
.
application_started
()
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