summaryrefslogtreecommitdiff
path: root/tests/plugins/basics.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/basics.py')
-rw-r--r--tests/plugins/basics.py188
1 files changed, 112 insertions, 76 deletions
diff --git a/tests/plugins/basics.py b/tests/plugins/basics.py
index 993d87cec..740a20c66 100644
--- a/tests/plugins/basics.py
+++ b/tests/plugins/basics.py
@@ -43,9 +43,13 @@ def test_element_factory(plugin_fixture):
##############################################################
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'customsource'))
def test_custom_source(plugin_fixture, datafiles):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
assert(isinstance(factory, SourceFactory))
foo_type, _ = factory.lookup('foo')
@@ -54,9 +58,13 @@ def test_custom_source(plugin_fixture, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'customelement'))
def test_custom_element(plugin_fixture, datafiles):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
assert(isinstance(factory, ElementFactory))
foo_type, _ = factory.lookup('foo')
@@ -84,40 +92,16 @@ def test_missing_element(plugin_fixture):
foo_type = factory.lookup('foo')
-# Load one factory with 2 plugin directories both containing a foo plugin
-@pytest.mark.datafiles(DATA_DIR)
-def test_conflict_source(plugin_fixture, datafiles):
- plugins1 = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'customsource')
- plugins2 = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'anothersource')
-
- with pytest.raises(PluginError) as exc:
- factory = SourceFactory(plugin_fixture['base'], [plugins1, plugins2])
-
-
-# Load one factory with 2 plugin directories both containing a foo plugin
-@pytest.mark.datafiles(DATA_DIR)
-def test_conflict_element(plugin_fixture, datafiles):
- plugins1 = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'customelement')
- plugins2 = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'anotherelement')
-
- with pytest.raises(PluginError) as exc:
- factory = ElementFactory(plugin_fixture['base'], [plugins1, plugins2])
-
-
# Load a factory with a plugin that returns a value instead of Source subclass
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'notatype'))
def test_source_notatype(plugin_fixture, datafiles):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -125,9 +109,13 @@ def test_source_notatype(plugin_fixture, datafiles):
# Load a factory with a plugin that returns a value instead of Element subclass
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'notatype'))
def test_element_notatype(plugin_fixture, datafiles):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -136,9 +124,13 @@ def test_element_notatype(plugin_fixture, datafiles):
# which is not a Source subclass
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'wrongtype'))
def test_source_wrongtype(plugin_fixture, datafiles):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -147,9 +139,13 @@ def test_source_wrongtype(plugin_fixture, datafiles):
# which is not a Element subclass
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'wrongtype'))
def test_element_wrongtype(plugin_fixture, datafiles):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -157,9 +153,13 @@ def test_element_wrongtype(plugin_fixture, datafiles):
# 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):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -167,9 +167,13 @@ def test_source_missing_setup(plugin_fixture, datafiles):
# 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):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -178,9 +182,13 @@ def test_element_missing_setup(plugin_fixture, datafiles):
# that is not a function
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badsetup'))
def test_source_bad_setup(plugin_fixture, datafiles):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -189,9 +197,13 @@ def test_source_bad_setup(plugin_fixture, datafiles):
# that is not a function
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badsetup'))
def test_element_bad_setup(plugin_fixture, datafiles):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -200,9 +212,13 @@ def test_element_bad_setup(plugin_fixture, datafiles):
# high version of buildstream
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionsource'))
def test_source_badversion(plugin_fixture, datafiles):
- factory = SourceFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = SourceFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -211,9 +227,13 @@ def test_source_badversion(plugin_fixture, datafiles):
# high version of buildstream
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'badversionelement'))
def test_element_badversion(plugin_fixture, datafiles):
- factory = ElementFactory(plugin_fixture['base'],
- [os.path.join(datafiles.dirname,
- datafiles.basename)])
+ plugins = [{
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename),
+ 'plugins': {'foo': 0}
+ }]
+ factory = ElementFactory(plugin_fixture['base'], plugins)
with pytest.raises(PluginError) as exc:
foo_type = factory.lookup('foo')
@@ -225,12 +245,20 @@ def test_element_badversion(plugin_fixture, datafiles):
# 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')
+ plugins1 = {
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename,
+ 'customsource'),
+ 'plugins': {'foo': 0}
+ }
+ plugins2 = {
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename,
+ 'anothersource'),
+ 'plugins': {'foo': 0}
+ }
factory1 = SourceFactory(plugin_fixture['base'], [plugins1])
factory2 = SourceFactory(plugin_fixture['base'], [plugins2])
@@ -246,12 +274,20 @@ def test_source_multicontext(plugin_fixture, datafiles):
# 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')
+ plugins1 = {
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename,
+ 'customelement'),
+ 'plugins': {'foo': 0}
+ }
+ plugins2 = {
+ 'origin': 'local',
+ 'path': os.path.join(datafiles.dirname,
+ datafiles.basename,
+ 'anotherelement'),
+ 'plugins': {'foo': 0}
+ }
factory1 = ElementFactory(plugin_fixture['base'], [plugins1])
factory2 = ElementFactory(plugin_fixture['base'], [plugins2])