diff options
Diffstat (limited to 'tests/plugins/basics.py')
-rw-r--r-- | tests/plugins/basics.py | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/tests/plugins/basics.py b/tests/plugins/basics.py index 0654b08af..539500169 100644 --- a/tests/plugins/basics.py +++ b/tests/plugins/basics.py @@ -2,8 +2,8 @@ import os import pytest from pluginbase import PluginBase -from buildstream._elementfactory import _ElementFactory -from buildstream._sourcefactory import _SourceFactory +from buildstream._elementfactory import ElementFactory +from buildstream._sourcefactory import SourceFactory from buildstream import PluginError DATA_DIR = os.path.join( @@ -26,30 +26,30 @@ def test_fixture(plugin_fixture): assert(isinstance(plugin_fixture['base'], PluginBase)) def test_source_factory(plugin_fixture): - factory = _SourceFactory(plugin_fixture['base']) - assert(isinstance(factory, _SourceFactory)) + factory = SourceFactory(plugin_fixture['base']) + assert(isinstance(factory, SourceFactory)) def test_element_factory(plugin_fixture): - factory = _ElementFactory(plugin_fixture['base']) - assert(isinstance(factory, _ElementFactory)) + factory = ElementFactory(plugin_fixture['base']) + assert(isinstance(factory, ElementFactory)) ############################################################## # Check that we can load custom sources & elements # ############################################################## @pytest.mark.datafiles(os.path.join(DATA_DIR, 'customsource')) def test_custom_source(plugin_fixture, datafiles): - factory = _SourceFactory(plugin_fixture['base'], + factory = SourceFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) - assert(isinstance(factory, _SourceFactory)) + assert(isinstance(factory, SourceFactory)) foo_type = factory.lookup('foo') assert(foo_type.__name__ == 'FooSource') @pytest.mark.datafiles(os.path.join(DATA_DIR, 'customelement')) def test_custom_element(plugin_fixture, datafiles): - factory = _ElementFactory(plugin_fixture['base'], + factory = ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) - assert(isinstance(factory, _ElementFactory)) + assert(isinstance(factory, ElementFactory)) foo_type = factory.lookup('foo') assert(foo_type.__name__ == 'FooElement') @@ -58,16 +58,16 @@ def test_custom_element(plugin_fixture, datafiles): # Check plugin loading failure modes # ############################################################## def test_missing_source(plugin_fixture): - factory = _SourceFactory(plugin_fixture['base']) - assert(isinstance(factory, _SourceFactory)) + factory = SourceFactory(plugin_fixture['base']) + assert(isinstance(factory, SourceFactory)) # Test fails if PluginError is not raised with pytest.raises(PluginError) as exc: foo_type = factory.lookup('foo') def test_missing_element(plugin_fixture): - factory = _ElementFactory(plugin_fixture['base']) - assert(isinstance(factory, _ElementFactory)) + factory = ElementFactory(plugin_fixture['base']) + assert(isinstance(factory, ElementFactory)) # Test fails if PluginError is not raised with pytest.raises(PluginError) as exc: @@ -80,7 +80,7 @@ def test_conflict_source(plugin_fixture, datafiles): plugins2 = os.path.join(datafiles.dirname, datafiles.basename, 'anothersource') with pytest.raises(PluginError) as exc: - factory = _SourceFactory(plugin_fixture['base'], [ plugins1, plugins2 ]) + factory = SourceFactory(plugin_fixture['base'], [ plugins1, plugins2 ]) # Load one factory with 2 plugin directories both containing a foo plugin @pytest.mark.datafiles(DATA_DIR) @@ -89,62 +89,62 @@ def test_conflict_element(plugin_fixture, datafiles): plugins2 = os.path.join(datafiles.dirname, datafiles.basename, 'anotherelement') with pytest.raises(PluginError) as exc: - factory = _ElementFactory(plugin_fixture['base'], [ plugins1, plugins2 ]) + factory = ElementFactory(plugin_fixture['base'], [ plugins1, plugins2 ]) # Load a factory with a plugin that returns a value instead of a Source subclass @pytest.mark.datafiles(os.path.join(DATA_DIR, 'notatype')) def test_source_notatype(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _SourceFactory(plugin_fixture['base'], + factory = SourceFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin that returns a value instead of a Element subclass @pytest.mark.datafiles(os.path.join(DATA_DIR, 'notatype')) def test_element_notatype(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _ElementFactory(plugin_fixture['base'], + factory = ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin that returns a type which is not a Source subclass @pytest.mark.datafiles(os.path.join(DATA_DIR, 'wrongtype')) def test_source_wrongtype(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _SourceFactory(plugin_fixture['base'], + factory = SourceFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin that returns a type which is not a Element subclass @pytest.mark.datafiles(os.path.join(DATA_DIR, 'wrongtype')) def test_element_wrongtype(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _ElementFactory(plugin_fixture['base'], + factory = ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin which fails to provide a setup() function @pytest.mark.datafiles(os.path.join(DATA_DIR, 'nosetup')) def test_source_missing_setup(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _SourceFactory(plugin_fixture['base'], + factory = SourceFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin which fails to provide a setup() function @pytest.mark.datafiles(os.path.join(DATA_DIR, 'nosetup')) def test_element_missing_setup(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _ElementFactory(plugin_fixture['base'], + factory = ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin which provides a setup symbol that is not a function @pytest.mark.datafiles(os.path.join(DATA_DIR, 'badsetup')) def test_source_bad_setup(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _SourceFactory(plugin_fixture['base'], + factory = SourceFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) # Load a factory with a plugin which provides a setup symbol that is not a function @pytest.mark.datafiles(os.path.join(DATA_DIR, 'badsetup')) def test_element_bad_setup(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: - factory = _ElementFactory(plugin_fixture['base'], + factory = ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) ############################################################## @@ -157,10 +157,10 @@ def test_source_multicontext(plugin_fixture, datafiles): plugins1 = os.path.join(datafiles.dirname, datafiles.basename, 'customsource') plugins2 = os.path.join(datafiles.dirname, datafiles.basename, 'anothersource') - factory1 = _SourceFactory(plugin_fixture['base'], [ plugins1 ]) - factory2 = _SourceFactory(plugin_fixture['base'], [ plugins2 ]) - assert(isinstance(factory1, _SourceFactory)) - assert(isinstance(factory2, _SourceFactory)) + factory1 = SourceFactory(plugin_fixture['base'], [ plugins1 ]) + factory2 = SourceFactory(plugin_fixture['base'], [ plugins2 ]) + assert(isinstance(factory1, SourceFactory)) + assert(isinstance(factory2, SourceFactory)) foo_type1 = factory1.lookup('foo') foo_type2 = factory2.lookup('foo') @@ -173,10 +173,10 @@ def test_element_multicontext(plugin_fixture, datafiles): plugins1 = os.path.join(datafiles.dirname, datafiles.basename, 'customelement') plugins2 = os.path.join(datafiles.dirname, datafiles.basename, 'anotherelement') - factory1 = _ElementFactory(plugin_fixture['base'], [ plugins1 ]) - factory2 = _ElementFactory(plugin_fixture['base'], [ plugins2 ]) - assert(isinstance(factory1, _ElementFactory)) - assert(isinstance(factory2, _ElementFactory)) + factory1 = ElementFactory(plugin_fixture['base'], [ plugins1 ]) + factory2 = ElementFactory(plugin_fixture['base'], [ plugins2 ]) + assert(isinstance(factory1, ElementFactory)) + assert(isinstance(factory2, ElementFactory)) foo_type1 = factory1.lookup('foo') foo_type2 = factory2.lookup('foo') |