def test_updating_one_field_should_not_blank_others_on_patch_update( self, mock_revoke, app, token_user_one, url_token_detail, user_one): mock_revoke.return_value = True user_one_token = token_user_one new_name = 'The token formerly known as Prince' res = app.patch_json_api(url_token_detail, { 'data': { 'attributes': { 'name': new_name, 'scopes': 'osf.full_write' }, 'id': token_user_one._id, 'type': 'tokens' } }, auth=user_one.auth) user_one_token.reload() assert res.status_code == 200 assert_dict_contains_subset( { 'owner': user_one_token.owner._id, 'name': new_name, 'scopes': '{}'.format(user_one_token.scopes), }, res.json['data']['attributes']) assert res.json['data']['id'] == user_one_token._id
def test_updating_one_field_should_not_blank_others_on_patch_update( self, app, user, user_app, user_app_url): user_app_copy = user_app new_name = 'The instance formerly known as Prince' res = app.patch_json_api(user_app_url, { 'data': { 'attributes': { 'name': new_name }, 'id': user_app.client_id, 'type': 'applications' } }, auth=user.auth, expect_errors=True) user_app_copy.reload() assert res.status_code == 200 assert_dict_contains_subset( { 'client_id': user_app_copy.client_id, 'client_secret': user_app_copy.client_secret, 'owner': user_app_copy.owner._id, 'name': new_name, 'description': user_app_copy.description, 'home_url': user_app_copy.home_url, 'callback_url': user_app_copy.callback_url }, res.json['data']['attributes'])
def test_updating_one_field_should_not_blank_others_on_patch_update( self, app, user, user_app, user_app_url): user_app_copy = user_app new_name = 'The instance formerly known as Prince' res = app.patch_json_api( user_app_url, { 'data': { 'attributes': {'name': new_name}, 'id': user_app.client_id, 'type': 'applications' } }, auth=user.auth, expect_errors=True) user_app_copy.reload() assert res.status_code == 200 assert_dict_contains_subset( { 'client_id': user_app_copy.client_id, 'client_secret': user_app_copy.client_secret, 'owner': user_app_copy.owner._id, 'name': new_name, 'description': user_app_copy.description, 'home_url': user_app_copy.home_url, 'callback_url': user_app_copy.callback_url }, res.json['data']['attributes'] )
def test_updating_one_field_should_not_blank_others_on_patch_update( self, mock_revoke, app, token_user_one, url_token_detail, user_one): mock_revoke.return_value = True user_one_token = token_user_one new_name = 'The token formerly known as Prince' res = app.patch_json_api( url_token_detail, { 'data': { 'attributes': { 'name': new_name, 'scopes': 'osf.full_write' }, 'id': token_user_one._id, 'type': 'tokens' } }, auth=user_one.auth) user_one_token.reload() assert res.status_code == 200 assert_dict_contains_subset( { 'owner': user_one_token.owner._id, 'name': new_name, 'scopes': '{}'.format(user_one_token.scopes), }, res.json['data']['attributes']) assert res.json['data']['id'] == user_one_token._id
def test_updating_one_field_should_not_blank_others_on_patch_update( self, mock_revoke, app, token_user_one, url_token_detail, user_one, read_scope): mock_revoke.return_value = True user_one_token = token_user_one new_name = 'The token formerly known as Prince' res = app.patch_json_api(url_token_detail, { 'data': { 'attributes': { 'name': new_name, }, 'id': token_user_one._id, 'type': 'tokens', 'relationships': { 'scopes': { 'data': [{ 'type': 'scopes', 'id': read_scope.name }] } } } }, auth=user_one.auth) user_one_token.reload() assert res.status_code == 200 assert_dict_contains_subset({ 'name': new_name, }, res.json['data']['attributes']) assert res.json['data']['id'] == user_one_token._id assert res.json['data']['relationships']['owner']['data'][ 'id'] == user_one_token.owner._id assert len(res.json['data']['embeds']['scopes']['data']) == 1 assert res.json['data']['embeds']['scopes']['data'][0][ 'id'] == read_scope.name