def test_show_returns_serializable_data(vmware_inventory): fakeargs = FakeArgs() vmw = vmware_inventory.VMWareInventory(load=False) vmw.args = fakeargs vmw.inventory = BASIC_INVENTORY showdata = vmw.show() json.loads(showdata)
def test_host_info_returns_single_host(vmware_inventory): vmw = vmware_inventory.VMWareInventory(load=False) vmw.inventory = BASIC_INVENTORY foo = vmw.get_host_info('foo') bar = vmw.get_host_info('bar') assert foo == {'hostname': 'foo'} assert bar == {'hostname': 'bar'}
def test_show_list_returns_all_data(vmware_inventory): fakeargs = FakeArgs() vmw = vmware_inventory.VMWareInventory(load=False) vmw.args = fakeargs vmw.args.list = True vmw.inventory = BASIC_INVENTORY showdata = vmw.show() expected = json.dumps(BASIC_INVENTORY, indent=2) assert showdata == expected
def test_show_host_returns_just_host(vmware_inventory): fakeargs = FakeArgs() vmw = vmware_inventory.VMWareInventory(load=False) vmw.args = fakeargs vmw.args.list = False vmw.args.host = 'foo' vmw.inventory = BASIC_INVENTORY showdata = vmw.show() expected = BASIC_INVENTORY['_meta']['hostvars']['foo'] expected = json.dumps(expected, indent=2) assert showdata == expected