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
cfdf5d8d
Commit
cfdf5d8d
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into remove-old-plugins
parents
8629eb23
fdc66ae1
No related branches found
No related tags found
1 merge request
!47
Aggregate old plugins under the "dummy" core plugin
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
force_bdss/bdss_application.py
+29
-9
29 additions, 9 deletions
force_bdss/bdss_application.py
force_bdss/tests/test_bdss_application.py
+43
-0
43 additions, 0 deletions
force_bdss/tests/test_bdss_application.py
requirements/dev_requirements.txt
+1
-0
1 addition, 0 deletions
requirements/dev_requirements.txt
with
73 additions
and
9 deletions
force_bdss/bdss_application.py
+
29
−
9
View file @
cfdf5d8d
from
stevedore
import
extension
import
functools
import
logging
from
stevedore.extension
import
ExtensionManager
from
stevedore.exception
import
NoMatches
from
envisage.api
import
Application
...
...
@@ -34,18 +37,35 @@ class BDSSApplication(Application):
else
:
plugins
.
append
(
CoreMCODriver
())
mgr
=
extension
.
ExtensionManager
(
mgr
=
ExtensionManager
(
namespace
=
'
force.bdss.extensions
'
,
invoke_on_load
=
True
invoke_on_load
=
True
,
on_load_failure_callback
=
functools
.
partial
(
_load_failure_callback
,
plugins
)
)
def
import_extensions
(
ext
):
print
(
"
Found extension {}
"
.
format
(
ext
.
name
))
plugins
.
append
(
ext
.
obj
)
try
:
mgr
.
map
(
import_extensions
)
mgr
.
map
(
functools
.
partial
(
_
import_extensions
,
plugins
)
)
except
NoMatches
:
print
(
"
No extensions found
"
)
logging
.
info
(
"
No extensions found
"
)
super
(
BDSSApplication
,
self
).
__init__
(
plugins
=
plugins
)
def
_import_extensions
(
plugins
,
ext
):
"""
Service routine extracted for testing.
Imports the extension in the plugins argument.
"""
logging
.
info
(
"
Found extension {}
"
.
format
(
ext
.
obj
))
plugins
.
append
(
ext
.
obj
)
def
_load_failure_callback
(
plugins
,
manager
,
entry_point
,
exception
):
"""
Service routine extracted for testing.
Reports failure to load a module through stevedore, using the
on_load_failure_callback option.
"""
logging
.
error
(
"
Unable to load plugin {}. Exception: {}. Message: {}
"
.
format
(
entry_point
,
exception
.
__class__
.
__name__
,
exception
)
)
This diff is collapsed.
Click to expand it.
force_bdss/tests/test_bdss_application.py
0 → 100644
+
43
−
0
View file @
cfdf5d8d
import
unittest
import
testfixtures
from
force_bdss.bdss_application
import
(
BDSSApplication
,
_load_failure_callback
,
_import_extensions
)
try
:
import
mock
except
ImportError
:
from
unittest
import
mock
class
TestBDSSApplication
(
unittest
.
TestCase
):
def
test_initialization
(
self
):
app
=
BDSSApplication
(
False
,
"
foo/bar
"
)
self
.
assertFalse
(
app
.
evaluate
)
self
.
assertEqual
(
app
.
workflow_filepath
,
"
foo/bar
"
)
def
test_extension_load_failure
(
self
):
plugins
=
[]
with
testfixtures
.
LogCapture
()
as
log
:
_load_failure_callback
(
plugins
,
mock
.
Mock
(),
"
foo
"
,
Exception
(
"
hello
"
))
log
.
check
(
(
'
root
'
,
'
ERROR
'
,
"
Unable to load plugin foo. Exception:
"
"
Exception. Message: hello
"
)
)
self
.
assertEqual
(
plugins
,
[])
def
test_import_extension
(
self
):
plugins
=
[]
plugin
=
mock
.
Mock
()
ext
=
mock
.
Mock
()
ext
.
obj
=
plugin
_import_extensions
(
plugins
,
ext
)
self
.
assertEqual
(
plugins
[
0
],
plugin
)
This diff is collapsed.
Click to expand it.
requirements/dev_requirements.txt
+
1
−
0
View file @
cfdf5d8d
flake8
coverage
mock
testfixtures
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