def insights_update(ctx, declaration): """ command """ insights_client = InsightsClient(get_mgmt_client()) ctx.log( insights_client.create( config_file=utils_core.convert_to_absolute(declaration)))
def test_insights_client_delete_with_title(mgmt_client, mocker): """Test: Beacon Insights client update() - with config_file Assertions ---------- - Beacon Insights client create() return value should be mocked response """ mocker.patch(REQUESTS).return_value.json = Mock(return_value={}) insights_client = InsightsClient(mgmt_client) assert insights_client.delete(name='blah') == {}
def test_insights_client_list_query_parameters(mgmt_client, mocker): """Test: list() method with query parameters Assertions ---------- - Return value should be mock API response """ mocker.patch(REQUESTS).return_value.json = Mock(return_value={}) insights_client = InsightsClient(mgmt_client) assert insights_client.list(query_parameters={'pageSize': '5'}) == {}
def insight_delete(ctx, name, auto_approve): """ command """ approval_confirmation_map = { 'delete': 'Insight named %s will be deleted' % name } utils_core.verify_approval('delete', approval_confirmation_map, auto_approve) insights_client = InsightsClient(get_mgmt_client()) result = insights_client.delete(name=name, config={}) if result == {}: ctx.log('Insight deleted successfully') else: ctx.log(result)
def test_insights_client_update_config_file(mgmt_client, mocker): """Test: Beacon Insights client update() - with config_file Assertions ---------- - Beacon Insights client create() return value should be mocked response """ mocker.patch('f5sdk.utils.file_utils.open', mocker.mock_open(read_data=json.dumps({}))) mocker.patch(REQUESTS).return_value.json = Mock(return_value={}) insights_client = InsightsClient(mgmt_client) assert insights_client.create(config_file='/foo.json') == {}
def test_crud_operations(mgmt_client, mocker): """Test: CRUD operation functions Assertions ---------- - response should match mocked return value """ utils.validate_crud_operations( InsightsClient(mgmt_client), mocker=mocker, methods=['list', 'create', 'show', 'delete'])
def cs_beacon_insights_client(context): """Return Cloud Services Beacon Insights client""" context.beacon_insights_client = InsightsClient(context.cs_mgmt_client) return context.beacon_insights_client
def insight_show(ctx, name): """ command """ insights_client = InsightsClient(get_mgmt_client()) ctx.log(insights_client.show(name=name))
def insights_list(ctx): """ command """ insights_client = InsightsClient(get_mgmt_client()) ctx.log(insights_client.list())