def main(): if mounted(device_name): print('Preparation.') print('device_dismount(', device_name, sep='', end=')\n') device_dismount(device_name) time.sleep(1) print() print('Verify absence of unreachable device.') in_inventory = device_name in inventory() in_mounted = device_name in inventory_mounted() print(device_name + ' in inventory', in_inventory, sep=': ') print(device_name + ' is mounted', in_mounted, sep=': ') assert not in_inventory assert not in_mounted del in_inventory, in_mounted print() print('Discover effect of mounting unreachable device.') print('device_mount(' + device_name, device_address, device_port, sep=', ', end=')\n') device_mount(device_name, device_address, device_port, device_username, device_password) time.sleep(1) in_connected = device_name in inventory_connected() in_mounted = device_name in inventory_mounted() print(device_name + ' is connected', in_connected, sep=': ') print(device_name + ' is mounted', in_mounted, sep=': ') assert not in_connected assert in_mounted
def main(): inventory_set = set(inventory()) inventory_connected_set = set(inventory_connected()) inventory_not_connected_set = set(inventory_not_connected()) inventory_mounted_set = set(inventory_mounted()) inventory_unmounted_set = set(inventory_unmounted()) empty_set = set() print("The set of 'connected' devices is a subset of the inventory:", inventory_connected_set <= inventory_set) assert inventory_connected_set <= inventory_set print( "The set of 'not connected' devices is also a subset of the inventory:", inventory_not_connected_set <= inventory_set) assert inventory_not_connected_set <= inventory_set print( "There are no network devices in both the 'connected' set and the 'not connected' set:", inventory_not_connected_set & inventory_connected_set == empty_set) assert inventory_not_connected_set & inventory_connected_set == empty_set print( "Every network device in the inventory is in either the 'connected' set or the 'not connected' set:", inventory_connected_set | inventory_not_connected_set == inventory_set) assert inventory_connected_set | inventory_not_connected_set == inventory_set print() print("The set of 'mounted' devices is a subset of the inventory:", inventory_mounted_set <= inventory_set) assert inventory_mounted_set <= inventory_set print( "The set of 'unmounted' devices has no intersection with the inventory:", inventory_unmounted_set & inventory_set == empty_set) assert inventory_unmounted_set & inventory_set == empty_set, 'Expect no intersection, got %s' % ( inventory_unmounted_set & inventory_set) print( "There are no network devices in both the 'mounted' set and the 'unmounted' set:", inventory_unmounted_set & inventory_mounted_set == empty_set) assert inventory_unmounted_set & inventory_mounted_set == empty_set
def main(): inventory_set = set(inventory()) inventory_connected_set = set(inventory_connected()) inventory_not_connected_set = set(inventory_not_connected()) inventory_mounted_set = set(inventory_mounted()) inventory_unmounted_set = set(inventory_unmounted()) empty_set = set() print("The set of 'connected' devices is a subset of the inventory:", inventory_connected_set <= inventory_set) assert inventory_connected_set <= inventory_set print("The set of 'not connected' devices is also a subset of the inventory:", inventory_not_connected_set <= inventory_set) assert inventory_not_connected_set <= inventory_set print("There are no network devices in both the 'connected' set and the 'not connected' set:", inventory_not_connected_set & inventory_connected_set == empty_set) assert inventory_not_connected_set & inventory_connected_set == empty_set print("Every network device in the inventory is in either the 'connected' set or the 'not connected' set:", inventory_connected_set | inventory_not_connected_set == inventory_set) assert inventory_connected_set | inventory_not_connected_set == inventory_set print() print("The set of 'mounted' devices is a subset of the inventory:", inventory_mounted_set <= inventory_set) assert inventory_mounted_set <= inventory_set print("The set of 'unmounted' devices has no intersection with the inventory:", inventory_unmounted_set & inventory_set == empty_set) assert inventory_unmounted_set & inventory_set == empty_set, 'Expect no intersection, got %s' % (inventory_unmounted_set & inventory_set) print("There are no network devices in both the 'mounted' set and the 'unmounted' set:", inventory_unmounted_set & inventory_mounted_set == empty_set) assert inventory_unmounted_set & inventory_mounted_set == empty_set
def main(): print(plain(doc(inventory))) print(inventory())