diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2016-11-13 22:04:18 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2016-11-13 22:04:18 +0900 |
commit | 1671daf03bd6fad7afba603188d782a332b57a9b (patch) | |
tree | e5faff2256374a2aaff865d1737e7ee2e4ef1f98 /tests/plugins | |
parent | cdddd8adba09fe4b0a71e7a13f5c2b9b12c1108b (diff) | |
download | buildstream-1671daf03bd6fad7afba603188d782a332b57a9b.tar.gz |
Adding test ensuring we can load different plugins with the same name
This is important, since a Pipeline can recurse into other Pipelines,
it's important that the user provided plugins loaded for each respective
pipeline are clearly separated. Two projects may declare plugin 'foo' and
do so differently.
This test simply loads two clearly different plugins both named 'foo'
but does so in different plugin contexts, and tests that these plugins
are indeed different implementations for each context.
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/basics.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/plugins/basics.py b/tests/plugins/basics.py index f4b6a1699..1e844fcd5 100644 --- a/tests/plugins/basics.py +++ b/tests/plugins/basics.py @@ -146,3 +146,41 @@ def test_element_bad_setup(plugin_fixture, datafiles): with pytest.raises(PluginError) as exc: factory = _ElementFactory(plugin_fixture['base'], [ os.path.join(datafiles.dirname, datafiles.basename) ]) + +############################################################## +# Check we can load different contexts of plugin # +############################################################## + +# Load two factories, both of which define a different 'foo' plugin +@pytest.mark.datafiles(DATA_DIR) +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)) + + foo_type1 = factory1.lookup('foo') + foo_type2 = factory2.lookup('foo') + + assert(foo_type1.__name__ == 'FooSource') + assert(foo_type2.__name__ == 'AnotherFooSource') + +# Load two factories, both of which define a different 'foo' plugin +@pytest.mark.datafiles(DATA_DIR) +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)) + + foo_type1 = factory1.lookup('foo') + foo_type2 = factory2.lookup('foo') + + assert(foo_type1.__name__ == 'FooElement') + assert(foo_type2.__name__ == 'AnotherFooElement') |