Skip to content

Commit

Permalink
Add tests for Host data functions (nornir-automation#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogenstad authored and dbarrosop committed Aug 8, 2019
1 parent 2fa6d4d commit 1386202
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/core/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def test_inventory_deserializer(self):
inv = deserializer.Inventory.deserialize(**inv_dict)
assert inv.groups["group_1"] in inv.hosts["dev1.group_1"].groups

def test_inventory_data(self):
"""Test Host values()/keys()/items()"""
inv = deserializer.Inventory.deserialize(**inv_dict)
h = inv.hosts["dev1.group_1"]
assert "comes_from_dev1.group_1" in h.values()
assert "blah" in h.values()
assert "my_var" in h.keys()
assert "only_default" in h.keys()
assert "comes_from_dev1.group_1" == dict(h.items())["my_var"]

def test_filtering(self):
inv = deserializer.Inventory.deserialize(**inv_dict)
unfiltered = sorted(list(inv.hosts.keys()))
Expand Down
1 change: 1 addition & 0 deletions tests/inventory_data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ password: docker
platform: linux
data:
my_var: comes_from_defaults
only_default: only_defined_in_default
connection_options:
dummy:
hostname: dummy_from_defaults
Expand Down

0 comments on commit 1386202

Please sign in to comment.