summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-17 17:10:43 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-17 20:14:10 +0900
commitc20b15417f7519a0bfb481aeaa4fa5307a6fdaf2 (patch)
tree28ecc87daa53907add0bc6b8e538facf377bc144
parentd4a6df027965861c9ac652c330b0ae7710f86878 (diff)
downloadbuildstream-c20b15417f7519a0bfb481aeaa4fa5307a6fdaf2.tar.gz
tests/yaml/, tests/format/: Added tests for list composition directives
-rw-r--r--tests/format/list-directive-error-element/config.bst7
-rw-r--r--tests/format/list-directive-error-element/environment.bst7
-rw-r--r--tests/format/list-directive-error-element/project.conf1
-rw-r--r--tests/format/list-directive-error-element/public.bst8
-rw-r--r--tests/format/list-directive-error-element/variables.bst7
-rw-r--r--tests/format/list-directive-error-project/element.bst1
-rw-r--r--tests/format/list-directive-error-project/project.conf6
-rw-r--r--tests/format/listdirectiveerrors.py41
-rw-r--r--tests/yaml/data/implicitoverwrite.yaml6
-rw-r--r--tests/yaml/data/listappend.yaml7
-rw-r--r--tests/yaml/data/listappendprepend.yaml12
-rw-r--r--tests/yaml/data/listoverwrite.yaml7
-rw-r--r--tests/yaml/data/listprepend.yaml7
-rw-r--r--tests/yaml/data/secondappend.yaml7
-rw-r--r--tests/yaml/data/secondprepend.yaml7
-rw-r--r--tests/yaml/yaml.py297
16 files changed, 324 insertions, 104 deletions
diff --git a/tests/format/list-directive-error-element/config.bst b/tests/format/list-directive-error-element/config.bst
new file mode 100644
index 000000000..f2d6a985a
--- /dev/null
+++ b/tests/format/list-directive-error-element/config.bst
@@ -0,0 +1,7 @@
+kind: autotools
+
+config:
+ outigration-frob-mans:
+ (>):
+ - name: Appending to something
+ - value: that is not integration-commands
diff --git a/tests/format/list-directive-error-element/environment.bst b/tests/format/list-directive-error-element/environment.bst
new file mode 100644
index 000000000..7a88e1a11
--- /dev/null
+++ b/tests/format/list-directive-error-element/environment.bst
@@ -0,0 +1,7 @@
+kind: autotools
+
+environment:
+ foo:
+ (=):
+ - name: Overriding
+ - value: Something that doesnt exist
diff --git a/tests/format/list-directive-error-element/project.conf b/tests/format/list-directive-error-element/project.conf
new file mode 100644
index 000000000..b32753625
--- /dev/null
+++ b/tests/format/list-directive-error-element/project.conf
@@ -0,0 +1 @@
+name: test
diff --git a/tests/format/list-directive-error-element/public.bst b/tests/format/list-directive-error-element/public.bst
new file mode 100644
index 000000000..8e49218be
--- /dev/null
+++ b/tests/format/list-directive-error-element/public.bst
@@ -0,0 +1,8 @@
+kind: autotools
+
+public:
+ foo:
+ the-foo-list:
+ (>):
+ - name: Appending to something
+ - value: that does not exist
diff --git a/tests/format/list-directive-error-element/variables.bst b/tests/format/list-directive-error-element/variables.bst
new file mode 100644
index 000000000..0a88d5fa7
--- /dev/null
+++ b/tests/format/list-directive-error-element/variables.bst
@@ -0,0 +1,7 @@
+kind: autotools
+
+variables:
+ foo:
+ (<):
+ - name: Prepending
+ - value: To something that doesnt exist
diff --git a/tests/format/list-directive-error-project/element.bst b/tests/format/list-directive-error-project/element.bst
new file mode 100644
index 000000000..3c29b4ea1
--- /dev/null
+++ b/tests/format/list-directive-error-project/element.bst
@@ -0,0 +1 @@
+kind: autotools
diff --git a/tests/format/list-directive-error-project/project.conf b/tests/format/list-directive-error-project/project.conf
new file mode 100644
index 000000000..dfba68b98
--- /dev/null
+++ b/tests/format/list-directive-error-project/project.conf
@@ -0,0 +1,6 @@
+name: test
+
+non-existant:
+ (>):
+ - name: Appending
+ - value: To something that doesnt exist
diff --git a/tests/format/listdirectiveerrors.py b/tests/format/listdirectiveerrors.py
new file mode 100644
index 000000000..001b8a49d
--- /dev/null
+++ b/tests/format/listdirectiveerrors.py
@@ -0,0 +1,41 @@
+import os
+import pytest
+from buildstream import _yaml
+from buildstream import LoadError, LoadErrorReason
+from tests.testutils.runcli import cli
+
+# Project directory
+DATA_DIR = os.path.dirname(os.path.realpath(__file__))
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_project_error(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'list-directive-error-project')
+ result = cli.run(project=project, silent=True, args=[
+ 'show',
+ '--deps', 'none',
+ '--format', '%{vars}',
+ 'element.bst'])
+
+ assert result.exit_code != 0
+ assert result.exception
+ assert isinstance(result.exception, LoadError)
+ assert result.exception.reason == LoadErrorReason.TRAILING_LIST_DIRECTIVE
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("target", [
+ ('variables.bst'), ('environment.bst'), ('config.bst'), ('public.bst')
+])
+def test_element_error(cli, datafiles, target):
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'list-directive-error-element')
+ result = cli.run(project=project, silent=True, args=[
+ 'show',
+ '--deps', 'none',
+ '--format', '%{vars}',
+ target])
+
+ assert result.exit_code != 0
+ assert result.exception
+ assert isinstance(result.exception, LoadError)
+ assert result.exception.reason == LoadErrorReason.TRAILING_LIST_DIRECTIVE
diff --git a/tests/yaml/data/implicitoverwrite.yaml b/tests/yaml/data/implicitoverwrite.yaml
new file mode 100644
index 000000000..20e5eb76a
--- /dev/null
+++ b/tests/yaml/data/implicitoverwrite.yaml
@@ -0,0 +1,6 @@
+# Composited on top of basics.yaml, overwriting it's children list
+children:
+- name: overwrite1
+ mood: overwrite1
+- name: overwrite2
+ mood: overwrite2
diff --git a/tests/yaml/data/listappend.yaml b/tests/yaml/data/listappend.yaml
new file mode 100644
index 000000000..889ed80b2
--- /dev/null
+++ b/tests/yaml/data/listappend.yaml
@@ -0,0 +1,7 @@
+# Composited on top of basics.yaml, appending to it's children list
+children:
+ (>):
+ - name: appended1
+ mood: appended1
+ - name: appended2
+ mood: appended2
diff --git a/tests/yaml/data/listappendprepend.yaml b/tests/yaml/data/listappendprepend.yaml
new file mode 100644
index 000000000..18471b36c
--- /dev/null
+++ b/tests/yaml/data/listappendprepend.yaml
@@ -0,0 +1,12 @@
+# Composited on top of basics.yaml, prepending and appending to it's children list
+children:
+ (<):
+ - name: prepended1
+ mood: prepended1
+ - name: prepended2
+ mood: prepended2
+ (>):
+ - name: appended1
+ mood: appended1
+ - name: appended2
+ mood: appended2
diff --git a/tests/yaml/data/listoverwrite.yaml b/tests/yaml/data/listoverwrite.yaml
new file mode 100644
index 000000000..3efdfa7cb
--- /dev/null
+++ b/tests/yaml/data/listoverwrite.yaml
@@ -0,0 +1,7 @@
+# Composited on top of basics.yaml, overwriting it's children list
+children:
+ (=):
+ - name: overwrite1
+ mood: overwrite1
+ - name: overwrite2
+ mood: overwrite2
diff --git a/tests/yaml/data/listprepend.yaml b/tests/yaml/data/listprepend.yaml
new file mode 100644
index 000000000..3934c93be
--- /dev/null
+++ b/tests/yaml/data/listprepend.yaml
@@ -0,0 +1,7 @@
+# Composited on top of basics.yaml, prepending to it's children list
+children:
+ (<):
+ - name: prepended1
+ mood: prepended1
+ - name: prepended2
+ mood: prepended2
diff --git a/tests/yaml/data/secondappend.yaml b/tests/yaml/data/secondappend.yaml
new file mode 100644
index 000000000..376c4a707
--- /dev/null
+++ b/tests/yaml/data/secondappend.yaml
@@ -0,0 +1,7 @@
+# Composited on top of listappend.yaml, appending to it's children list
+children:
+ (>):
+ - name: secondappend1
+ mood: secondappend1
+ - name: secondappend2
+ mood: secondappend2
diff --git a/tests/yaml/data/secondprepend.yaml b/tests/yaml/data/secondprepend.yaml
new file mode 100644
index 000000000..58276c381
--- /dev/null
+++ b/tests/yaml/data/secondprepend.yaml
@@ -0,0 +1,7 @@
+# Composited on top of listprepend.yaml, prepending to it's children list
+children:
+ (<):
+ - name: secondprepend1
+ mood: secondprepend1
+ - name: secondprepend2
+ mood: secondprepend2
diff --git a/tests/yaml/yaml.py b/tests/yaml/yaml.py
index 948151bed..cf12317a9 100644
--- a/tests/yaml/yaml.py
+++ b/tests/yaml/yaml.py
@@ -4,7 +4,6 @@ from collections import Mapping
from buildstream import _yaml
from buildstream import LoadError, LoadErrorReason
-from buildstream._yaml import CompositePolicy
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -77,92 +76,6 @@ def test_element_provenance(datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
-def test_composited_overwrite_provenance(datafiles):
-
- filename = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'basics.yaml')
- overlayfile = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'composite.yaml')
-
- base = _yaml.load(filename)
- assert(base.get('kind') == 'pony')
- assert_provenance(filename, 1, 0, base)
-
- overlay = _yaml.load(overlayfile)
- assert(overlay.get('kind') == 'horse')
- assert_provenance(overlayfile, 1, 0, overlay)
-
- _yaml.composite_dict(base, overlay,
- policy=CompositePolicy.OVERWRITE, typesafe=True)
- assert(base.get('kind') == 'horse')
-
- children = base.get('children')
- assert(isinstance(children, list))
- assert(len(children) == 1)
-
- assert_provenance(filename, 1, 0, base)
-
- # The entire children member is overwritten with the overlay
- assert_provenance(overlayfile, 4, 0, base, 'children')
- assert_provenance(overlayfile, 4, 2, base, 'children', [0])
-
- # The child dict itself has the overlay provenance
- child = children[0]
- assert_provenance(overlayfile, 5, 8, child, 'mood')
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR))
-def test_composited_array_append_provenance(datafiles):
-
- filename = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'basics.yaml')
- overlayfile = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'composite.yaml')
-
- base = _yaml.load(filename)
- assert(base.get('kind') == 'pony')
- assert_provenance(filename, 1, 0, base)
-
- overlay = _yaml.load(overlayfile)
- assert(overlay.get('kind') == 'horse')
- assert_provenance(overlayfile, 1, 0, overlay)
-
- _yaml.composite_dict(base, overlay,
- policy=CompositePolicy.ARRAY_APPEND, typesafe=True)
- assert(base.get('kind') == 'horse')
-
- children = base.get('children')
- assert(isinstance(children, list))
- assert(len(children) == 8)
-
- assert_provenance(filename, 1, 0, base)
- assert_provenance(filename, 7, 0, base, 'children')
-
- # The newly added element has the overlay provenance
- assert_provenance(overlayfile, 4, 2, base, 'children', [7])
-
- # The child dict itself has the overlay provenance
- child = children[7]
- assert_provenance(overlayfile, 5, 8, child, 'mood')
-
- extra = base.get('extra')
- assert(isinstance(extra, dict))
- another = extra.get('another')
- assert(isinstance(another, dict))
-
- assert_provenance(filename, 22, 2, base, 'extra')
- assert_provenance(filename, 22, 2, extra)
- assert_provenance(filename, 22, 8, extra, 'this')
-
- assert_provenance(overlayfile, 9, 4, extra, 'another')
- assert_provenance(overlayfile, 9, 4, another)
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_node_validate(datafiles):
valid = os.path.join(datafiles.dirname,
@@ -190,31 +103,20 @@ def test_node_get(datafiles):
filename = os.path.join(datafiles.dirname,
datafiles.basename,
'basics.yaml')
- overlayfile = os.path.join(datafiles.dirname,
- datafiles.basename,
- 'composite.yaml')
base = _yaml.load(filename)
assert(base.get('kind') == 'pony')
- overlay = _yaml.load(overlayfile)
- assert(overlay.get('kind') == 'horse')
- _yaml.composite_dict(base, overlay,
- policy=CompositePolicy.ARRAY_APPEND,
- typesafe=True)
- assert(base.get('kind') == 'horse')
children = _yaml.node_get(base, list, 'children')
assert(isinstance(children, list))
- assert(len(children) == 8)
+ assert(len(children) == 7)
- child = _yaml.node_get(base, Mapping, 'children', indices=[7])
- assert_provenance(overlayfile, 5, 8, child, 'mood')
+ child = _yaml.node_get(base, Mapping, 'children', indices=[6])
+ assert_provenance(filename, 20, 8, child, 'mood')
extra = _yaml.node_get(base, Mapping, 'extra')
- another = _yaml.node_get(extra, Mapping, 'another')
-
with pytest.raises(LoadError) as exc:
- wrong = _yaml.node_get(another, Mapping, 'five')
+ wrong = _yaml.node_get(extra, Mapping, 'old')
assert (exc.value.reason == LoadErrorReason.INVALID_DATA)
@@ -236,8 +138,7 @@ def test_composite_preserve_originals(datafiles):
base = _yaml.load(filename)
overlay = _yaml.load(overlayfile)
base_copy = _yaml.node_chain_copy(base)
- _yaml.composite_dict(base_copy, overlay,
- policy=CompositePolicy.OVERWRITE, typesafe=True)
+ _yaml.composite_dict(base_copy, overlay)
copy_extra = _yaml.node_get(base_copy, Mapping, 'extra')
orig_extra = _yaml.node_get(base, Mapping, 'extra')
@@ -247,3 +148,191 @@ def test_composite_preserve_originals(datafiles):
# But the original node is not effected by the override.
assert(_yaml.node_get(orig_extra, str, 'old') == 'new')
+
+
+# Tests for list composition
+#
+# Each test composits a filename on top of basics.yaml, and tests
+# the toplevel children list at the specified index
+#
+# Parameters:
+# filename: The file to composite on top of basics.yaml
+# index: The index in the children list
+# length: The expected length of the children list
+# mood: The expected value of the mood attribute of the dictionary found at index in children
+# prov_file: The expected provenance filename of "mood"
+# prov_line: The expected provenance line of "mood"
+# prov_col: The expected provenance column of "mood"
+#
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+@pytest.mark.parametrize("filename,index,length,mood,prov_file,prov_line,prov_col", [
+
+ # Test results of compositing with the (<) prepend directive
+ ('listprepend.yaml', 0, 9, 'prepended1', 'listprepend.yaml', 5, 10),
+ ('listprepend.yaml', 1, 9, 'prepended2', 'listprepend.yaml', 7, 10),
+ ('listprepend.yaml', 2, 9, 'silly', 'basics.yaml', 8, 8),
+ ('listprepend.yaml', 8, 9, 'sleepy', 'basics.yaml', 20, 8),
+
+ # Test results of compositing with the (>) append directive
+ ('listappend.yaml', 7, 9, 'appended1', 'listappend.yaml', 5, 10),
+ ('listappend.yaml', 8, 9, 'appended2', 'listappend.yaml', 7, 10),
+ ('listappend.yaml', 0, 9, 'silly', 'basics.yaml', 8, 8),
+ ('listappend.yaml', 6, 9, 'sleepy', 'basics.yaml', 20, 8),
+
+ # Test results of compositing with both (<) and (>) directives
+ ('listappendprepend.yaml', 0, 11, 'prepended1', 'listappendprepend.yaml', 5, 10),
+ ('listappendprepend.yaml', 1, 11, 'prepended2', 'listappendprepend.yaml', 7, 10),
+ ('listappendprepend.yaml', 2, 11, 'silly', 'basics.yaml', 8, 8),
+ ('listappendprepend.yaml', 8, 11, 'sleepy', 'basics.yaml', 20, 8),
+ ('listappendprepend.yaml', 9, 11, 'appended1', 'listappendprepend.yaml', 10, 10),
+ ('listappendprepend.yaml', 10, 11, 'appended2', 'listappendprepend.yaml', 12, 10),
+
+ # Test results of compositing with the (=) overwrite directive
+ ('listoverwrite.yaml', 0, 2, 'overwrite1', 'listoverwrite.yaml', 5, 10),
+ ('listoverwrite.yaml', 1, 2, 'overwrite2', 'listoverwrite.yaml', 7, 10),
+
+ # Test results of compositing without any directive, implicitly overwriting
+ ('implicitoverwrite.yaml', 0, 2, 'overwrite1', 'implicitoverwrite.yaml', 4, 8),
+ ('implicitoverwrite.yaml', 1, 2, 'overwrite2', 'implicitoverwrite.yaml', 6, 8),
+])
+def test_list_composition(datafiles, filename,
+ index, length, mood,
+ prov_file, prov_line, prov_col):
+ base = os.path.join(datafiles.dirname, datafiles.basename, 'basics.yaml')
+ overlay = os.path.join(datafiles.dirname, datafiles.basename, filename)
+
+ base = _yaml.load(base, shortname='basics.yaml')
+ overlay = _yaml.load(overlay, shortname=filename)
+ _yaml.composite_dict(base, overlay)
+
+ children = _yaml.node_get(base, list, 'children')
+ assert len(children) == length
+ child = children[index]
+
+ assert child['mood'] == mood
+ assert_provenance(prov_file, prov_line, prov_col, child, 'mood')
+
+
+# Tests for deep list composition
+#
+# Same as test_list_composition(), but adds an additional file
+# in between so that lists are composited twice.
+#
+# This test will to two iterations for each parameter
+# specification, expecting the same results
+#
+# First iteration:
+# composited = basics.yaml & filename1
+# composited = composited & filename2
+#
+# Second iteration:
+# composited = filename1 & filename2
+# composited = basics.yaml & composited
+#
+# Parameters:
+# filename1: The file to composite on top of basics.yaml
+# filename2: The file to composite on top of filename1
+# index: The index in the children list
+# length: The expected length of the children list
+# mood: The expected value of the mood attribute of the dictionary found at index in children
+# prov_file: The expected provenance filename of "mood"
+# prov_line: The expected provenance line of "mood"
+# prov_col: The expected provenance column of "mood"
+#
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+@pytest.mark.parametrize("filename1,filename2,index,length,mood,prov_file,prov_line,prov_col", [
+
+ # Test results of compositing literal list with (>) and then (<)
+ ('listprepend.yaml', 'listappend.yaml', 0, 11, 'prepended1', 'listprepend.yaml', 5, 10),
+ ('listprepend.yaml', 'listappend.yaml', 1, 11, 'prepended2', 'listprepend.yaml', 7, 10),
+ ('listprepend.yaml', 'listappend.yaml', 2, 11, 'silly', 'basics.yaml', 8, 8),
+ ('listprepend.yaml', 'listappend.yaml', 8, 11, 'sleepy', 'basics.yaml', 20, 8),
+ ('listprepend.yaml', 'listappend.yaml', 9, 11, 'appended1', 'listappend.yaml', 5, 10),
+ ('listprepend.yaml', 'listappend.yaml', 10, 11, 'appended2', 'listappend.yaml', 7, 10),
+
+ # Test results of compositing literal list with (<) and then (>)
+ ('listappend.yaml', 'listprepend.yaml', 0, 11, 'prepended1', 'listprepend.yaml', 5, 10),
+ ('listappend.yaml', 'listprepend.yaml', 1, 11, 'prepended2', 'listprepend.yaml', 7, 10),
+ ('listappend.yaml', 'listprepend.yaml', 2, 11, 'silly', 'basics.yaml', 8, 8),
+ ('listappend.yaml', 'listprepend.yaml', 8, 11, 'sleepy', 'basics.yaml', 20, 8),
+ ('listappend.yaml', 'listprepend.yaml', 9, 11, 'appended1', 'listappend.yaml', 5, 10),
+ ('listappend.yaml', 'listprepend.yaml', 10, 11, 'appended2', 'listappend.yaml', 7, 10),
+
+ # Test results of compositing literal list with (>) and then (>)
+ ('listappend.yaml', 'secondappend.yaml', 0, 11, 'silly', 'basics.yaml', 8, 8),
+ ('listappend.yaml', 'secondappend.yaml', 6, 11, 'sleepy', 'basics.yaml', 20, 8),
+ ('listappend.yaml', 'secondappend.yaml', 7, 11, 'appended1', 'listappend.yaml', 5, 10),
+ ('listappend.yaml', 'secondappend.yaml', 8, 11, 'appended2', 'listappend.yaml', 7, 10),
+ ('listappend.yaml', 'secondappend.yaml', 9, 11, 'secondappend1', 'secondappend.yaml', 5, 10),
+ ('listappend.yaml', 'secondappend.yaml', 10, 11, 'secondappend2', 'secondappend.yaml', 7, 10),
+
+ # Test results of compositing literal list with (>) and then (>)
+ ('listprepend.yaml', 'secondprepend.yaml', 0, 11, 'secondprepend1', 'secondprepend.yaml', 5, 10),
+ ('listprepend.yaml', 'secondprepend.yaml', 1, 11, 'secondprepend2', 'secondprepend.yaml', 7, 10),
+ ('listprepend.yaml', 'secondprepend.yaml', 2, 11, 'prepended1', 'listprepend.yaml', 5, 10),
+ ('listprepend.yaml', 'secondprepend.yaml', 3, 11, 'prepended2', 'listprepend.yaml', 7, 10),
+ ('listprepend.yaml', 'secondprepend.yaml', 4, 11, 'silly', 'basics.yaml', 8, 8),
+ ('listprepend.yaml', 'secondprepend.yaml', 10, 11, 'sleepy', 'basics.yaml', 20, 8),
+
+ # Test results of compositing literal list with (>) or (<) and then another literal list
+ ('listappend.yaml', 'implicitoverwrite.yaml', 0, 2, 'overwrite1', 'implicitoverwrite.yaml', 4, 8),
+ ('listappend.yaml', 'implicitoverwrite.yaml', 1, 2, 'overwrite2', 'implicitoverwrite.yaml', 6, 8),
+ ('listprepend.yaml', 'implicitoverwrite.yaml', 0, 2, 'overwrite1', 'implicitoverwrite.yaml', 4, 8),
+ ('listprepend.yaml', 'implicitoverwrite.yaml', 1, 2, 'overwrite2', 'implicitoverwrite.yaml', 6, 8),
+
+ # Test results of compositing literal list with (>) or (<) and then an explicit (=) overwrite
+ ('listappend.yaml', 'listoverwrite.yaml', 0, 2, 'overwrite1', 'listoverwrite.yaml', 5, 10),
+ ('listappend.yaml', 'listoverwrite.yaml', 1, 2, 'overwrite2', 'listoverwrite.yaml', 7, 10),
+ ('listprepend.yaml', 'listoverwrite.yaml', 0, 2, 'overwrite1', 'listoverwrite.yaml', 5, 10),
+ ('listprepend.yaml', 'listoverwrite.yaml', 1, 2, 'overwrite2', 'listoverwrite.yaml', 7, 10),
+
+ # Test results of compositing literal list an explicit overwrite (=) and then with (>) or (<)
+ ('listoverwrite.yaml', 'listappend.yaml', 0, 4, 'overwrite1', 'listoverwrite.yaml', 5, 10),
+ ('listoverwrite.yaml', 'listappend.yaml', 1, 4, 'overwrite2', 'listoverwrite.yaml', 7, 10),
+ ('listoverwrite.yaml', 'listappend.yaml', 2, 4, 'appended1', 'listappend.yaml', 5, 10),
+ ('listoverwrite.yaml', 'listappend.yaml', 3, 4, 'appended2', 'listappend.yaml', 7, 10),
+ ('listoverwrite.yaml', 'listprepend.yaml', 0, 4, 'prepended1', 'listprepend.yaml', 5, 10),
+ ('listoverwrite.yaml', 'listprepend.yaml', 1, 4, 'prepended2', 'listprepend.yaml', 7, 10),
+ ('listoverwrite.yaml', 'listprepend.yaml', 2, 4, 'overwrite1', 'listoverwrite.yaml', 5, 10),
+ ('listoverwrite.yaml', 'listprepend.yaml', 3, 4, 'overwrite2', 'listoverwrite.yaml', 7, 10),
+])
+def test_list_composition_twice(datafiles, filename1, filename2,
+ index, length, mood,
+ prov_file, prov_line, prov_col):
+ file_base = os.path.join(datafiles.dirname, datafiles.basename, 'basics.yaml')
+ file1 = os.path.join(datafiles.dirname, datafiles.basename, filename1)
+ file2 = os.path.join(datafiles.dirname, datafiles.basename, filename2)
+
+ #####################
+ # Round 1 - Fight !
+ #####################
+ base = _yaml.load(file_base, shortname='basics.yaml')
+ overlay1 = _yaml.load(file1, shortname=filename1)
+ overlay2 = _yaml.load(file2, shortname=filename2)
+
+ _yaml.composite_dict(base, overlay1)
+ _yaml.composite_dict(base, overlay2)
+
+ children = _yaml.node_get(base, list, 'children')
+ assert len(children) == length
+ child = children[index]
+
+ assert child['mood'] == mood
+ assert_provenance(prov_file, prov_line, prov_col, child, 'mood')
+
+ #####################
+ # Round 2 - Fight !
+ #####################
+ base = _yaml.load(file_base, shortname='basics.yaml')
+ overlay1 = _yaml.load(file1, shortname=filename1)
+ overlay2 = _yaml.load(file2, shortname=filename2)
+
+ _yaml.composite_dict(overlay1, overlay2)
+ _yaml.composite_dict(base, overlay1)
+
+ children = _yaml.node_get(base, list, 'children')
+ assert len(children) == length
+ child = children[index]
+
+ assert child['mood'] == mood
+ assert_provenance(prov_file, prov_line, prov_col, child, 'mood')