def test_address_from_path(): builder = OperationRequestBuilder() builder.address_from('/subsystem=datasources/data-source=DemoDS') request = builder.build() assert request == dict( address=[{'subsystem': 'datasources'}, {'data-source': 'DemoDS'}])
def test_content_src(): builder = OperationRequestBuilder() builder.content('/tmp/hawtio.war') request = builder.build() assert request == dict( content=[dict(url='file:/tmp/hawtio.war')], address=[])
def test_write_attribute_operation(): builder = OperationRequestBuilder() builder.write('min-pool-size', 10) request = builder.build() assert request == dict(operation='write-attribute', name='min-pool-size', value=10, address=[])
def test_deploy_no_server_group(): builder = OperationRequestBuilder() builder.target(None) builder.deploy() request = builder.build() assert request == dict(operation='deploy', address=[])
def test_deploy_with_server_group(): builder = OperationRequestBuilder() builder.target('main-server-group') builder.deploy() request = builder.build() assert request == dict(operation='add', address=[{'server-group': 'main-server-group'}])
def test_deployment_address(): builder = OperationRequestBuilder() builder.deployment('hawtio.war') request = builder.build() assert request == dict(address=[dict(deployment='hawtio.war')])
def test_composite_operation(): builder = OperationRequestBuilder() builder.add() add_operation = builder.build() builder = OperationRequestBuilder() builder.deploy() deploy_operation = builder.build() builder = OperationRequestBuilder() builder.composite([add_operation, deploy_operation]) request = builder.build() assert request == dict(address=[], operation='composite', steps=[add_operation, deploy_operation])
def test_target_server_group(): builder = OperationRequestBuilder() builder.target('main-server-group') request = builder.build() assert request == dict(address=[{'server-group': 'main-server-group'}])
def execute(operation, parameters, path): builder = OperationRequestBuilder() builder.address_from(path) builder.payload(parameters) builder.operation(operation) return builder.build()
def test_read_operation(): builder = OperationRequestBuilder() builder.read() request = builder.build() assert request == dict(operation='read-resource', address=[])
def write_attribute(path, name, value): builder = OperationRequestBuilder() builder.address_from(path) builder.write(name, value) return builder.build()
def remove(path): builder = OperationRequestBuilder() builder.address_from(path) builder.remove() return builder.build()
def composite(operations): builder = OperationRequestBuilder() builder.composite(operations) return builder.build()
def test_undeploy_no_server_group(): builder = OperationRequestBuilder() builder.undeploy() request = builder.build() assert request == dict(operation='undeploy', address=[])
def test_add_operation(): builder = OperationRequestBuilder() builder.add() request = builder.build() assert request == dict(operation='add', address=[])
def undeploy(name, server_group): builder = OperationRequestBuilder() builder.deployment(name) builder.remove() remove_content = builder.build() builder = OperationRequestBuilder() builder.target(server_group) builder.undeploy() builder.deployment(name) undeploy_operation = builder.build() return [undeploy_operation, remove_content]
def deploy_only(name, bytes_value, server_group): builder = OperationRequestBuilder() builder.content_reference(bytes_value) builder.target(server_group) builder.add() builder.payload(dict(enabled=True)) builder.deployment(name) return builder.build()
def deploy(name, src, server_group): add_builder = OperationRequestBuilder() add_builder.deployment(name) add_builder.content(src) add_builder.add() add_content = add_builder.build() deploy_builder = OperationRequestBuilder() deploy_builder.target(server_group) deploy_builder.deploy() deploy_builder.deployment(name) deploy_operation = deploy_builder.build() return [add_content, deploy_operation]
def test_remove_operation(): builder = OperationRequestBuilder() builder.remove() request = builder.build() assert request == dict(operation='remove', address=[])
def add(path, attributes): builder = OperationRequestBuilder() builder.address_from(path) builder.add() builder.payload(attributes) return builder.build()