Updated simple plugin test
This commit is contained in:
parent
4638071a00
commit
eb5c9c3fee
3 changed files with 63 additions and 7 deletions
1
openflexure_microscope/plugins/testing/__init__.py
Normal file
1
openflexure_microscope/plugins/testing/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from .plugin import Plugin
|
||||||
13
openflexure_microscope/plugins/testing/plugin.py
Normal file
13
openflexure_microscope/plugins/testing/plugin.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from openflexure_microscope.plugins import MicroscopePlugin
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(MicroscopePlugin):
|
||||||
|
"""
|
||||||
|
A set of default plugins
|
||||||
|
"""
|
||||||
|
|
||||||
|
def identify(self):
|
||||||
|
"""
|
||||||
|
Tests for access to Microscope.camera, and Microscope.stage
|
||||||
|
"""
|
||||||
|
return (self.microscope.camera, self.microscope.stage)
|
||||||
|
|
@ -4,19 +4,61 @@ from openflexure_stage import OpenFlexureStage
|
||||||
from openflexure_microscope import Microscope, config
|
from openflexure_microscope import Microscope, config
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
import logging, sys
|
import logging, sys
|
||||||
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
||||||
|
|
||||||
|
success_string = """
|
||||||
|
/O
|
||||||
|
| |
|
||||||
|
_____) \\
|
||||||
|
(__0) \\______
|
||||||
|
(____0)
|
||||||
|
(____0) EVERYTHING IS OK!
|
||||||
|
(__o)___________
|
||||||
|
"""
|
||||||
|
|
||||||
|
class TestPluginMethods(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_testplugin_load(self):
|
||||||
|
plugin_arr = microscope.plugin.plugins
|
||||||
|
|
||||||
|
plugin_names = [plugin[0] for plugin in plugin_arr]
|
||||||
|
|
||||||
|
self.assertTrue('testing' in plugin_names)
|
||||||
|
|
||||||
|
def test_camera_access(self):
|
||||||
|
identify = microscope.plugin.testing.identify()
|
||||||
|
self.assertTrue(identify[0] is microscope.camera)
|
||||||
|
|
||||||
|
def test_stage_access(self):
|
||||||
|
identify = microscope.plugin.testing.identify()
|
||||||
|
self.assertTrue(identify[1] is microscope.stage)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
openflexurerc = config.load_config()
|
|
||||||
|
|
||||||
print(openflexurerc)
|
openflexurerc = {
|
||||||
|
'plugins': [
|
||||||
|
'openflexure_microscope.plugins.testing:Plugin'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
microscope = Microscope(StreamingCamera(config=openflexurerc), OpenFlexureStage("/dev/ttyUSB0"), config=openflexurerc)
|
with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage:
|
||||||
|
|
||||||
print(microscope.plugin.plugins)
|
microscope = Microscope(camera, stage, openflexurerc)
|
||||||
|
|
||||||
# Check that default tets plugins have loaded
|
suites = [
|
||||||
print(microscope.plugin.default.identify())
|
unittest.TestLoader().loadTestsFromTestCase(TestPluginMethods),
|
||||||
|
]
|
||||||
|
|
||||||
microscope.close()
|
alltests = unittest.TestSuite(suites)
|
||||||
|
|
||||||
|
result = unittest.TextTestRunner(verbosity=2).run(alltests)
|
||||||
|
|
||||||
|
if result.wasSuccessful():
|
||||||
|
print(success_string)
|
||||||
|
|
||||||
|
microscope.close()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue