Skip to content

Commit

Permalink
Merge pull request #117 from wwkimball/development
Browse files Browse the repository at this point in the history
Prep Release v3.4.1
  • Loading branch information
wwkimball authored Jan 24, 2021
2 parents 748a7dc + ed6180d commit 5f59dc0
Show file tree
Hide file tree
Showing 8 changed files with 1,076 additions and 821 deletions.
18 changes: 18 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
3.4.1:
Bug Fixes:
* yaml-set (and the underlying Processor class) were unable to change nodes
having a null (None) value to anything else. This changes how null/None
values are handled by the Processor during node retrieval; they are no longer
discarded, so you will receive None as the data of any retrieved NodeCoords
for appropriate null/None leaf nodes.

Enhancements:
* The node deletion capability of the yaml-set command is now part of the
library. See Processor::delete_nodes(...) and
Processor::delete_gathered_nodes(...) for details.
* The library now supports loading YAML from String rather than only from file.
Simply pass a new `literal=True` keyword parameter to
Parsers::get_yaml_data(...) or Parsers::get_yaml_multidoc_data(...) to
indicate that `source` is literal serialized (String) YAML data rather than a
file-spec. This mode is implied when reading from STDIN (source is "-").

3.4.0:
Bug Fixes:
* For the yaml-diff command-line tool, custom identity keys for specific
Expand Down
24 changes: 24 additions & 0 deletions tests/test_commands_yaml_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,3 +1218,27 @@ def test_assign_null(self, script_runner, tmp_path_factory):
with open(yaml_file, 'r') as fhnd:
filedat = fhnd.read()
assert filedat == yamlout

def test_change_null(self, script_runner, tmp_path_factory):
yamlin = """---
ingress_key: Preceding value
concrete_key:
egress_key: Following value
"""
yamlout = """---
ingress_key: Preceding value
concrete_key: Now not null
egress_key: Following value
"""
yaml_file = create_temp_yaml_file(tmp_path_factory, yamlin)
result = script_runner.run(
self.command,
"--change=concrete_key",
"--value=Now not null",
yaml_file
)
assert result.success, result.stderr

with open(yaml_file, 'r') as fhnd:
filedat = fhnd.read()
assert filedat == yamlout
52 changes: 52 additions & 0 deletions tests/test_common_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,58 @@
class Test_common_parsers():
"""Tests for the Parsers helper class."""

###
# get_yaml_data (literal=True)
###
def test_get_yaml_data_literally(self, quiet_logger):
serialized_yaml = """---
hash:
key: value
list:
- ichi
- ni
- san
"""
yaml = Parsers.get_yaml_editor()
(data, loaded) = Parsers.get_yaml_data(
yaml, quiet_logger, serialized_yaml,
literal=True)
assert loaded == True
assert data["hash"]["key"] == "value"
assert data["list"][0] == "ichi"
assert data["list"][1] == "ni"
assert data["list"][2] == "san"

###
# get_yaml_multidoc_data (literal=True)
###
def test_get_yaml_multidoc_data_literally(self, quiet_logger):
serialized_yaml = """---
document: 1st
has: data
...
---
document: 2nd
has: different data
"""
yaml = Parsers.get_yaml_editor()
doc_id = 0
for (data, loaded) in Parsers.get_yaml_multidoc_data(
yaml, quiet_logger, serialized_yaml,
literal=True):
assert loaded == True
if doc_id == 0:
document = "1st"
has = "data"
else:
document= "2nd"
has = "different data"
doc_id = doc_id + 1

assert data["document"] == document
assert data["has"] == has

###
# stringify_dates
###
Expand Down
Loading

0 comments on commit 5f59dc0

Please sign in to comment.