Skip to content

Commit

Permalink
Merge pull request #1152 from CJ-Wright/fix_variants
Browse files Browse the repository at this point in the history
Fix the variants rendering for cfep9
  • Loading branch information
scopatz authored Sep 19, 2019
2 parents 355998f + 64edb9b commit 2117180
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conda_smithy/variant_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def variant_add(v1: dict, v2: dict) -> Dict[str, Any]:
# deal with __migrator: ordering
if "__migrator" in v2:
print(v2)
ordering = v2["__migrator"].get("ordering")
ordering = v2["__migrator"].get("ordering", {})
print(ordering)
else:
ordering = {}
Expand Down Expand Up @@ -175,7 +175,7 @@ def variant_add(v1: dict, v2: dict) -> Dict[str, Any]:
joint_variant = {}
for k in joint:
v_left, v_right = ensure_list(v1[k]), ensure_list(v2[k])
joint_variant[k] = variant_key_add(k, v_left, v_right, ordering=ordering.get(k))
joint_variant[k] = variant_key_add(k, v_left, v_right, ordering=ordering.get(k, None))

out = {
**toolz.keyfilter(lambda k: k in left, v1),
Expand Down
24 changes: 24 additions & 0 deletions news/fix_variants.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Don't make assumptions in ``conda_smithy/variant_algebra.py`` about the metadata

**Security:**

* <news item>

30 changes: 30 additions & 0 deletions tests/test_variant_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ def test_ordering():
# raise Exception()


def test_no_ordering():
start = parse_variant(
dedent(
"""\
xyz:
- 1
"""
)
)

mig_compiler = parse_variant(
dedent(
"""\
__migrator:
kind:
version
migration_no:
1
xyz:
- 2
"""
)
)

res = variant_add(start, mig_compiler)
assert res["xyz"] == ["2"]
print(res)
# raise Exception()


def test_ordering_downgrade():
start = parse_variant(
dedent(
Expand Down

0 comments on commit 2117180

Please sign in to comment.