本文整理汇总了Python中bespin.tests.BespinTestApp类的典型用法代码示例。如果您正苦于以下问题:Python BespinTestApp类的具体用法?Python BespinTestApp怎么用?Python BespinTestApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BespinTestApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_login_yields_401
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)
示例2: test_login_without_cookie
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']
示例3: test_bad_ticket_is_ignored
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)
示例4: test_static_files_with_auth
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')
示例5: test_userinfo_also_returns_capabilities
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
示例6: test_server_capabilities
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=[])
示例7: test_username_with_bad_characters
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)
示例8: test_register_existing_user_should_not_authenticate
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
示例9: test_get_users_settings
def test_get_users_settings():
_clear_db()
app = controllers.make_app()
app = BespinTestApp(app)
resp = app.post("/register/new/macgyver",
dict(password="foo", email="[email protected]"))
resp = app.put("/file/at/BespinSettings/settings", """
vcsuser Mack Gyver <[email protected]>
""")
s = _get_session()
macgyver = User.find_user("macgyver")
settings = macgyver.get_settings()
assert settings == dict(vcsuser="Mack Gyver <[email protected]>")
示例10: test_password_change_bad_code
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)
示例11: test_lost_username
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]
示例12: test_register_and_verify_user
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")
示例13: test_users_can_be_locked_out
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)
示例14: test_password_change_with_confirmation_code
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
示例15: test_lost_password_request
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]