WIP on libraries upgrade
This commit is contained in:
@@ -294,7 +294,7 @@ class UserListTests(AbstractPillarTest):
|
||||
|
||||
def test_list_all_users_subscriber(self):
|
||||
# Regular access should result in only your own info.
|
||||
users = self.get('/api/users', auth_token='token').json()
|
||||
users = self.get('/api/users', auth_token='token').get_json()
|
||||
self.assertEqual(1, users['_meta']['total'])
|
||||
|
||||
# The 'auth' section should be removed.
|
||||
@@ -303,7 +303,7 @@ class UserListTests(AbstractPillarTest):
|
||||
|
||||
def test_list_all_users_admin(self):
|
||||
# Admin access should result in all users
|
||||
users = self.get('/api/users', auth_token='admin-token').json()
|
||||
users = self.get('/api/users', auth_token='admin-token').get_json()
|
||||
self.assertEqual(3, users['_meta']['total'])
|
||||
|
||||
# The 'auth' section should be removed.
|
||||
@@ -314,7 +314,7 @@ class UserListTests(AbstractPillarTest):
|
||||
"""Even admins shouldn't be able to GET auth info."""
|
||||
|
||||
projection = json.dumps({'auth': 1})
|
||||
users = self.get(f'/api/users?projection={projection}', auth_token='admin-token').json()
|
||||
users = self.get(f'/api/users?projection={projection}', auth_token='admin-token').get_json()
|
||||
self.assertEqual(3, users['_meta']['total'])
|
||||
|
||||
# The 'auth' section should be removed.
|
||||
@@ -333,21 +333,21 @@ class UserListTests(AbstractPillarTest):
|
||||
|
||||
def test_own_user_subscriber(self):
|
||||
# Regular access should result in only your own info.
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').json()
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').get_json()
|
||||
self.assertNotIn('auth', user_info)
|
||||
|
||||
def test_own_user_subscriber_explicit_projection(self):
|
||||
# With a custom projection requesting the auth list
|
||||
projection = json.dumps({'auth': 1})
|
||||
user_info = self.get(f'/api/users/123456789abc123456789abc?projection={projection}',
|
||||
auth_token='token').json()
|
||||
auth_token='token').get_json()
|
||||
self.assertNotIn('auth', user_info)
|
||||
|
||||
def test_other_user_subscriber(self):
|
||||
from pillar.api.utils import remove_private_keys
|
||||
|
||||
# Requesting another user should be limited to full name and email.
|
||||
user_info = self.get('/api/users/223456789abc123456789abc', auth_token='token').json()
|
||||
user_info = self.get('/api/users/223456789abc123456789abc', auth_token='token').get_json()
|
||||
self.assertNotIn('auth', user_info)
|
||||
|
||||
regular_info = remove_private_keys(user_info)
|
||||
@@ -357,7 +357,7 @@ class UserListTests(AbstractPillarTest):
|
||||
from pillar.api.utils import remove_private_keys
|
||||
|
||||
# PUTting a user should work, and not mess up the auth field.
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').json()
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').get_json()
|
||||
self.assertNotIn('auth', user_info)
|
||||
|
||||
put_user = remove_private_keys(user_info)
|
||||
@@ -378,7 +378,7 @@ class UserListTests(AbstractPillarTest):
|
||||
group_ids = self.create_standard_groups()
|
||||
|
||||
# A user should be able to change only some fields, but not all.
|
||||
user_info = self.get('/api/users/me', auth_token='token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='token').get_json()
|
||||
|
||||
# Alter all fields (except auth, another test already checks that that's uneditable).
|
||||
put_user = remove_private_keys(user_info)
|
||||
@@ -395,7 +395,7 @@ class UserListTests(AbstractPillarTest):
|
||||
auth_token='token',
|
||||
etag=user_info['_etag'])
|
||||
|
||||
new_user_info = self.get('/api/users/me', auth_token='token').json()
|
||||
new_user_info = self.get('/api/users/me', auth_token='token').get_json()
|
||||
self.assertEqual(new_user_info['full_name'], put_user['full_name'])
|
||||
self.assertEqual(new_user_info['username'], put_user['username'])
|
||||
self.assertEqual(new_user_info['email'], put_user['email'])
|
||||
@@ -409,7 +409,7 @@ class UserListTests(AbstractPillarTest):
|
||||
from pillar.api.utils import remove_private_keys
|
||||
|
||||
# PUTting the user as another user should fail.
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').json()
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').get_json()
|
||||
put_user = remove_private_keys(user_info)
|
||||
|
||||
self.put('/api/users/123456789abc123456789abc', auth_token='other-token',
|
||||
@@ -420,7 +420,7 @@ class UserListTests(AbstractPillarTest):
|
||||
from pillar.api.utils import remove_private_keys
|
||||
|
||||
# PUTting a user should work, and not mess up the auth field.
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').json()
|
||||
user_info = self.get('/api/users/123456789abc123456789abc', auth_token='token').get_json()
|
||||
put_user = remove_private_keys(user_info)
|
||||
|
||||
self.put('/api/users/123456789abc123456789abc', auth_token='admin-token',
|
||||
@@ -841,7 +841,7 @@ class UserCreationTest(AbstractPillarTest):
|
||||
|
||||
etag = db_user['_etag']
|
||||
resp = self.put(f'/api/users/{user_id}', json=puttable, etag=etag,
|
||||
auth_token='user-token', expected_status=200).json()
|
||||
auth_token='user-token', expected_status=200).get_json()
|
||||
etag = resp['_etag']
|
||||
self.put(f'/api/users/{user_id}', json=empty_email, etag=etag,
|
||||
auth_token='user-token', expected_status=422)
|
||||
@@ -851,7 +851,7 @@ class UserCreationTest(AbstractPillarTest):
|
||||
# An admin should be able to edit this user, but also not clear the email address.
|
||||
self.create_user(24 * 'a', roles={'admin'}, token='admin-token')
|
||||
resp = self.put(f'/api/users/{user_id}', json=puttable, etag=etag,
|
||||
auth_token='admin-token', expected_status=200).json()
|
||||
auth_token='admin-token', expected_status=200).get_json()
|
||||
etag = resp['_etag']
|
||||
self.put(f'/api/users/{user_id}', json=empty_email, etag=etag,
|
||||
auth_token='admin-token', expected_status=422)
|
||||
|
@@ -296,7 +296,7 @@ class HomeProjectTest(AbstractHomeProjectTest):
|
||||
|
||||
# Create home project by getting it.
|
||||
resp = self.get('/api/bcloud/home-project', auth_token='token')
|
||||
before_delete_json_proj = resp.json()
|
||||
before_delete_json_proj = resp.get_json()
|
||||
|
||||
# Delete the project.
|
||||
self.delete(f'/api/projects/{before_delete_json_proj["_id"]}',
|
||||
@@ -305,7 +305,7 @@ class HomeProjectTest(AbstractHomeProjectTest):
|
||||
|
||||
# Recreate home project by getting it.
|
||||
resp = self.get('/api/bcloud/home-project', auth_token='token')
|
||||
after_delete_json_proj = resp.json()
|
||||
after_delete_json_proj = resp.get_json()
|
||||
|
||||
self.assertEqual(before_delete_json_proj['_id'],
|
||||
after_delete_json_proj['_id'])
|
||||
@@ -452,7 +452,7 @@ class TextureLibraryTest(AbstractHomeProjectTest):
|
||||
|
||||
def test_hdri_library__no_bcloud_version(self):
|
||||
resp = self.get('/api/bcloud/texture-libraries', auth_token='token')
|
||||
libs = resp.json()['_items']
|
||||
libs = resp.get_json()['_items']
|
||||
library_project_ids = {proj['_id'] for proj in libs}
|
||||
|
||||
self.assertNotIn(str(self.hdri_proj_id), library_project_ids)
|
||||
@@ -462,7 +462,7 @@ class TextureLibraryTest(AbstractHomeProjectTest):
|
||||
resp = self.get('/api/bcloud/texture-libraries',
|
||||
auth_token='token',
|
||||
headers={'Blender-Cloud-Addon': '1.3.3'})
|
||||
libs = resp.json()['_items']
|
||||
libs = resp.get_json()['_items']
|
||||
library_project_ids = {proj['_id'] for proj in libs}
|
||||
self.assertNotIn(str(self.hdri_proj_id), library_project_ids)
|
||||
self.assertIn(str(self.tex_proj_id), library_project_ids)
|
||||
@@ -471,7 +471,7 @@ class TextureLibraryTest(AbstractHomeProjectTest):
|
||||
resp = self.get('/api/bcloud/texture-libraries',
|
||||
auth_token='token',
|
||||
headers={'Blender-Cloud-Addon': '1.4.0'})
|
||||
libs = resp.json()['_items']
|
||||
libs = resp.get_json()['_items']
|
||||
library_project_ids = {proj['_id'] for proj in libs}
|
||||
self.assertIn(str(self.hdri_proj_id), library_project_ids)
|
||||
self.assertIn(str(self.tex_proj_id), library_project_ids)
|
||||
@@ -539,11 +539,11 @@ class HdriSortingTest(AbstractHomeProjectTest):
|
||||
'name': 'Symmetrical Garden'
|
||||
}
|
||||
resp = self.post('/api/nodes', json=node, expected_status=201, auth_token='token')
|
||||
node_info = resp.json()
|
||||
node_info = resp.json
|
||||
|
||||
# Check that the node's files are in the right order
|
||||
resp = self.get('/api/nodes/%s' % node_info['_id'], auth_token='token')
|
||||
get_node = resp.json()
|
||||
get_node = resp.json
|
||||
|
||||
self.assertEqual(['256p', '1k', '2k'],
|
||||
[file_info['resolution']
|
||||
@@ -565,7 +565,7 @@ class HdriSortingTest(AbstractHomeProjectTest):
|
||||
'name': 'Symmetrical Garden'
|
||||
}
|
||||
resp = self.post('/api/nodes', json=node, expected_status=201, auth_token='token')
|
||||
node_info = resp.json()
|
||||
node_info = resp.json
|
||||
|
||||
# Mess up the node's order
|
||||
node['properties']['files'] = [
|
||||
@@ -578,7 +578,7 @@ class HdriSortingTest(AbstractHomeProjectTest):
|
||||
|
||||
# Check that the node's files are in the right order
|
||||
resp = self.get('/api/nodes/%s' % node_info['_id'], auth_token='token')
|
||||
get_node = resp.json()
|
||||
get_node = resp.json
|
||||
|
||||
self.assertEqual(['256p', '1k', '2k'],
|
||||
[file_info['resolution']
|
||||
|
@@ -192,7 +192,7 @@ class FileMaxSizeTest(AbstractPillarTest):
|
||||
expected_status=201,
|
||||
auth_token='token',
|
||||
files={'file': (test_file, 'test_file.bin')})
|
||||
stream_info = resp.json()
|
||||
stream_info = resp.get_json()
|
||||
file_id = stream_info['file_id']
|
||||
|
||||
self.assert_file_doc_ok(file_id, file_size)
|
||||
@@ -216,7 +216,7 @@ class FileMaxSizeTest(AbstractPillarTest):
|
||||
expected_status=201,
|
||||
auth_token='token',
|
||||
files={'file': (test_file, 'test_file.bin')})
|
||||
stream_info = resp.json()
|
||||
stream_info = resp.get_json()
|
||||
file_id = stream_info['file_id']
|
||||
|
||||
self.assert_file_doc_ok(file_id, file_size)
|
||||
|
@@ -16,10 +16,10 @@ class CoerceMarkdownTest(AbstractPillarTest):
|
||||
}
|
||||
|
||||
created_data = self.post('/api/nodes', json=node, expected_status=201,
|
||||
auth_token='token-a').json()
|
||||
auth_token='token-a').get_json()
|
||||
node_id = created_data['_id']
|
||||
|
||||
json_node = self.get(f'/api/nodes/{node_id}', auth_token='token-a').json()
|
||||
json_node = self.get(f'/api/nodes/{node_id}', auth_token='token-a').get_json()
|
||||
self.assertEqual('<h1>Title</h1>\n<p>This is content.</p>\n',
|
||||
json_node['_description_html'])
|
||||
|
||||
@@ -43,7 +43,7 @@ class CoerceMarkdownTest(AbstractPillarTest):
|
||||
|
||||
pid = r['_id']
|
||||
|
||||
json_proj = self.get(f'/api/projects/{pid}', auth_token='token-a').json()
|
||||
json_proj = self.get(f'/api/projects/{pid}', auth_token='token-a').get_json()
|
||||
json_proj.pop('node_types', None) # just to make it easier to print
|
||||
import pprint
|
||||
pprint.pprint(json_proj)
|
||||
@@ -63,9 +63,9 @@ class CoerceMarkdownTest(AbstractPillarTest):
|
||||
}
|
||||
|
||||
created_data = self.post('/api/nodes', json=node, expected_status=201,
|
||||
auth_token='token-a').json()
|
||||
auth_token='token-a').get_json()
|
||||
node_id = created_data['_id']
|
||||
|
||||
json_node = self.get(f'/api/nodes/{node_id}', auth_token='token-a').json()
|
||||
json_node = self.get(f'/api/nodes/{node_id}', auth_token='token-a').get_json()
|
||||
expect = '<h1>Title</h1>\n<!-- {test a="b"} -->\n'
|
||||
self.assertEqual(expect, json_node['_description_html'])
|
||||
|
@@ -253,7 +253,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
'name': str(self),
|
||||
'properties': {},
|
||||
})
|
||||
self.node_id = resp.json()['_id']
|
||||
self.node_id = resp.get_json()['_id']
|
||||
|
||||
def _check_share_data(self, share_data):
|
||||
base_url = self.app.config['SHORT_LINK_BASE_URL']
|
||||
@@ -265,7 +265,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
# Share the node
|
||||
resp = self.post('/api/nodes/%s/share' % self.node_id, auth_token='token',
|
||||
expected_status=201)
|
||||
share_data = resp.json()
|
||||
share_data = resp.get_json()
|
||||
|
||||
self._check_share_data(share_data)
|
||||
|
||||
@@ -279,7 +279,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
|
||||
# Check that an anonymous user has acces.
|
||||
resp = self.get('/api/nodes/%s' % self.node_id)
|
||||
self.assertEqual(str(self.node_id), resp.json()['_id'])
|
||||
self.assertEqual(str(self.node_id), resp.get_json()['_id'])
|
||||
|
||||
def test_other_user_access_shared_node(self):
|
||||
# Share the node
|
||||
@@ -290,7 +290,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
other_user_id = self.create_user(user_id=24 * 'a')
|
||||
self.create_valid_auth_token(other_user_id, 'other-token')
|
||||
resp = self.get('/api/nodes/%s' % self.node_id, auth_token='other-token')
|
||||
self.assertEqual(str(self.node_id), resp.json()['_id'])
|
||||
self.assertEqual(str(self.node_id), resp.get_json()['_id'])
|
||||
|
||||
def test_get_share_data__unshared_node(self):
|
||||
self.get('/api/nodes/%s/share' % self.node_id,
|
||||
@@ -304,7 +304,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
|
||||
# Then get its share info.
|
||||
resp = self.get('/api/nodes/%s/share' % self.node_id, auth_token='token')
|
||||
share_data = resp.json()
|
||||
share_data = resp.get_json()
|
||||
|
||||
self._check_share_data(share_data)
|
||||
|
||||
@@ -349,7 +349,7 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
resp = self.post('/api/nodes/%s/share' % self.node_id, auth_token='token',
|
||||
expected_status=201)
|
||||
|
||||
share_data = resp.json()
|
||||
share_data = resp.get_json()
|
||||
|
||||
self._check_share_data(share_data)
|
||||
self.assertEqual(3, create_short_link.call_count)
|
||||
@@ -360,19 +360,19 @@ class NodeSharingTest(AbstractPillarTest):
|
||||
# Share the node
|
||||
resp = self.post('/api/nodes/%s/share' % self.node_id, auth_token='token',
|
||||
expected_status=201)
|
||||
share_data = resp.json()
|
||||
share_data = resp.get_json()
|
||||
|
||||
# Get the node with short_code
|
||||
resp = self.get('/api/nodes/%s' % self.node_id,
|
||||
json={'projection': {'short_code': 1}})
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
self.assertEqual(node['short_code'], share_data['short_code'])
|
||||
self.assertTrue(node['short_link'].endswith(share_data['short_code']))
|
||||
|
||||
# Get the node without short_code
|
||||
resp = self.get('/api/nodes/%s' % self.node_id,
|
||||
qs={'projection': {'short_code': 0}})
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
self.assertNotIn('short_code', node)
|
||||
self.assertNotIn('short_link', node)
|
||||
|
||||
@@ -409,10 +409,10 @@ class TextureSortFilesTest(AbstractPillarTest):
|
||||
},
|
||||
'user': ctd.EXAMPLE_PROJECT_OWNER_ID,
|
||||
})
|
||||
node_id = resp.json()['_id']
|
||||
node_id = resp.get_json()['_id']
|
||||
|
||||
resp = self.get(f'/api/nodes/{node_id}', auth_token='token')
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
map_types = [f['map_type'] for f in node['properties']['files']]
|
||||
self.assertEqual(['color', 'alpha', 'specular'], map_types)
|
||||
|
||||
@@ -435,10 +435,10 @@ class TextureSortFilesTest(AbstractPillarTest):
|
||||
},
|
||||
'user': ctd.EXAMPLE_PROJECT_OWNER_ID,
|
||||
})
|
||||
node_id = resp.json()['_id']
|
||||
node_id = resp.get_json()['_id']
|
||||
|
||||
resp = self.get(f'/api/nodes/{node_id}', auth_token='token')
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
map_types = [f['map_type'] for f in node['properties']['files']]
|
||||
self.assertEqual(['alpha', 'bump', 'specular'], map_types)
|
||||
|
||||
@@ -453,10 +453,10 @@ class TextureSortFilesTest(AbstractPillarTest):
|
||||
},
|
||||
'user': ctd.EXAMPLE_PROJECT_OWNER_ID,
|
||||
})
|
||||
node_id = resp.json()['_id']
|
||||
node_id = resp.get_json()['_id']
|
||||
|
||||
resp = self.get(f'/api/nodes/{node_id}', auth_token='token')
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
self.assertEqual([], node['properties']['files'])
|
||||
|
||||
def test_no_files_list(self):
|
||||
@@ -468,9 +468,9 @@ class TextureSortFilesTest(AbstractPillarTest):
|
||||
'properties': {},
|
||||
'user': ctd.EXAMPLE_PROJECT_OWNER_ID,
|
||||
})
|
||||
node_id = resp.json()['_id']
|
||||
node_id = resp.get_json()['_id']
|
||||
|
||||
resp = self.get(f'/api/nodes/{node_id}', auth_token='token')
|
||||
node = resp.json()
|
||||
node = resp.get_json()
|
||||
self.assertNotIn('files', node['properties'])
|
||||
|
||||
|
@@ -843,7 +843,7 @@ class IPRangeTest(AbstractIPRangeSingleOrgTest):
|
||||
def test_ipranges_get_via_eve(self):
|
||||
self.test_patch_set_ip_ranges_happy()
|
||||
r = self.get(f'/api/organizations/{self.org_id}', auth_token='token')
|
||||
from_eve = r.json()
|
||||
from_eve = r.get_json()
|
||||
|
||||
# Eve cannot return binary data, at least not until we upgrade to a version
|
||||
# that depends on Cerberus >= 1.0.
|
||||
@@ -853,7 +853,7 @@ class IPRangeTest(AbstractIPRangeSingleOrgTest):
|
||||
self.assertEqual(expect_ranges, from_eve['ip_ranges'])
|
||||
|
||||
r = self.get(f'/api/organizations', auth_token='token')
|
||||
from_eve = r.json()
|
||||
from_eve = r.get_json()
|
||||
self.assertEqual(expect_ranges, from_eve['_items'][0]['ip_ranges'])
|
||||
|
||||
def test_patch_unset_ip_ranges_happy(self):
|
||||
@@ -996,7 +996,7 @@ class IPRangeLoginRolesTest(AbstractIPRangeSingleOrgTest):
|
||||
# user in the database.
|
||||
resp = self.get('/api/users/me', auth_token='usertoken',
|
||||
headers=headers, environ_overrides=env)
|
||||
me = resp.json()
|
||||
me = resp.get_json()
|
||||
|
||||
# The IP-based roles should be stored in the token document.
|
||||
self.enter_app_context()
|
||||
|
@@ -24,7 +24,7 @@ class AbstractPatchCommentTest(AbstractPillarTest):
|
||||
resp = self.post('/api/nodes', json=asset,
|
||||
auth_token='owner-token',
|
||||
expected_status=201)
|
||||
self.asset_id = resp.json()['_id']
|
||||
self.asset_id = resp.get_json()['_id']
|
||||
|
||||
# Create the comment
|
||||
comment = {'description': '',
|
||||
@@ -43,7 +43,7 @@ class AbstractPatchCommentTest(AbstractPillarTest):
|
||||
resp = self.post('/api/nodes', json=comment,
|
||||
auth_token='owner-token',
|
||||
expected_status=201)
|
||||
comment_info = resp.json()
|
||||
comment_info = resp.get_json()
|
||||
self.node_url = '/api/nodes/%s' % comment_info['_id']
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
||||
# Patch the node
|
||||
res = self.patch(self.node_url,
|
||||
json={'op': 'upvote'},
|
||||
auth_token='token').json()
|
||||
auth_token='token').get_json()
|
||||
self.assertEqual(1, res['properties']['rating_positive'])
|
||||
self.assertEqual(0, res['properties']['rating_negative'])
|
||||
|
||||
# Get the node again, to inspect its changed state.
|
||||
patched_node = self.get(self.node_url, auth_token='token').json()
|
||||
patched_node = self.get(self.node_url, auth_token='token').get_json()
|
||||
self.assertEqual(1, patched_node['properties']['rating_positive'])
|
||||
self.assertEqual(0, patched_node['properties']['rating_negative'])
|
||||
self.assertEqual({'user': str(self.user_id), 'is_positive': True},
|
||||
@@ -87,12 +87,12 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
||||
# Patch the node
|
||||
res = self.patch(self.node_url,
|
||||
json={'op': 'downvote'},
|
||||
auth_token='token').json()
|
||||
auth_token='token').get_json()
|
||||
self.assertEqual(0, res['properties']['rating_positive'])
|
||||
self.assertEqual(1, res['properties']['rating_negative'])
|
||||
|
||||
# Get the node again, to inspect its changed state.
|
||||
patched_node = self.get(self.node_url, auth_token='token').json()
|
||||
patched_node = self.get(self.node_url, auth_token='token').get_json()
|
||||
self.assertEqual(0, patched_node['properties']['rating_positive'])
|
||||
self.assertEqual(1, patched_node['properties']['rating_negative'])
|
||||
self.assertEqual({'user': str(self.user_id), 'is_positive': False},
|
||||
@@ -124,7 +124,7 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
||||
auth_token='token')
|
||||
|
||||
# Get the node again, to inspect its changed state.
|
||||
patched_node = self.get(self.node_url, auth_token='token').json()
|
||||
patched_node = self.get(self.node_url, auth_token='token').get_json()
|
||||
self.assertEqual(0, patched_node['properties']['rating_positive'])
|
||||
self.assertEqual(0, patched_node['properties']['rating_negative'])
|
||||
self.assertEqual([], patched_node['properties'].get('ratings', []))
|
||||
@@ -167,7 +167,7 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
||||
auth_token='other-token-4')
|
||||
|
||||
# Inspect the result
|
||||
patched_node = self.get(self.node_url, auth_token='token').json()
|
||||
patched_node = self.get(self.node_url, auth_token='token').get_json()
|
||||
self.assertEqual(3, patched_node['properties']['rating_positive'])
|
||||
self.assertEqual(2, patched_node['properties']['rating_negative'])
|
||||
self.assertEqual([
|
||||
@@ -181,16 +181,16 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
||||
|
||||
class EditCommentTest(AbstractPatchCommentTest):
|
||||
def test_comment_edit_happy(self, token='owner-token'):
|
||||
pre_node = self.get(self.node_url, auth_token=token).json()
|
||||
pre_node = self.get(self.node_url, auth_token=token).get_json()
|
||||
|
||||
res = self.patch(self.node_url,
|
||||
json={'op': 'edit', 'content': 'Je moeder is niet je vader.'},
|
||||
auth_token=token).json()
|
||||
auth_token=token).get_json()
|
||||
self.assertEqual('<p>Je moeder is niet je vader.</p>\n',
|
||||
res['properties']['_content_html'])
|
||||
|
||||
# Get the node again, to inspect its changed state.
|
||||
patched_node = self.get(self.node_url, auth_token=token).json()
|
||||
patched_node = self.get(self.node_url, auth_token=token).get_json()
|
||||
self.assertEqual('Je moeder is niet je vader.',
|
||||
patched_node['properties']['content'])
|
||||
self.assertEqual('<p>Je moeder is niet je vader.</p>\n',
|
||||
@@ -210,7 +210,7 @@ class EditCommentTest(AbstractPatchCommentTest):
|
||||
expected_status=403)
|
||||
|
||||
# Get the node again, to inspect its old state.
|
||||
patched_node = self.get(self.node_url, auth_token='token').json()
|
||||
patched_node = self.get(self.node_url, auth_token='token').get_json()
|
||||
self.assertEqual('Purrrr kittycat',
|
||||
patched_node['properties']['content'])
|
||||
self.assertEqual('<p>Purrrr kittycat</p>\n',
|
||||
|
@@ -60,7 +60,7 @@ class PatchHandlerTest(AbstractPillarTest):
|
||||
resp = self.patch('/api/test/%s' % oid, auth_token='user-token',
|
||||
json={'op': 'test-echo',
|
||||
'echo': '¡Thith ith Špahtah!'})
|
||||
self.assertEqual({'echo': '¡Thith ith Špahtah!'}, resp.json())
|
||||
self.assertEqual({'echo': '¡Thith ith Špahtah!'}, resp.get_json())
|
||||
|
||||
def test_patch_empty_response(self):
|
||||
import bson
|
||||
|
@@ -166,7 +166,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
project_info = self._create_user_and_project(['subscriber'])
|
||||
project_url = '/api/projects/%(_id)s' % project_info
|
||||
|
||||
project = self.get(project_url, auth_token='token').json()
|
||||
project = self.get(project_url, auth_token='token').get_json()
|
||||
|
||||
# Create another user we can try and assign the project to.
|
||||
other_user_id = 'f00dd00df00dd00df00dd00d'
|
||||
@@ -199,7 +199,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
# Re-fetch from database to see which fields actually made it there.
|
||||
# equal to put_project -> changed in DB
|
||||
# equal to project -> not changed in DB
|
||||
db_proj = self.get(project_url, auth_token='token').json()
|
||||
db_proj = self.get(project_url, auth_token='token').get_json()
|
||||
self.assertEqual(project['url'], db_proj['url'])
|
||||
self.assertEqual(put_project['description'], db_proj['description'])
|
||||
self.assertEqual(put_project['name'], db_proj['name'])
|
||||
@@ -391,7 +391,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
expected_status=204)
|
||||
|
||||
resp = self.get(f'/api/files/{fid}', expected_status=404)
|
||||
self.assertEqual(str(fid), resp.json()['_id'])
|
||||
self.assertEqual(str(fid), resp.get_json()['_id'])
|
||||
|
||||
with self.app.app_context():
|
||||
db_file_after = files_coll.find_one(fid)
|
||||
@@ -413,7 +413,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
project_info['picture_header'] = str(fid)
|
||||
resp = self.put(proj_url, auth_token='token', etag=etag,
|
||||
json=remove_private_keys(project_info))
|
||||
etag = resp.json()['_etag']
|
||||
etag = resp.get_json()['_etag']
|
||||
|
||||
# DELETE the project.
|
||||
self.delete(proj_url, auth_token='token', etag=etag, expected_status=204)
|
||||
@@ -433,7 +433,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
self.patch(proj_url, auth_token='token', json={'op': 'undelete'}, expected_status=204)
|
||||
|
||||
resp = self.get(f'/api/files/{fid}')
|
||||
self.assertEqual(str(fid), resp.json()['_id'])
|
||||
self.assertEqual(str(fid), resp.get_json()['_id'])
|
||||
|
||||
with self.app.app_context():
|
||||
files_coll = self.app.db('files')
|
||||
@@ -456,7 +456,7 @@ class ProjectEditTest(AbstractProjectTest):
|
||||
db_file_after = files_coll.find_one(fid)
|
||||
self.assertTrue(db_file_after['_deleted'])
|
||||
|
||||
resp = self.get(proj_url, auth_token='token', expected_status=404).json()
|
||||
resp = self.get(proj_url, auth_token='token', expected_status=404).get_json()
|
||||
self.assertTrue(resp['_deleted'])
|
||||
|
||||
|
||||
|
@@ -31,8 +31,8 @@ class ProjectMergerTest(AbstractPillarTest):
|
||||
with self.app.app_context():
|
||||
merging.merge_project(self.pid_from, self.pid_to)
|
||||
|
||||
db_file = self.get(f'/api/files/{fid}').json()
|
||||
db_node = self.get(f'/api/nodes/{nid}').json()
|
||||
db_file = self.get(f'/api/files/{fid}').get_json()
|
||||
db_node = self.get(f'/api/nodes/{nid}').get_json()
|
||||
|
||||
self.assertEqual(db_file['project'], str(self.pid_to))
|
||||
self.assertEqual(db_node['project'], str(self.pid_to))
|
||||
|
@@ -63,7 +63,7 @@ class ServiceAccountCreationTest(AbstractPillarTest):
|
||||
resp = self.put(f'/api/users/{user_id}',
|
||||
json=puttable,
|
||||
auth_token=token['token'],
|
||||
etag=etag).json()
|
||||
etag=etag).get_json()
|
||||
etag = resp['_etag']
|
||||
|
||||
with self.app.test_request_context():
|
||||
|
@@ -58,7 +58,7 @@ class RoleUpdatingTest(AbstractPillarTest):
|
||||
|
||||
self.get('/api/bcloud/update-subscription', auth_token='my-happy-token',
|
||||
expected_status=204)
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual({'subscriber', 'has_subscription'}, set(user_info['roles']))
|
||||
|
||||
# Check the signals
|
||||
@@ -75,13 +75,13 @@ class RoleUpdatingTest(AbstractPillarTest):
|
||||
|
||||
# Make sure this user is currently known as a subcriber.
|
||||
self.create_user(roles={'subscriber', 'has_subscription'}, token='my-happy-token')
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual({'subscriber', 'has_subscription'}, set(user_info['roles']))
|
||||
|
||||
# And after updating, it shouldn't be.
|
||||
self.get('/api/bcloud/update-subscription', auth_token='my-happy-token',
|
||||
expected_status=204)
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual([], user_info['roles'])
|
||||
|
||||
self.assertEqual(1, len(self.user_subs_signal_calls))
|
||||
@@ -98,7 +98,7 @@ class RoleUpdatingTest(AbstractPillarTest):
|
||||
self.get('/api/bcloud/update-subscription', auth_token='my-happy-token',
|
||||
expected_status=204)
|
||||
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual(['demo'], user_info['roles'])
|
||||
|
||||
self.assertEqual(1, len(self.user_subs_signal_calls))
|
||||
@@ -113,13 +113,13 @@ class RoleUpdatingTest(AbstractPillarTest):
|
||||
|
||||
# Make sure this user is currently known as demo user.
|
||||
self.create_user(roles={'demo'}, token='my-happy-token')
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual(['demo'], user_info['roles'])
|
||||
|
||||
# And after updating, it shouldn't be.
|
||||
self.get('/api/bcloud/update-subscription', auth_token='my-happy-token',
|
||||
expected_status=204)
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').json()
|
||||
user_info = self.get('/api/users/me', auth_token='my-happy-token').get_json()
|
||||
self.assertEqual([], user_info['roles'])
|
||||
|
||||
self.assertEqual(1, len(self.user_subs_signal_calls))
|
||||
|
Reference in New Issue
Block a user