本文整理汇总了Python中tests.data.users.john函数的典型用法代码示例。如果您正苦于以下问题:Python john函数的具体用法?Python john怎么用?Python john使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了john函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: test_paging
def test_paging(db_session, client):
john = users.john()
for _ in range(75):
event = events.new_user(actor=john)
db_session.add(event)
db_session.commit()
res = client.get("/timeline")
assert res.status_code == 200
assert len(res.json["events"]) == 50
res = client.get("/timeline?page=2")
assert res.status_code == 200
assert len(res.json["events"]) == 25
res = client.get("/timeline?page=3")
assert res.status_code == 200
assert len(res.json["events"]) == 0
res = client.get("/timeline?per_page=40")
assert res.status_code == 200
assert len(res.json["events"]) == 40
res = client.get("/timeline?per_page=40&page=2")
assert res.status_code == 200
assert len(res.json["events"]) == 35
开发者ID:skylines-project,项目名称:skylines,代码行数:27,代码来源:list_test.py
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: test_repr_is_str
def test_repr_is_str(db_session):
john = users.john(last_name=u'Müller')
db_session.add(john)
db_session.commit()
assert isinstance(repr(john), str)
assert repr(john) == '<User: [email protected], display=John Müller>'
开发者ID:Turbo87,项目名称:skylines,代码行数:7,代码来源:test_user.py
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例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_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
示例16: 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
示例17: test_list_users
def test_list_users(db_session, client):
john = users.john()
add_fixtures(db_session, john)
res = client.get("/users/")
assert res.status_code == 200
assert res.json == {
u"users": [{u"id": john.id, u"name": u"John Doe", u"club": None}]
}
开发者ID:skylines-project,项目名称:skylines,代码行数:9,代码来源:list_test.py
示例18: 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
示例19: 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
示例20: test_search_with_umlauts
def test_search_with_umlauts(db_session, client):
john = users.john(last_name=u"Müller")
add_fixtures(db_session, john)
res = client.get(u"/search?text=M%C3%BCll")
assert res.status_code == 200
assert res.json == {
"results": [{"id": john.id, "type": "user", "name": u"John Müller"}]
}
开发者ID:skylines-project,项目名称:skylines,代码行数:10,代码来源:search_test.py
注:本文中的tests.data.users.john函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论