本文整理汇总了Python中bespin.tests.BespinTestApp.post方法的典型用法代码示例。如果您正苦于以下问题:Python BespinTestApp.post方法的具体用法?Python BespinTestApp.post怎么用?Python BespinTestApp.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bespin.tests.BespinTestApp
的用法示例。
在下文中一共展示了BespinTestApp.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_register_and_verify_user
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_register_and_verify_user():
config.activate_profile()
_clear_db()
s = _get_session()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
assert resp.content_type == "application/json"
data = simplejson.loads(resp.body)
assert data == {}
assert resp.cookies_set['auth_tkt']
assert app.cookies
billbixby = User.find_user("BillBixby")
sample_project = get_project(billbixby, billbixby, "SampleProject")
files = [file.name for file in sample_project.list_files()]
assert "readme.txt" in files
# should be able to run again without an exception appearing
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"),
status=409)
# with the cookie set, we should be able to retrieve the
# logged in name
resp = app.get('/register/userinfo/')
assert resp.content_type == 'application/json'
data = simplejson.loads(resp.body)
assert data['username'] == 'BillBixby'
assert 'quota' in data
assert data['quota'] == 15728640
assert 'amountUsed' in data
resp = app.get("/file/at/BespinSettings/config")
app.post("/file/close/BespinSettings/config")
示例2: test_username_with_bad_characters
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_username_with_bad_characters():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/Thinga%20Majig",
dict(password="foo", email="[email protected]"), status=400)
resp = app.post("/register/new/Thinga<majig>",
dict(password="foo", email="[email protected]"), status=400)
resp = app.post("/register/new/Thing/",
dict(password="foo", email="[email protected]"), status=400)
resp = app.post("/register/new/..",
dict(password="foo", email="[email protected]"), status=400)
示例3: test_register_existing_user_should_not_authenticate
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_register_existing_user_should_not_authenticate():
s = _get_session(True)
app_orig = controllers.make_app()
app = BespinTestApp(app_orig)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
app = BespinTestApp(app_orig)
resp = app.post("/register/new/BillBixby", dict(email="[email protected]",
password="somethingelse"),
status=409)
assert not resp.cookies_set
user = User.find_user("BillBixby", 'notangry')
assert user is not None
示例4: test_password_change_bad_code
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_password_change_bad_code():
config.set_profile("test")
config.activate_profile()
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
app.reset()
resp = app.post('/register/password/BillBixby', dict(
code="42",
newPassword="hatetraffic"),
status=400)
示例5: test_bad_login_yields_401
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_bad_login_yields_401():
s = _get_session(True)
User.create_user("BillBixby", "hulkrulez", "[email protected]")
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/login/BillBixby",
dict(password="NOTHULK"), status=401)
示例6: test_lost_username
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_lost_username(send_text_email):
config.set_profile("test")
config.activate_profile()
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
resp = app.post('/register/lost/', dict(email='[email protected]'))
assert send_text_email.called
args = send_text_email.call_args[0]
assert args[0] == '[email protected]'
assert args[1].startswith("Your username for ")
assert "Your username is:" in args[2]
assert "BillBixby" in args[2]
示例7: test_bad_ticket_is_ignored
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_bad_ticket_is_ignored():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/Aldus", dict(password="foo",
email="[email protected]"))
app.cookies['auth_tkt'] = app.cookies['auth_tkt'][:-1]
resp = app.get("/preview/at/SampleProjectFor%3AAldus/index.html", status=401)
示例8: test_login_without_cookie
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_login_without_cookie():
s = _get_session(True)
User.create_user("BillBixby", "hulkrulez", "[email protected]")
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/login/BillBixby",
dict(password="hulkrulez"))
assert resp.cookies_set['auth_tkt']
示例9: test_userinfo_also_returns_capabilities
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_userinfo_also_returns_capabilities():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/BillBixby", dict(email="[email protected]", password="notangry"))
resp = app.get("/register/userinfo/")
data = simplejson.loads(resp.body)
print data
assert "serverCapabilities" in data
示例10: test_users_can_be_locked_out
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_users_can_be_locked_out():
config.set_profile("test")
config.c.login_failure_tracking = "memory"
config.c.login_attempts = "1"
config.c.lockout_period = "1"
config.activate_profile()
app = controllers.make_app()
app = BespinTestApp(app)
_clear_db()
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
resp = app.post("/register/login/BillBixby",
dict(password="NOTHULK"), status=401)
# fail with good password now, because we're locked out
resp = app.post("/register/login/BillBixby",
dict(password="notangry"), status=401)
示例11: test_static_files_with_auth
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_static_files_with_auth():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.get('/editor.html', status=302)
assert resp.location == "http://localhost/"
resp = app.post('/register/new/Aldus', dict(password="foo",
email="[email protected]"))
resp = app.get('/editor.html')
示例12: test_server_capabilities
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_server_capabilities():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/BillBixby", dict(email="[email protected]", password="notangry"))
resp = app.get("/capabilities/")
assert resp.content_type == "application/json"
data = simplejson.loads(resp.body)
print data
assert data == dict(capabilities=["vcs"], dojoModulePath={}, javaScriptPlugins=[])
示例13: test_password_change_with_confirmation_code
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_password_change_with_confirmation_code():
config.set_profile("test")
config.activate_profile()
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
app.reset()
user = User.find_user("BillBixby")
verify_code = controllers._get_password_verify_code(user)
resp = app.post('/register/password/BillBixby', dict(
code=verify_code,
newPassword="hatetraffic"))
user = User.find_user('BillBixby', 'hatetraffic')
assert user
示例14: test_lost_password_request
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_lost_password_request(send_text_email):
config.set_profile("test")
config.activate_profile()
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
password="notangry"))
app.reset()
resp = app.post('/register/lost/', dict(username='BillBixby'))
assert send_text_email.called
args = send_text_email.call_args[0]
assert args[0] == '[email protected]'
assert args[1].startswith("Requested password change for ")
user = User.find_user("BillBixby")
verify_code = controllers._get_password_verify_code(user)
assert verify_code in args[2]
示例15: test_messages_sent_from_server_to_user
# 需要导入模块: from bespin.tests import BespinTestApp [as 别名]
# 或者: from bespin.tests.BespinTestApp import post [as 别名]
def test_messages_sent_from_server_to_user():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/macgyver",
dict(password="foo", email="[email protected]"))
s = _get_session()
macgyver = User.find_user("macgyver")
assert len(macgyver.messages) == 0
macgyver.publish(dict(my="message"))
s.commit()
resp = app.post("/messages/")
assert resp.content_type == "application/json"
data = simplejson.loads(resp.body)
assert len(data) == 1
assert data[0] == dict(my="message")
# the message should be consumed
resp = app.post("/messages/")
data = simplejson.loads(resp.body)
assert len(data) == 0