How to use the boxsdk.network.default_network.DefaultNetworkResponse 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 / network / test_network.py View on Github external
def test_default_network_response_properties_pass_through_to_session_response_properties(access_token):
    mock_session_response = Mock(Response)
    mock_session_response.status_code = 200
    mock_session_response.headers = {}
    mock_session_response.raw = Mock()
    mock_session_response.content = json.dumps('content')
    mock_session_response.request = Mock()
    network_reponse = DefaultNetworkResponse(mock_session_response, access_token)
    assert network_reponse.json() == mock_session_response.json()
    assert network_reponse.content == mock_session_response.content
    assert network_reponse.ok == mock_session_response.ok
    assert network_reponse.status_code == mock_session_response.status_code
    assert network_reponse.headers == mock_session_response.headers
    assert network_reponse.response_as_stream == mock_session_response.raw
    assert network_reponse.access_token_used == access_token
github box / box-python-sdk / test / unit / network / test_network.py View on Github external
def _construct_network_response(request_response):
        return DefaultNetworkResponse(
            request_response=request_response,
            access_token_used=access_token,
        )
github box / box-python-sdk / test / unit / auth / test_oauth2.py View on Github external
def network_response_with_missing_tokens(request):
    mock_network_response = Mock(DefaultNetworkResponse)
    mock_network_response.ok = True
    json_dict = {}
    for key in request.param:
        json_dict[key] = 'fake_token'
    mock_network_response.json.return_value = json_dict
    return mock_network_response
github box / box-python-sdk / test / unit / object / test_events.py View on Github external
def empty_events_response(final_stream_position):
    # pylint:disable=redefined-outer-name
    mock_box_response = Mock(BoxResponse)
    mock_network_response = Mock(DefaultNetworkResponse)
    mock_box_response.network_response = mock_network_response
    mock_box_response.json.return_value = mock_json = {'next_stream_position': final_stream_position, 'entries': []}
    mock_box_response.content = json.dumps(mock_json).encode()
    mock_box_response.status_code = 200
    mock_box_response.ok = True
    return mock_box_response
github box / box-python-sdk / test / unit / object / test_legal_hold_policy.py View on Github external
def policies_response(policy_id_1, policy_id_2):
    # pylint disable=redefined-outer-name
    mock_network_response = Mock(DefaultNetworkResponse)
    mock_network_response.json.return_value = {
        'entries': [
            {'type': 'legal_hold_policy', 'id': policy_id_1, 'name': 'Test Policy 1'},
            {'type': 'legal_hold_policy', 'id': policy_id_2, 'name': 'Test Policy 2'}
        ],
        'limit': 5,
    }
    return mock_network_response
github box / box-python-sdk / test / unit / object / test_legal_hold_policy.py View on Github external
def legal_hold_response(legal_hold_id_1, legal_hold_id_2):
    # pylint disable=redefined-outer-name
    mock_network_response = Mock(DefaultNetworkResponse)
    mock_network_response.json.return_value = {
        'entries': [
            {'type': 'legal_hold', 'id': legal_hold_id_1, 'name': 'Test Legal Hold 1'},
            {'type': 'legal_hold', 'id': legal_hold_id_2, 'name': 'Test Legal Hold 2'}
        ],
        'limit': 5,
    }
    return mock_network_response
github box / box-python-sdk / test / unit / object / test_group.py View on Github external
def membership_responses(total, page_size, hidden_in_batch=None):
        offset = 0
        for number_entries in number_entries_per_response(total, page_size, hidden_in_batch):
            entries = take(mock_membership_dict_stream, number_entries)

            mock_box_response = Mock(BoxResponse)
            mock_network_response = Mock(DefaultNetworkResponse)
            mock_box_response.network_response = mock_network_response
            mock_box_response.json.return_value = {
                'entries': entries,
                'total_count': total,
                'offset': offset,
                'limit': page_size,
            }
            offset += page_size
            mock_box_response.status_code = 200
            mock_box_response.ok = True
            yield mock_box_response