本文整理汇总了Python中twill.commands.go函数的典型用法代码示例。如果您正苦于以下问题:Python go函数的具体用法?Python go怎么用?Python go使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了go函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_project_manager_sharing
def test_project_manager_sharing(self):
# test sharing as a manager
# main page
tc.go( testlib.PROJECT_LIST_URL )
tc.find("Logged in as")
# default project list
tc.find("Yeast mutant RAV 17")
tc.follow("Yeast mutant RAV 17")
tc.follow("Sharing")
tc.find("Current members")
tc.find("Add access")
# search for then add Demo User to this project
tc.fv("1", "text", "demo" )
tc.submit()
tc.code(200)
tc.find("Demo User")
tc.follow("add as member")
tc.find("Demo User")
# back to the project view
tc.follow("<< return to project")
tc.find("Yeast mutant RAV 17")
示例2: logout
def logout(self):
"Performs a logout"
tc.go( testlib.PROJECT_LIST_URL )
tc.code(200)
tc.go("/logout/")
tc.code(200)
tc.find("You are not logged in")
示例3: test_project_actions
def test_project_actions(self):
# main page
tc.go( testlib.PROJECT_LIST_URL )
tc.find("Logged in as")
# default project list
tc.find("Fly data 19")
tc.find("Human HELA 16")
tc.find("Mouse project HBB 1")
# create a new project
name = "Rainbow Connection - New Project"
self.create_project(name=name)
# visit this new project
tc.follow(name)
tc.code(200)
tc.find("Project: %s" % name)
# edit and rename project
newname = "Iguana Garden - New Project"
tc.follow("Edit")
tc.find("Edit Project")
tc.fv("1", "name", newname )
tc.fv("1", "info", "Some other *markup* goes here")
tc.submit()
tc.code(200)
tc.notfind(name)
tc.find(newname)
self.delete_project(name=newname)
示例4: test_confirm_password_reset
def test_confirm_password_reset(self):
"""
create confirmation link as Django engine and
test it for resetting password
"""
test_email = '[email protected]'
go(SITE)
code(200)
follow('reset password')
code(200)
fv(2, 'email', test_email)
submit()
code(200)
#create links
from django.contrib.auth.tokens import default_token_generator
from django.utils.http import int_to_base36
users = User.objects.filter(email__iexact=test_email)
for user in users:
link = "%s/accounts/password/reset_confirm/%s/%s/" % (SITE,
int_to_base36(user.id),
default_token_generator.make_token(user))
go(link)
code(200)
find('Password reset confirm')
fv(2, 'new_password1', 'test')
fv(2, 'new_password2', 'test')
submit()
code(200)
find('Your password was successfully reseted')
self.general_login_action(user.username,
'test',
"Welcome, %s" % user.username)
示例5: test_login_auth
def test_login_auth(self):
""" test login page """
self.general_login_action('user1', 'password1', 'Welcome, user1')
go("%s/accounts/login/" % SITE)
code(200)
url('/accounts/profile/')
find('Welcome, user1')
示例6: test_profile
def test_profile():
"""
Test user profile
"""
go(SITE + '/accounts/profile/')
code(404)
return
示例7: main
def main():
login, password = get_credentials()
# log-in to Django site
if login and password:
tw.go(LOGIN_URL)
tw.formvalue('1', 'username', login)
tw.formvalue('1', 'password', password)
tw.submit()
if isinstance(DATA_URL, basestring):
urls = [DATA_URL]
else:
urls = list(DATA_URL)
# retrieve URIs
for url in urls:
try:
tw.go(url)
tw.code('200')
tw.show()
except TwillAssertionError:
code = get_browser().get_code()
print (u"Unable to access %(url)s. "
u"Received HTTP #%(code)s."
% {'url': url, 'code': code})
tw.reset_browser()
示例8: minitwill
def minitwill(url, script):
'''Dada una URL y un script en una versión limitada
de twill, ejecuta ese script.
Apenas una línea falla, devuelve False.
Si todas tienen éxito, devuelve True.
Ejemplos:
>>> minitwill('http://google.com','code 200')
==> at http://www.google.com.ar/
True
>>> minitwill('http://google.com','title bing')
==> at http://www.google.com.ar/
title is 'Google'.
False
'''
try:
go(url)
except:
return False
for line in script.splitlines():
cmd, arg = line.split(' ', 1)
try:
if cmd in ['code', 'find', 'notfind', 'title']:
# Si line es "code 200", esto es el equivalente
# de code(200)
r = globals()[cmd](arg)
except:
return False
return True
示例9: test_BeautifulSoup
def test_BeautifulSoup():
"""
test parsing of BS-processed HTML.
"""
b = commands.get_browser()
commands.config('use_tidy', '0')
commands.config('use_BeautifulSoup', '1')
commands.config('allow_parse_errors', '0')
commands.go(url)
###
# Apparently, mechanize is more tolerant than it used to be.
# commands.go('/tidy_fixable_html')
# forms = [ i for i in b._browser.forms() ]
# assert len(forms) == 0, \
# "there should be no correct forms on this page"
###
commands.go('/BS_fixable_html')
forms = [ i for i in b._browser.forms() ]
assert len(forms) == 1, \
"there should be one mangled form on this page"
示例10: login
def login():
if s218:
page = 'http://129.21.142.218:8008/securesync/login/'
username = 'JSteacher'
password = 'poipoi99'
facility = '0939bcf9d5fe59ff8fde46b5a729a232'
else:
page = 'http://129.21.142.118:8008/securesync/login/'
username = 'knowledgecraft'
password = 'knowledgecraft'
facility = 'dbae7005f9b45ce082b5fe0a0985946a'
print 'Logging In...'
go(page)
print "Forms:"
showforms()
try:
# Force try using the first form found on a page.
formclear('2')
fv("2", "username", username)
fv("2", "password", password)
fv("2", "facility", facility)
#fv("1", "csrfmiddlewaretoken", '3F1bMuIIM9ERzcp6ceEyFxlT51yJKsK6')
submit('0')
content = showSilently()
print 'debug twill post content:', content
except urllib2.HTTPError, e:
sys.exit("%d: %s" % (e.code, e.msg))
示例11: login
def login(username, password):
t.add_extra_header("User-Agent", "[email protected].com")
t.go(host + "index.php/Special:UserLogin")
t.fv("1", "wpName", username)
t.fv("1", "wpPassword", password)
t.submit("wpLoginAttempt")
示例12: get_xml_history
def get_xml_history(self):
"""Returns a parsed xml object corresponding to the history"""
self.home()
tc.go('./history?template=history.xml' )
xml = self.last_page()
tree = ElementTree.fromstring(xml)
return tree
示例13: minitwill
def minitwill(url, script):
"""Dada una URL y un script en una versión limitada
de twill, ejecuta ese script.
Apenas una línea falla, devuelve False.
Si todas tienen éxito, devuelve True.
Ejemplos:
>>> minitwill('http://google.com','code 200')
==> at http://www.google.com.ar/
True
>>> minitwill('http://google.com','title bing')
==> at http://www.google.com.ar/
title is 'Google'.
False
"""
go(url)
for line in script.splitlines():
cmd, arg = line.split(" ", 1)
try:
if cmd in ["code", "find", "notfind", "title"]:
r = globals()[cmd](arg)
except:
return False
return True
示例14: setup
def setup(
self,
login=None,
password=None,
service_url="https://bramka.play.pl",
login_url="https://logowanie.play.pl/p4-idp2/LoginForm.do",
logout_url="https://logowanie.play.pl/p4-idp2/LogoutUser",
):
self.SERVICE_URL = service_url
self.LOGIN_URL = login_url
self.LOGOUT_URL = logout_url
self.MY_PHONE_NUMBER = login
self.MY_PASSWORD = password
web.config("readonly_controls_writeable", True)
web.agent(self.MY_HTTP_AGENT)
web.go(self.SERVICE_URL)
web.submit()
web.code(200)
web.formvalue("loginForm", "login", self.MY_PHONE_NUMBER)
web.formvalue("loginForm", "password", self.MY_PASSWORD)
web.submit()
web.code(200)
self._retry_find("editableSmsComposeForm", 5)
示例15: visit_loginurl
def visit_loginurl (aggregate):
"""Check for a login URL and visit it."""
config = aggregate.config
url = config["loginurl"]
if not url:
return
if not fileutil.has_module("twill"):
msg = strformat.format_feature_warning(module=u'twill',
feature=u'login URL visit',
url=u'http://twill.idyll.org/')
log.warn(LOG_CHECK, msg)
return
from twill import commands as tc
log.debug(LOG_CHECK, u"Visiting login URL %s", url)
configure_twill(tc)
tc.go(url)
if tc.get_browser().get_code() != 200:
log.warn(LOG_CHECK, _("Error visiting login URL %(url)s.") % \
{"url": url})
return
submit_login_form(config, url, tc)
if tc.get_browser().get_code() != 200:
log.warn(LOG_CHECK, _("Error posting form at login URL %(url)s.") % \
{"url": url})
return
#XXX store_cookies(tc.get_browser().cj, aggregate.cookies, url)
resulturl = tc.get_browser().get_url()
log.debug(LOG_CHECK, u"URL after POST is %s" % resulturl)
# add result URL to check list
from ..checker import get_url_from
aggregate.urlqueue.put(get_url_from(resulturl, 0, aggregate))