How to use the boxsdk.config.API.BASE_API_URL function in boxsdk

To help you get started, we’ve selected a few boxsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github box / box-python-sdk / test / unit / object / test_base_object.py View on Github external
def test_delete_handles_params_and_headers_correctly(mock_box_session, make_mock_box_request, params, headers, success):
    # pylint:disable=redefined-outer-name, protected-access
    fake_id = 'a_fake_id'
    base_object = BaseObject(mock_box_session, fake_id)

    mock_box_response, _ = make_mock_box_request(response_ok=success)
    mock_box_session.delete.return_value = mock_box_response
    expected_url = '{0}/{1}s/{2}'.format(API.BASE_API_URL, None, fake_id)
    update_response = base_object.delete(params=params, headers=headers)
    mock_box_session.delete.assert_called_once_with(
        expected_url,
        expect_json_response=False,
        params=params or {},
        headers=headers,
    )
    assert update_response is success
github box / box-python-sdk / test / integration / test_with_shared_link.py View on Github external
box_client,
        mock_box_network,
        generic_successful_response,
        shared_link,
        shared_link_password,
        box_api_headers,
):
    # pylint:disable=redefined-outer-name
    mock_box_network.session.request.side_effect = [
        generic_successful_response,
    ]
    box_client.with_shared_link(shared_link, shared_link_password).folder('0').get()
    assert mock_box_network.session.request.mock_calls == [
        call(
            'GET',
            '{0}/folders/0'.format(API.BASE_API_URL),
            headers=box_api_headers,
            params=None,
        ),
github box / box-python-sdk / test / unit / object / test_legal_hold_policy.py View on Github external
def test_assign(test_legal_hold_policy, mock_box_session, test_file):
    assignment_id = '12345'
    assigned_at = '2016-05-18T17:38:03-07:00',
    expected_url = '{0}/legal_hold_policy_assignments'.format(API.BASE_API_URL)
    expected_body = {
        'policy_id': test_legal_hold_policy.object_id,
        'assign_to': {
            'type': 'file',
            'id': test_file.object_id
        }
    }
    mock_box_session.post.return_value.json.return_value = {
        'type': 'legal_hold_policy_assignment',
        'id': assignment_id,
        'assigned_at': assigned_at,
    }
    new_legal_hold_assignment = test_legal_hold_policy.assign(test_file)
    mock_box_session.post.assert_called_once_with(expected_url, data=json.dumps(expected_body))
    assert isinstance(new_legal_hold_assignment, LegalHoldPolicyAssignment)
    assert new_legal_hold_assignment.assigned_at == assigned_at
github box / box-python-sdk / test / unit / object / test_webhook.py View on Github external
def test_delete_webhook_return_the_correct_response(
        test_webhook,
        mock_box_session,
        delete_webhook_response,
):
    # pylint:disable=redefined-outer-name
    mock_box_session.delete.return_value = delete_webhook_response
    response = test_webhook.delete()
    expected_url = '{0}/webhooks/{1}'.format(API.BASE_API_URL, test_webhook.object_id)
    mock_box_session.delete.assert_called_once_with(expected_url, params={}, expect_json_response=False, headers=None)
    assert response is True
github box / box-python-sdk / test / unit / object / test_legal_hold_policy.py View on Github external
def test_get(test_legal_hold_policy, mock_box_session):
    created_at = '2016-05-18T17:38:03-07:00',
    expected_url = '{0}/legal_hold_policies/{1}'.format(API.BASE_API_URL, test_legal_hold_policy.object_id)
    mock_box_session.get.return_value.json.return_value = {
        'type': 'legal_hold_policy',
        'id': test_legal_hold_policy.object_id,
        'created_at': created_at
    }
    legal_hold_policy = test_legal_hold_policy.get()
    mock_box_session.get.assert_called_once_with(expected_url, headers=None, params=None)
    assert isinstance(legal_hold_policy, LegalHoldPolicy)
    assert legal_hold_policy.created_at == created_at
github box / box-python-sdk / test / integration / test_retry_and_refresh.py View on Github external
box_client,
        mock_box_network,
        generic_successful_response,
        successful_token_mock,
        unauthorized_response,
):
    mock_box_network.session.request.side_effect = [
        unauthorized_response,
        successful_token_mock,
        generic_successful_response,
    ]
    box_client.folder('0').get()
    assert mock_box_network.session.request.mock_calls == [
        call(
            'GET',
            '{0}/folders/0'.format(API.BASE_API_URL),
            headers=ANY,
            params=None,
        ),
        call(
            'POST',
            '{0}/token'.format(API.OAUTH2_API_URL),
            data=ANY,
            headers={'content-type': 'application/x-www-form-urlencoded', 'User-Agent': ANY, 'X-Box-UA': ANY},
        ),
        call(
            'GET',
            '{0}/folders/0'.format(API.BASE_API_URL),
            headers=ANY,
            params=None,
        ),
github box / box-python-sdk / test / unit / object / test_group.py View on Github external
def test_add_member(test_group, mock_box_session, mock_add_member_response, mock_user, role):
    expected_url = '{0}/group_memberships'.format(API.BASE_API_URL)
    mock_box_session.post.return_value = mock_add_member_response
    new_group_membership = test_group.add_member(mock_user, role, configurable_permissions={'can_run_reports': True})
    data = json.dumps({
        'user': {'id': mock_user.object_id},
        'group': {'id': test_group.object_id},
        'role': role,
        'configurable_permissions': {'can_run_reports': True}
    })
    mock_box_session.post.assert_called_once_with(expected_url, data=data)
    assert isinstance(new_group_membership, GroupMembership)
github box / box-python-sdk / test / integration / test_with_shared_link.py View on Github external
def test_events_endpoint_with_shared_link_causes_box_api_header_to_be_added(
        box_client,
        mock_box_network,
        generic_successful_response,
        shared_link,
        shared_link_password,
        box_api_headers,
):
    # pylint:disable=redefined-outer-name
    mock_box_network.session.request.side_effect = [
        generic_successful_response,
    ]
    stream_position = 1348790499819
    options = {'url': '{0}/events'.format(API.BASE_API_URL), 'retry_timeout': 60}
    box_client.events().with_shared_link(shared_link, shared_link_password).long_poll(options, stream_position)
    assert mock_box_network.session.request.mock_calls == [
        call(
            'GET',
            options['url'],
            headers=box_api_headers,
            timeout=options['retry_timeout'],
            params={'stream_position': stream_position},
        ),
github box / box-python-sdk / test / unit / object / test_user.py View on Github external
def test_remove_email_alias(mock_user, mock_box_session, test_email_alias):
    expected_url = '{0}/users/{1}/email_aliases/{2}'.format(API.BASE_API_URL, mock_user.object_id, test_email_alias.object_id)
    mock_box_session.delete.return_value.ok = True

    result = mock_user.remove_email_alias(test_email_alias)

    mock_box_session.delete.assert_called_once_with(expected_url, expect_json_response=False)
    assert result is True
github box / box-python-sdk / test / unit / object / test_metadata_template.py View on Github external
def test_get(test_metadata_template, mock_box_session):
    expected_url = '{0}/metadata_templates/{1}/{2}/schema'.format(
        API.BASE_API_URL,
        test_metadata_template.scope,
        test_metadata_template.template_key,
    )
    mock_box_session.get.return_value.json.return_value = {
        'type': 'metadata_template',
        'scope': 'enterprise',
        'displayName': 'Vendor Contract',
        'hidden': True,
        'fields': [
            {
                'type': 'date',
                'displayName': 'Birthday',
                'key': 'bday',
            },
            {
                'type': 'enum',