def test_getattr_and_getitem(test_object_and_response, mock_box_session): # pylint:disable=redefined-outer-name, protected-access test_object, mock_object_response = test_object_and_response mock_box_session.put.return_value = mock_object_response update_response = BaseObject.update_info(test_object, {}) assert isinstance(update_response, test_object.__class__) assert update_response.object_id == update_response.id == update_response['id']
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
def test_getattr_and_getitem(test_object_and_response, mock_box_session): # pylint:disable=redefined-outer-name, protected-access test_object, mock_object_response = test_object_and_response mock_box_session.put.return_value = mock_object_response update_response = BaseObject.update_info(test_object, {}) assert isinstance(update_response, test_object.__class__) assert update_response.object_id == update_response.id == update_response[ 'id']
def test_update_info(test_object_and_response, mock_box_session, params, headers): # pylint:disable=redefined-outer-name, protected-access test_object, mock_object_response = test_object_and_response expected_url = test_object.get_url() mock_box_session.put.return_value = mock_object_response data = {'foo': 'bar', 'baz': {'foo': 'bar'}, 'num': 4} update_response = BaseObject.update_info(test_object, data, params=params, headers=headers) mock_box_session.put.assert_called_once_with(expected_url, data=json.dumps(data), params=params, headers=headers) assert isinstance(update_response, test_object.__class__) assert update_response.object_id == test_object.object_id