summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2016-11-28 17:30:48 +0000
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2016-11-28 17:37:31 +0000
commitb2de60fc37a8e218c6264dd160714e043a63f313 (patch)
tree4b41d973e9351b5e7c385dc6ca7189fdffa13106
parent514c3c09e90594ef594b719d99fcc28c5adfcb7a (diff)
downloadbuildstream-b2de60fc37a8e218c6264dd160714e043a63f313.tar.gz
Updating context tests now that we've changed to use the _yaml module
-rw-r--r--tests/context/__init__.py0
-rw-r--r--tests/context/context.py23
-rw-r--r--tests/context/data/invalidtype.yaml3
3 files changed, 25 insertions, 1 deletions
diff --git a/tests/context/__init__.py b/tests/context/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/context/__init__.py
diff --git a/tests/context/context.py b/tests/context/context.py
index a785b6628..ae4effad1 100644
--- a/tests/context/context.py
+++ b/tests/context/context.py
@@ -2,7 +2,7 @@ import os
import pytest
from buildstream import Context
-from buildstream import LoadError
+from buildstream import LoadError, LoadErrorReason
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -73,6 +73,8 @@ def test_context_load_missing_config(context_fixture, datafiles):
with pytest.raises(LoadError) as exc:
context.load(conf_file)
+ assert (exc.value.reason == LoadErrorReason.MISSING_FILE)
+
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_context_load_malformed_config(context_fixture, datafiles):
context = context_fixture['context']
@@ -85,6 +87,8 @@ def test_context_load_malformed_config(context_fixture, datafiles):
with pytest.raises(LoadError) as exc:
context.load(conf_file)
+ assert (exc.value.reason == LoadErrorReason.INVALID_YAML)
+
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_context_load_notdict_config(context_fixture, datafiles):
context = context_fixture['context']
@@ -96,3 +100,20 @@ def test_context_load_notdict_config(context_fixture, datafiles):
with pytest.raises(LoadError) as exc:
context.load(conf_file)
+
+ # XXX Should this be a different LoadErrorReason ?
+ assert (exc.value.reason == LoadErrorReason.INVALID_YAML)
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+def test_context_load_invalid_type(context_fixture, datafiles):
+ context = context_fixture['context']
+ assert(isinstance(context, Context))
+
+ conf_file = os.path.join(datafiles.dirname,
+ datafiles.basename,
+ 'invalidtype.yaml')
+
+ with pytest.raises(LoadError) as exc:
+ context.load(conf_file)
+
+ assert (exc.value.reason == LoadErrorReason.ILLEGAL_COMPOSITE)
diff --git a/tests/context/data/invalidtype.yaml b/tests/context/data/invalidtype.yaml
new file mode 100644
index 000000000..3eb3200a8
--- /dev/null
+++ b/tests/context/data/invalidtype.yaml
@@ -0,0 +1,3 @@
+# Specify wrong value type for something
+
+sourcedir: 5