Skip to content
Snippets Groups Projects
Commit 70012153 authored by Tiago Gomes's avatar Tiago Gomes
Browse files

tests: test local plugins and element-path paths

parent ca9eacca
No related branches found
No related tags found
No related merge requests found
Pipeline #26894491 failed
import os
import pytest
from buildstream._exceptions import LoadError, LoadErrorReason
from buildstream._context import Context
from buildstream._project import Project
from tests.testutils import filetypegenerator
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'project',
)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing-element-path'))
def test_missing_element_path_directory(datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
context = Context()
with pytest.raises(LoadError) as exc:
project = Project(project, context)
assert (exc.value.reason == LoadErrorReason.MISSING_FILE)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing-element-path'))
def test_invalid_element_path_directory(datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
context = Context()
path = os.path.join(project, 'elements')
for file_type in filetypegenerator.generate_file_types(path):
if not os.path.isdir(path):
with pytest.raises(LoadError) as exc:
project = Project(project, context)
assert (exc.value.reason == LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
def test_missing_local_plugin_directory(datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
context = Context()
with pytest.raises(LoadError) as exc:
project = Project(project, context)
assert (exc.value.reason == LoadErrorReason.MISSING_FILE)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
def test_invalid_local_plugin_directory(datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
context = Context()
path = os.path.join(project, 'plugins')
for file_type in filetypegenerator.generate_file_types(path):
if not os.path.isdir(path):
with pytest.raises(LoadError) as exc:
project = Project(project, context)
assert (exc.value.reason == LoadErrorReason.INVALID_DATA)
name: foo
plugins:
- origin: local
path: plugins
sources:
mysource: 0
name: foo
element-path: elements
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment