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

Python api.auth_for函数代码示例

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

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



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

示例1: test_delete_user_invalidates_auth_tokens

def test_delete_user_invalidates_auth_tokens(client, test_user, test_admin):
    res = client.get('/settings'.format(id=test_user.id), headers=auth_for(test_user))
    assert res.status_code == 200

    res = client.delete('/users/{id}'.format(id=test_user.id), headers=auth_for(test_admin))
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/settings'.format(id=test_user.id), headers=auth_for(test_user))
    assert res.status_code == 401
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:10,代码来源:delete_test.py


示例2: test_delete_account_invalidates_auth_tokens

def test_delete_account_invalidates_auth_tokens(client, test_user):
    res = client.get('/settings'.format(id=test_user.id), headers=auth_for(test_user))
    assert res.status_code == 200

    res = client.delete('/account', headers=auth_for(test_user), json={
        'password': test_user.original_password,
    })
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/settings'.format(id=test_user.id), headers=auth_for(test_user))
    assert res.status_code == 401
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:12,代码来源:delete_test.py


示例3: test_existing_club

def test_existing_club(db_session, client, test_user):
    lva = clubs.lva()
    add_fixtures(db_session, lva)

    res = client.put("/clubs", headers=auth_for(test_user), json={"name": "LV Aachen"})
    assert res.status_code == 422
    assert res.json["error"] == "duplicate-club-name"
开发者ID:skylines-project,项目名称:skylines,代码行数:7,代码来源:create_test.py


示例4: test_missing

def test_missing(db_session, client, test_user):
    res = client.post(
        "/clubs/1000000000",
        headers=auth_for(test_user),
        json={"name": "foobar", "website": "https://foobar.de"},
    )
    assert res.status_code == 404
开发者ID:skylines-project,项目名称:skylines,代码行数:7,代码来源:update_test.py


示例5: test_delete_user_as_other_user

def test_delete_user_as_other_user(db_session, client, test_user):
    john = users.john()
    db_session.add(john)
    db_session.commit()

    res = client.delete('/users/{id}'.format(id=test_user.id), headers=auth_for(john))
    assert res.status_code == 403
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:7,代码来源:delete_test.py


示例6: test_clear_all

def test_clear_all(db_session, client):
    john = users.john()
    jane = users.jane()
    max = users.max()

    create_follower_notification(john, jane)
    create_follower_notification(john, max)
    create_follower_notification(jane, max)

    db_session.commit()

    res = client.post("/notifications/clear", headers=auth_for(john))
    assert res.status_code == 200
    assert res.json == {}

    johns_notifications = db_session.query(Notification).filter_by(recipient=john).all()
    assert len(johns_notifications) == 2
    assert johns_notifications[0].event.actor_id == jane.id
    assert johns_notifications[0].time_read is not None
    assert johns_notifications[1].event.actor_id == max.id
    assert johns_notifications[1].time_read is not None

    janes_notifications = db_session.query(Notification).filter_by(recipient=jane).all()
    assert len(janes_notifications) == 1
    assert janes_notifications[0].event.actor_id == max.id
    assert janes_notifications[0].time_read is None
开发者ID:skylines-project,项目名称:skylines,代码行数:26,代码来源:clear_test.py


示例7: test_create

def test_create(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment, john)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]

    res = client.post('/flights/{id}/comments'.format(id=flight.id), headers=auth_for(john), json={
        u'text': u'foobar',
    })
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }, {
        u'user': {
            u'id': john.id,
            u'name': u'John Doe',
        },
        u'text': u'foobar',
    }]
开发者ID:GliderGeek,项目名称:skylines,代码行数:31,代码来源:create_comment_test.py


示例8: test_create

def test_create(db_session, client, test_user):
    res = client.put("/clubs", headers=auth_for(test_user), json={"name": "LV Aachen"})
    assert res.status_code == 200

    club = Club.get(res.json["id"])
    assert club
    assert club.owner_id == test_user.id
开发者ID:skylines-project,项目名称:skylines,代码行数:7,代码来源:create_test.py


示例9: test_non_json_data

def test_non_json_data(db_session, client, test_user):
    sfn = clubs.sfn()
    test_user.club = sfn
    add_fixtures(db_session, sfn)

    res = client.post('/clubs/{id}'.format(id=sfn.id), headers=auth_for(test_user), data='foobar?')
    assert res.status_code == 400
    assert res.json['error'] == 'invalid-request'
开发者ID:GliderGeek,项目名称:skylines,代码行数:8,代码来源:update_test.py


示例10: test_invalid_data

def test_invalid_data(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    add_fixtures(db_session, flight, john)

    res = client.post('/flights/{id}/comments'.format(id=flight.id), headers=auth_for(john), data='foobar?')
    assert res.status_code == 400
    assert res.json == {u'error': u'invalid-request'}
开发者ID:GliderGeek,项目名称:skylines,代码行数:8,代码来源:create_comment_test.py


示例11: test_invalid_json

def test_invalid_json(db_session, client):
    john = users.john()
    add_fixtures(db_session, john)

    res = client.post(
        "/settings/password/check", headers=auth_for(john), data="foobar?"
    )
    assert res.status_code == 400
开发者ID:skylines-project,项目名称:skylines,代码行数:8,代码来源:password_check_test.py


示例12: test_basic_flight_json

def test_basic_flight_json(db_session, client):
    # add user
    john = users.john()
    db_session.add(john)
    db_session.commit()

    # upload flight
    data = dict(files=(igcs.simple_path,))
    res = client.post("/flights/upload", headers=auth_for(john), data=data)
    assert res.status_code == 200
    flight_id = res.json["results"][0]["flight"]["id"]

    res = client.get("/flights/{id}/json".format(id=flight_id), headers=auth_for(john))
    assert res.status_code == 200
    assert res.json == S(
        {
            u"additional": {
                u"competition_id": None,
                u"model": None,
                u"registration": u"LY-KDR",
            },
            u"barogram_h": u"[email protected]@U}@[email protected]@[email protected][KIKKKI[][email protected]@[email protected]",
            u"barogram_t": u"ik_A{B{@[email protected]]S]]IIIIMIIISIIISIIIIIIIIIIII",
            u"contests": Unordered(
                [
                    {
                        u"name": u"olc_plus triangle",
                        u"times": u"{y_AgBeAyAS",
                        u"turnpoints": u"[email protected]{[email protected]}[email protected]@|[email protected]{AnEgJ",
                    },
                    {
                        u"name": u"olc_plus classic",
                        u"times": u"[email protected]][email protected]@",
                        u"turnpoints": u"ypokI{[email protected]]g^[email protected][d{AtTwI",
                    },
                ]
            ),
            u"elevations_h": u"",
            u"elevations_t": u"",
            u"enl": u"",
            u"geoid": Approx(25.15502072293512),
            u"points": u"syokIm|owC????lYxKbQrIrGlBlPjH|N`Kn[l[tRjZ~LrPpRz^tP|`@lFnHrG`[email protected]`@[email protected]@fQ`[email protected]@`CsAlAsG",
            u"sfid": int,
        }
    )
开发者ID:skylines-project,项目名称:skylines,代码行数:45,代码来源:read_test.py


示例13: test_missing_flight

def test_missing_flight(db_session, client):
    john = users.john()
    add_fixtures(db_session, john)

    res = client.post('/flights/{id}/comments'.format(id=1000000), headers=auth_for(john), json={
        u'text': u'foobar',
    })
    assert res.status_code == 404
    assert res.json == {u'message': u'Sorry, there is no such record (1000000) in our database.'}
开发者ID:GliderGeek,项目名称:skylines,代码行数:9,代码来源:create_comment_test.py


示例14: test_correct_password

def test_correct_password(db_session, client):
    john = users.john()
    add_fixtures(db_session, john)

    res = client.post('/settings/password/check', headers=auth_for(john), json={
        'password': john.original_password,
    })
    assert res.status_code == 200
    assert res.json == {'result': True}
开发者ID:GliderGeek,项目名称:skylines,代码行数:9,代码来源:password_check_test.py


示例15: test_igc_owner_access_on_private_flight

def test_igc_owner_access_on_private_flight(db_session, client):
    john = users.john()
    flight = flights.one(pilot=None, privacy_level=Flight.PrivacyLevel.PRIVATE,
                         igc_file=igcs.simple(owner=john))
    add_fixtures(db_session, flight, john)

    res = client.get('/flights/{id}'.format(id=flight.id), headers=auth_for(john))
    assert res.status_code == 200
    assert 'flight' in res.json
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:9,代码来源:read_test.py


示例16: test_existing_club

def test_existing_club(db_session, client, test_user):
    lva = clubs.lva()
    add_fixtures(db_session, lva)

    res = client.put('/clubs', headers=auth_for(test_user), json={
        'name': 'LV Aachen',
    })
    assert res.status_code == 422
    assert res.json['error'] == 'duplicate-club-name'
开发者ID:GliderGeek,项目名称:skylines,代码行数:9,代码来源:create_test.py


示例17: test_create

def test_create(db_session, client, test_user):
    res = client.put('/clubs', headers=auth_for(test_user), json={
        'name': 'LV Aachen',
    })
    assert res.status_code == 200

    club = Club.get(res.json['id'])
    assert club
    assert club.owner_id == test_user.id
开发者ID:GliderGeek,项目名称:skylines,代码行数:9,代码来源:create_test.py


示例18: test_manager_access_on_private_flight

def test_manager_access_on_private_flight(db_session, client):
    jane = users.jane(admin=True)
    flight = flights.one(privacy_level=Flight.PrivacyLevel.PRIVATE,
                         igc_file=igcs.simple(owner=users.john()))
    add_fixtures(db_session, flight, jane)

    res = client.get('/flights/{id}'.format(id=flight.id), headers=auth_for(jane))
    assert res.status_code == 200
    assert 'flight' in res.json
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:9,代码来源:read_test.py


示例19: test_incorrect_password

def test_incorrect_password(db_session, client):
    john = users.john()
    add_fixtures(db_session, john)

    res = client.post(
        "/settings/password/check", headers=auth_for(john), json={"password": "foobar"}
    )
    assert res.status_code == 200
    assert res.json == {"result": False}
开发者ID:skylines-project,项目名称:skylines,代码行数:9,代码来源:password_check_test.py


示例20: test_delete_user_as_admin

def test_delete_user_as_admin(client, test_user, test_admin):
    res = client.get('/users/{id}'.format(id=test_user.id))
    assert res.status_code == 200

    res = client.delete('/users/{id}'.format(id=test_user.id), headers=auth_for(test_admin))
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/users/{id}'.format(id=test_user.id))
    assert res.status_code == 404
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:10,代码来源:delete_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python api_client.get_data函数代码示例发布时间:2022-05-27
下一篇:
Python test_helpers.TestHelpers类代码示例发布时间: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