当前位置: 首页>>代码示例>>Python>>正文


Python data.add_fixtures函数代码示例

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


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

示例1: test_comments

def test_comments(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment1 = flight_comments.yeah(flight=flight)
    comment2 = flight_comments.emoji(flight=flight)
    comment3 = flight_comments.yeah(
        flight=flight, user=flight.igc_file.owner, text=u"foo"
    )
    comment4 = flight_comments.yeah(flight=flight, text=u"bar")
    comment5 = flight_comments.yeah(flight=flight, user=users.jane(), text=u"baz")
    add_fixtures(db_session, flight, comment1, comment2, comment3, comment4, comment5)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {
        u"flight": expected_basic_flight_json(flight),
        u"near_flights": [],
        u"comments": [
            {u"user": None, u"text": u"Yeah!"},
            {u"user": None, u"text": u"\U0001f44d"},
            {u"user": {u"id": comment3.user.id, u"name": u"John Doe"}, u"text": u"foo"},
            {u"user": None, u"text": u"bar"},
            {u"user": {u"id": comment5.user.id, u"name": u"Jane Doe"}, u"text": u"baz"},
        ],
        u"contest_legs": {u"classic": [], u"triangle": []},
        u"phases": [],
        u"performance": {u"circling": [], u"cruise": {}},
    }
开发者ID:skylines-project,项目名称:skylines,代码行数:27,代码来源:read_test.py

示例2: test_unauthenticated

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

    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), json={
        u'text': u'foobar',
    })
    assert res.status_code == 401
    assert res.json == {
        u'error': u'invalid_token',
        u'message': u'Bearer token not found.',
    }

    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!',
    }]
开发者ID:GliderGeek,项目名称:skylines,代码行数:27,代码来源:create_comment_test.py

示例3: 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

示例4: test_basic_flight

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

    res = client.get("/flights/{id}".format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {u"flight": expected_basic_flight_json(flight)}
开发者ID:skylines-project,项目名称:skylines,代码行数:7,代码来源:read_test.py

示例5: test_search

def test_search(db_session, client):
    edka = airports.merzbrueck()
    lva = clubs.lva()

    add_fixtures(
        db_session,
        users.john(),
        users.jane(),
        lva,
        clubs.sfn(),
        edka,
        airports.meiersberg(),
    )

    res = client.get("/search?text=aachen")
    assert res.status_code == 200
    assert res.json == {
        "results": [
            {
                "id": edka.id,
                "type": "airport",
                "name": "Aachen Merzbruck",
                "icao": "EDKA",
                "frequency": "122.875",
            },
            {
                "id": lva.id,
                "type": "club",
                "name": "LV Aachen",
                "website": "http://www.lv-aachen.de",
            },
        ]
    }
开发者ID:skylines-project,项目名称:skylines,代码行数:33,代码来源:search_test.py

示例6: 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

示例7: test_unauthenticated_access_on_link_only_flight

def test_unauthenticated_access_on_link_only_flight(db_session, client):
    flight = flights.one(privacy_level=Flight.PrivacyLevel.LINK_ONLY,
                         igc_file=igcs.simple(owner=users.john()))
    add_fixtures(db_session, flight)

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

示例8: 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

示例9: 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

示例10: 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

示例11: test_unauthenticated_access_on_private_flight

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

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

示例12: 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

示例13: 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

示例14: 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

示例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


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