How to use the boxsdk.session.box_response.BoxResponse 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 / pagination / test_marker_based_object_collection.py View on Github external
def get_response(limit, marker):
            mock_box_response = Mock(BoxResponse)
            mock_network_response = Mock(DefaultNetworkResponse)
            mock_box_response.network_response = mock_network_response

            mock_json = {}
            # The marker string should be of format: "marker_i", where i is the offset. Parse that out.
            # If the marker is None, then begin paging from the start of the entries.
            offset = 0
            if marker is not None:
                offset = int(marker.split('_')[1])
            mock_json['entries'] = entries[offset:limit + offset]

            # A next_marker is only returned if there are more pages left.
            if (offset + limit) < len(entries):
                mock_json['next_marker'] = 'marker_{0}'.format(offset + limit)
            elif next_marker_value_for_last_page is not self.NO_NEXT_MARKER:
                mock_json['next_marker'] = next_marker_value_for_last_page
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 / pagination / test_limit_offset_based_object_collection.py View on Github external
def get_response(limit, offset):
            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 = {
                'entries': entries[offset:limit + offset],
                'total_count': len(entries),
                'limit': limit,
            }
            mock_box_response.content = json.dumps(mock_json).encode()
            mock_box_response.status_code = 200
            mock_box_response.ok = True
            return mock_box_response
        return get_response
github box / box-python-sdk / test / unit / object / test_folder.py View on Github external
def get_response(limit, offset):
        items_json, items = mock_items
        entries = items_json[offset:limit + offset]
        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 = {
            'entries': entries,
            'total_count': len(entries),
            'limit': limit,
            'offset': offset,
        }
        mock_box_response.content = json.dumps(mock_json).encode()
        mock_box_response.status_code = 200
        mock_box_response.ok = True
        return mock_box_response, items[offset:limit + offset]
    return get_response
github box / box-python-sdk / boxsdk / session / session.py View on Github external
def box_response_constructor(self):
        """Get the constructor for the container class representing an API response"""
        return _BoxResponse