• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python assertions.assertStatusOk函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pytest_girder.assertions.assertStatusOk函数的典型用法代码示例。如果您正苦于以下问题:Python assertStatusOk函数的具体用法?Python assertStatusOk怎么用?Python assertStatusOk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assertStatusOk函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testDeleteItemUpdatesSize

def testDeleteItemUpdatesSize(server, admin, hierarchy):
    resp = server.request(path='/item/%s' % hierarchy.items[0]['_id'], method='DELETE', user=admin)
    assertStatusOk(resp)

    assertNodeSize(hierarchy.folders[0], Folder, 0)
    assertNodeSize(hierarchy.folders[1], Folder, 10)
    assertNodeSize(hierarchy.collections[0], Collection, 10)
开发者ID:girder,项目名称:girder,代码行数:7,代码来源:test_size.py


示例2: testCustomWebRoot

def testCustomWebRoot(route, server):
    """
    Tests the ability of plugins to serve their own custom server roots.
    """
    resp = server.request(route)
    assertStatusOk(resp)
    assert resp.json == ['custom REST route']
开发者ID:girder,项目名称:girder,代码行数:7,代码来源:test_api_prefix.py


示例3: testTokenSessionReturnsPassedToken

def testTokenSessionReturnsPassedToken(server, token):
    # If we ask for another token, passing in the first one, we should get
    # the first one back
    resp = server.request(path='/token/session', method='GET', token=token)
    assertStatusOk(resp)
    token2 = resp.json['token']
    assert token == token2
开发者ID:data-exp-lab,项目名称:girder,代码行数:7,代码来源:test_token.py


示例4: testDisableApiKeysSetting

def testDisableApiKeysSetting(server, user):
    errMsg = 'API key functionality is disabled on this instance.'

    resp = server.request('/api_key', method='POST', user=user, params={
        'name': 'test key'
    })
    assertStatusOk(resp)

    # Disable API keys
    Setting().set(SettingKey.API_KEYS, False)

    # Key should still exist
    key = ApiKey().load(resp.json['_id'], force=True, exc=True)

    # No longer possible to authenticate with existing key
    resp = server.request('/api_key/token', method='POST', params={
        'key': key['key']
    })
    assertStatus(resp, 400)
    assert resp.json['message'] == errMsg

    # No longer possible to create new keys
    resp = server.request('/api_key', method='POST', user=user, params={
        'name': 'should not work'
    })
    assertStatus(resp, 400)
    assert resp.json['message'] == errMsg

    # Still possible to delete key
    resp = server.request('/api_key/%s' % key['_id'], method='DELETE', user=user)
    assertStatusOk(resp)
    assert ApiKey().load(key['_id'], force=True) is None
开发者ID:data-exp-lab,项目名称:girder,代码行数:32,代码来源:test_api_key.py


示例5: test_get_cjson

def test_get_cjson(server, calculation, user):

    assert '_id' in calculation
    assert 'moleculeId' in calculation
    calc_id = str(calculation['_id'])
    calc_molecule_id = str(calculation['moleculeId'])

    # Get the cjson for the calculation
    r = server.request(
        '/calculations/%s/cjson' %
        calc_id, method='GET', user=user)
    assertStatusOk(r)

    cjson = json.loads(r.json)

    # Should have all the needed cjson components
    assert 'atoms' in cjson
    assert 'coords' in cjson['atoms']
    assert '3d' in cjson['atoms']['coords']
    assert len(cjson['atoms']['coords']['3d']) == 24  # 3 * 8 atoms = 24

    assert 'elements' in cjson['atoms']
    assert 'number' in cjson['atoms']['elements']
    assert cjson['atoms']['elements']['number'].count(1) == 6
    assert cjson['atoms']['elements']['number'].count(6) == 2
    assert len(cjson['atoms']['elements']['number']) == 8

    assert 'bonds' in cjson
    assert 'connections' in cjson['bonds']
    assert 'order' in cjson['bonds']
    assert len(cjson['bonds']['order']) == 7
开发者ID:OpenChemistry,项目名称:mongochemserver,代码行数:31,代码来源:calculations_test.py


示例6: testTokenSessionDeletion

def testTokenSessionDeletion(server, token):
    # With the token should succeed
    resp = server.request(path='/token/session', method='DELETE', token=token)
    assertStatusOk(resp)
    # Now the token is gone, so it should fail
    resp = server.request(path='/token/session', method='DELETE', token=token)
    assertStatus(resp, 401)
开发者ID:data-exp-lab,项目名称:girder,代码行数:7,代码来源:test_token.py


示例7: test_put_properties

def test_put_properties(server, molecule, calculation, user):
    from girder.plugins.molecules.models.calculation import Calculation
    from girder.constants import AccessType

    assert '_id' in calculation
    assert 'moleculeId' in calculation
    assert 'properties' in calculation
    calc_id = str(calculation['_id'])
    calc_molecule_id = str(calculation['moleculeId'])
    calc_properties = calculation['properties']

    # We put these properties in ourselves
    assert 'molecular mass' in calc_properties
    assert 'boiling point' in calc_properties
    assert 'melting point' in calc_properties

    # Make sure these have the right values
    assert pytest.approx(calc_properties['molecular mass'], 1.e-4) == 30.0690
    assert calc_properties['melting point'] == -172
    assert calc_properties['boiling point'] == -88

    # Replace these properties with some new properties
    new_properties = {
        'critical temperature': 32.2,
        'critical pressure': 49.0
    }
    r = server.request('/calculations/%s/properties' % calc_id, method='PUT',
                       body=json.dumps(new_properties), user=user,
                       type='application/json')
    assertStatusOk(r)

    # Grab the new calculation
    updated_calc = Calculation().load(calc_id, level=AccessType.READ, user=user)

    # It should have an _id and a molecule id, and it should match
    assert '_id' in updated_calc
    assert 'moleculeId' in updated_calc
    assert 'properties' in updated_calc

    assert str(updated_calc['_id']) == calc_id
    assert str(updated_calc['moleculeId']) == calc_molecule_id

    # Make sure the old properties are no longer here
    updated_calc_properties = updated_calc['properties']
    assert 'molecular mass' not in updated_calc_properties
    assert 'boiling point' not in updated_calc_properties
    assert 'melting point' not in updated_calc_properties

    # The new properties should be here, though
    assert 'critical temperature' in updated_calc_properties
    assert 'critical pressure' in updated_calc_properties

    # Make sure these are correct also
    assert pytest.approx(
        updated_calc_properties['critical temperature'],
        1.e-1) == new_properties['critical temperature']
    assert pytest.approx(
        updated_calc_properties['critical pressure'],
        1.e-1) == new_properties['critical pressure']
开发者ID:OpenChemistry,项目名称:mongochemserver,代码行数:59,代码来源:calculations_test.py


示例8: testPluginRestRoutes

def testPluginRestRoutes(server):
    resp = server.request('/describe')
    assertStatusOk(resp)
    assert '/other' in resp.json['paths']

    resp = server.request('/other')
    assertStatusOk(resp)
    assert resp.json == ['custom REST route']
开发者ID:girder,项目名称:girder,代码行数:8,代码来源:test_custom_root.py


示例9: testLoadModelDecorator

def testLoadModelDecorator(server, user):
    resp = server.request(
        path='/accesstest/test_loadmodel_plain/%s' % user['_id'], method='GET')
    assertStatusOk(resp)
    assert resp.json['_id'] == str(user['_id'])

    resp = server.request(path='/accesstest/test_loadmodel_query', params={'userId': None})
    assertStatus(resp, 400)
    assert resp.json['message'] == 'Invalid ObjectId: None'
开发者ID:girder,项目名称:girder,代码行数:9,代码来源:test_access.py


示例10: apiKey

def apiKey(server, user):
    # Create a new API key with full access
    resp = server.request('/api_key', method='POST', params={
        'name': 'test key'
    }, user=user)
    assertStatusOk(resp)
    apiKey = ApiKey().load(resp.json['_id'], force=True)

    yield apiKey
开发者ID:data-exp-lab,项目名称:girder,代码行数:9,代码来源:test_api_key.py


示例11: testMoveSubfolderToUser

def testMoveSubfolderToUser(server, admin, hierarchy):
    resp = server.request(
        path='/folder/%s' % hierarchy.folders[1]['_id'], method='PUT',
        user=admin, params={
            'parentId': admin['_id'],
            'parentType': 'user'
        })
    assertStatusOk(resp)
    assertNodeSize(admin, User, 10)
    assertNodeSize(hierarchy.collections[0], Collection, 1)
开发者ID:girder,项目名称:girder,代码行数:10,代码来源:test_size.py


示例12: testApiDocsContent

def testApiDocsContent(server):
    """
    Test content of API documentation page.
    """
    resp = server.request(path='/api/v1', method='GET', isJson=False, prefix='')
    assertStatusOk(resp)
    body = getResponseBody(resp)

    assert 'Girder REST API Documentation' in body
    assert 'This is not a sandbox' in body
    assert 'id="swagger-ui-container"' in body
开发者ID:girder,项目名称:girder,代码行数:11,代码来源:test_api_docs.py


示例13: testTokenCreationDuration

def testTokenCreationDuration(server, user, apiKey):
    defaultDuration = Setting().get(SettingKey.COOKIE_LIFETIME)
    # We should be able to request a duration shorter than default
    resp = server.request('/api_key/token', method='POST', params={
        'key': apiKey['key'],
        'duration': defaultDuration - 1
    })
    assertStatusOk(resp)
    token = Token().load(
        resp.json['authToken']['token'], force=True, objectId=False)
    duration = token['expires'] - token['created']
    assert duration == datetime.timedelta(days=defaultDuration - 1)
开发者ID:data-exp-lab,项目名称:girder,代码行数:12,代码来源:test_api_key.py


示例14: testUploaderUser

def testUploaderUser(provisionedServer, smtp):
    # Create an uploader admin
    resp = provisionedServer.request(path='/user', method='POST', params={
        'email': '[email protected]',
        'login': 'uploader-admin',
        'firstName': 'uploader',
        'lastName': 'admin',
        'password': 'password'
    })
    assertStatusOk(resp)
    uploaderAdmin = User().findOne({'login': 'uploader-admin'})
    assert uploaderAdmin is not None
    contributorsGroup = Group().findOne({'name': 'Dataset Contributors'})
    assert contributorsGroup is not None
    Group().addUser(contributorsGroup, uploaderAdmin, level=AccessType.WRITE)

    # Create an uploader user
    resp = provisionedServer.request(path='/user', method='POST', params={
        'email': '[email protected]',
        'login': 'uploader-user',
        'firstName': 'uploader',
        'lastName': 'user',
        'password': 'password'
    })
    assertStatusOk(resp)
    uploaderUser = User().findOne({'login': 'uploader-user'})
    assert uploaderUser is not None

    # TODO: check if a user can upload without agreeing to terms

    # Ensure request create dataset permission works
    resp = provisionedServer.request(path='/user/requestCreateDatasetPermission',
                                     method='POST', user=uploaderUser)
    assertStatusOk(resp)
    assert smtp.waitForMail()
    assert smtp.getMail()  # pop off the queue for later assertion that the queue is empty

    # Ensure that the user can't create datasets yet
    resp = provisionedServer.request(path='/user/me', method='GET', user=uploaderUser)
    assertStatusOk(resp)
    assert not resp.json['permissions']['createDataset']

    # Ensure that a join request is pending
    contributorsGroup = Group().findOne({'name': 'Dataset Contributors'})
    joinRequestUserIds = [user['id'] for user in Group().getFullRequestList(contributorsGroup)]
    assert uploaderUser['_id'] in joinRequestUserIds
    assert smtp.isMailQueueEmpty()

    # Add the user, then ensure they can create datasets
    Group().inviteUser(contributorsGroup, uploaderUser, level=AccessType.READ)
    resp = provisionedServer.request(path='/user/me', method='GET', user=uploaderUser)
    assertStatusOk(resp)
    assert resp.json['permissions']['createDataset']
开发者ID:ImageMarkup,项目名称:isic-archive,代码行数:53,代码来源:user_test.py


示例15: testMoveFolderToNewCollection

def testMoveFolderToNewCollection(server, admin, hierarchy):
    assertNodeSize(hierarchy.collections[0], Collection, 11)
    assertNodeSize(hierarchy.collections[1], Collection, 0)

    resp = server.request(
        path='/folder/%s' % hierarchy.folders[0]['_id'], method='PUT',
        user=admin, params={
            'parentId': hierarchy.collections[1]['_id'],
            'parentType': 'collection'
        })
    assertStatusOk(resp)
    assertNodeSize(hierarchy.collections[0], Collection, 0)
    assertNodeSize(hierarchy.collections[1], Collection, 11)
开发者ID:girder,项目名称:girder,代码行数:13,代码来源:test_size.py


示例16: testListScopes

def testListScopes(server):
    resp = server.request('/token/scopes')
    assertStatusOk(resp)
    assert resp.json == TokenScope.listScopes()

    assert 'custom' in resp.json
    assert isinstance(resp.json['custom'], list)
    assert 'adminCustom' in resp.json
    assert isinstance(resp.json['adminCustom'], list)

    for scope in resp.json['custom'] + resp.json['adminCustom']:
        assert 'id' in scope
        assert 'name' in scope
        assert 'description' in scope
开发者ID:data-exp-lab,项目名称:girder,代码行数:14,代码来源:test_api_key.py


示例17: testApiDocsCustomContent

def testApiDocsCustomContent(server):
    """
    Test content of API documentation page that's customized by a plugin.
    """
    resp = server.request(path='/api/v1', method='GET', isJson=False, prefix='')
    assertStatusOk(resp)
    body = getResponseBody(resp)

    assert 'Girder REST API Documentation' not in body
    assert 'This is not a sandbox' not in body

    assert 'Girder Web Application Programming Interface' in body
    assert '<p>Custom API description</p>' in body
    assert 'id="swagger-ui-container"' in body
开发者ID:girder,项目名称:girder,代码行数:14,代码来源:test_api_docs.py


示例18: testTokenCreatesUniqueTokens

def testTokenCreatesUniqueTokens(server, user, apiKey):
    for _ in range(0, 2):
        resp = server.request('/api_key/token', method='POST', params={
            'key': apiKey['key']
        })
        assertStatusOk(resp)

    # We should have two tokens for this key
    q = {
        'userId': user['_id'],
        'apiKeyId': apiKey['_id']
    }
    count = Token().find(q).count()
    assert count == 2
开发者ID:data-exp-lab,项目名称:girder,代码行数:14,代码来源:test_api_key.py


示例19: testInactiveKeyStructure

def testInactiveKeyStructure(server, user, apiKey):
    newScopes = [TokenScope.DATA_READ, TokenScope.DATA_WRITE]
    resp = server.request('/api_key/%s' % apiKey['_id'], params={
        'active': False,
        'tokenDuration': 10,
        'scope': json.dumps(newScopes)
    }, method='PUT', user=user)
    assertStatusOk(resp)

    # Make sure key itself didn't change
    assert resp.json['key'] == apiKey['key']
    apiKey = ApiKey().load(resp.json['_id'], force=True)
    assert not apiKey['active']
    assert apiKey['tokenDuration'] == 10
    assert set(apiKey['scope']) == set(newScopes)
开发者ID:data-exp-lab,项目名称:girder,代码行数:15,代码来源:test_api_key.py


示例20: testInactiveKeysCannotCreateTokens

def testInactiveKeysCannotCreateTokens(server, user, apiKey):
    newScopes = [TokenScope.DATA_READ, TokenScope.DATA_WRITE]
    resp = server.request('/api_key/%s' % apiKey['_id'], params={
        'active': False,
        'tokenDuration': 10,
        'scope': json.dumps(newScopes)
    }, method='PUT', user=user)
    assertStatusOk(resp)

    # We should not be able to create tokens for this key anymore
    resp = server.request('/api_key/token', method='POST', params={
        'key': apiKey['key']
    })
    assertStatus(resp, 400)
    assert resp.json['message'] == 'Invalid API key.'
开发者ID:data-exp-lab,项目名称:girder,代码行数:15,代码来源:test_api_key.py



注:本文中的pytest_girder.assertions.assertStatusOk函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.UserFactory类代码示例发布时间:2022-05-27
下一篇:
Python pytest_bdd.scenarios函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap