def test_registry__register_controllers(registry_fixture): registry = Registry(registry_filename=TEST_FILENAME) clear_controllers(registry) controller = DEFAULT_REGISTRY["Controllers"][CTYPE][0] registry.register_controller(CTYPE, controller) controllers = registry.list_controllers(CTYPE) assert len(controllers) == 1 # Test that the the changes are reflected with a new instance. registry2 = Registry(registry_filename=TEST_FILENAME) controllers1 = registry.list_controllers(CTYPE) controllers2 = registry2.list_controllers(CTYPE) for data1, data2 in zip(controllers1, controllers2): for field in DEFAULT_REGISTRY["Controllers"][CTYPE][0]: assert data1[field] == data2[field]
def test_registry__register_controllers(registry_fixture): registry = Registry(registry_filename=TEST_FILENAME) registry.reset_defaults() new_controller = copy.deepcopy(DEFAULT_REGISTRY["Controllers"][CTYPE][0]) new_name = new_controller["name"] + "_new" new_controller["name"] = new_name registry.register_controller(CTYPE, new_controller) # Test that the the changes are reflected with a new instance. registry2 = Registry(registry_filename=TEST_FILENAME) controllers1 = registry.list_controllers(CTYPE) controllers2 = registry2.list_controllers(CTYPE) for data1, data2 in zip(controllers1, controllers2): for field in DEFAULT_REGISTRY["Controllers"][CTYPE][0]: assert data1[field] == data2[field] registry2.unregister_controller(CTYPE, new_name) assert not registry2.is_controller_registered(CTYPE, new_name)
def test_registry__reset_defaults(registry_fixture): registry = Registry(registry_filename=TEST_FILENAME) clear_controllers(registry) registry.reset_defaults() assert len(registry.list_controllers(CTYPE)) == len( DEFAULT_REGISTRY["Controllers"][CTYPE])
def test_registry__list_controllers(registry_fixture): registry = Registry(registry_filename=TEST_FILENAME) registry.reset_defaults() actual = registry.list_controllers(CTYPE) expected = DEFAULT_REGISTRY["Controllers"][CTYPE] assert len(actual) == len(expected)