Exemple #1
0
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'}) == {}
Exemple #4
0
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'])
Exemple #7
0
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
Exemple #8
0
def insight_show(ctx, name):
    """ command """

    insights_client = InsightsClient(get_mgmt_client())
    ctx.log(insights_client.show(name=name))
Exemple #9
0
def insights_list(ctx):
    """ command """
    insights_client = InsightsClient(get_mgmt_client())
    ctx.log(insights_client.list())