def send(self, msg, *send_to): """ @todo: make use of native vodafone multi-recipients functionality """ for contact in send_to: web.follow(self.SERVICE_URL) try: web.find("/myv/messaging/webtext/Challenge.shtml") except twill.errors.TwillAssertionError, e: pass else: web.go("/myv/messaging/webtext/Challenge.shtml") with tempfile.NamedTemporaryFile(suffix=".jpeg") as captcha: web.save_html(captcha.name) web.back() os.system("open %s " % captcha.name) web.formvalue("WebText", "jcaptcha_response", raw_input("Captcha: ")) web.formvalue("WebText", "message", msg) to = getattr(contact, "mobile", contact) web.formvalue("WebText", "recipient_0", to) web.sleep(2) web.submit() web.code(200) web.find("Message sent!")
def test_data_uploads(self): # data upload test name = 'Upload-test-name' self.create_project(name) tc.follow(name) # find the project id url = tc.follow('Edit') pid = url.split("/")[-2] tc.go("/data/upload/simple/%s/" % pid) # search for then add Demo User to this project tc.formfile("1", "File1", conf.testdata('short-data.bed')) tc.formfile("1", "File2", conf.testdata('short-good-input.gtrack')) tc.formfile("1", "File3", conf.testdata('readcounts.png')) tc.submit() # verify uploads tc.find("short-data.bed") tc.find("short-good-input.gtrack") tc.find("readcounts.png") # visit the dataset tc.follow("short-good-input.gtrack") tc.find("waiting") # edit the dataset tc.follow("Edit") tc.fv("1", "name", "short-good-input.gtrack") tc.fv("1", "info", "extra-info") tc.submit() tc.find("extra-info") # upload two results for it tc.follow("Add results") tc.formfile("1", "content", conf.testdata('short-data.bed')) tc.formfile("1", "image", conf.testdata('readcounts.png')) tc.submit() tc.follow("short-data.bed") tc.back() # upload one image tc.follow("Add results") tc.formfile("1", "image", conf.testdata('shift.png')) tc.submit() tc.follow("shift.png") tc.back() # back to project view tc.follow("Project view") self.delete_project(name)
def test_data_uploads(self): # data upload test name = 'Upload-test-name' self.create_project(name) tc.follow(name) # find the project id url = tc.follow('Edit') pid = url.split("/")[-2] tc.go("/data/upload/simple/%s/" % pid) # search for then add Demo User to this project tc.formfile("1", "File1", conf.testdata('short-data.bed') ) tc.formfile("1", "File2", conf.testdata('short-good-input.gtrack') ) tc.formfile("1", "File3", conf.testdata('readcounts.png') ) tc.submit() # verify uploads tc.find("short-data.bed") tc.find("short-good-input.gtrack") tc.find("readcounts.png") # visit the dataset tc.follow("short-good-input.gtrack") tc.find("waiting") # edit the dataset tc.follow("Edit") tc.fv("1", "name", "short-good-input.gtrack" ) tc.fv("1", "info","extra-info" ) tc.submit() tc.find("extra-info") # upload two results for it tc.follow("Add results") tc.formfile("1", "content", conf.testdata('short-data.bed') ) tc.formfile("1", "image", conf.testdata('readcounts.png') ) tc.submit() tc.follow("short-data.bed") tc.back() # upload one image tc.follow("Add results") tc.formfile("1", "image", conf.testdata('shift.png') ) tc.submit() tc.follow("shift.png") tc.back() # back to project view tc.follow("Project view") self.delete_project(name)
def send(self, msg, *send_to): web.go(self.SERVICE_URL) self._retry_find("editableSmsComposeForm", 5) try: page = web.get_browser().get_html() web.notfind("inputCaptcha") except twill.errors.TwillAssertionError, e: found = re.search("(/composer/public/jcaptcha\?id=.*)", page) assert found web.go(found.groups()[0]) with tempfile.NamedTemporaryFile(suffix=".jpeg") as captcha: web.save_html(captcha.name) web.back() os.system("open %s " % captcha.name) web.formvalue("editableSmsComposeForm", "inputCaptcha", raw_input("Captcha: "))
def upload_list(browser, pagename, uploads): # get the file sizes for later comparison. filesizes = [] for fn in uploads: filesizes.append(os.stat(fn)[stat.ST_SIZE]) filesizes.reverse() # because they get listed newest first. # Upload copy #1. t.go(host + "index.php/Special:Upload") t.formfile("1", "wpUploadFile", uploads[0]) t.fv("1", "wpDestFile", pagename) t.fv("1", "wpUploadDescription", "Uploading %s" % pagename) t.submit("wpUpload") # Verify that we succeeded. t.find("File:%s" % pagename) for fn in uploads[1:]: # propose that we upload a replacement t.go(host + "index.php?title=Special:Upload&wpDestFile=%s&wpForReUpload=1" % pagename) t.formfile("1", "wpUploadFile", fn) t.fv("1", "wpUploadDescription", "Uploading %s as %s" % (fn, pagename)) t.submit("wpUpload") # get the URLs for the thumbnails urls = [] for url in re.finditer( r'<td><a href="([^"]*?)"><img alt="Thumbnail for version .*?" src="(.*?)"', browser.get_html() ): urls.append(url.group(1)) urls.append(url.group(2)) print filesizes for i, url in enumerate(urls): t.go(url) if i % 2 == 0 and len(browser.get_html()) != filesizes[i / 2]: print i, len(browser.get_html()), filesizes[i / 2] t.find("Files differ in size") t.code("200") t.back() # delete all versions t.go(host + "index.php?title=File:%s&action=delete" % pagename) # after we get the confirmation page, commit to the action. t.fv("1", "wpReason", "Test Deleting...") t.submit("mw-filedelete-submit") # make sure that we can't visit their URLs. for i, url in enumerate(urls): t.go(url) if 0 and i % 2 == 1 and i > 0 and browser.get_code() == 200: # bug 30192: the archived file's thumbnail doesn't get deleted. print "special-casing the last URL" continue t.code("404") # restore the current and archived version. t.go(host + "index.php/Special:Undelete/File:%s" % pagename) t.fv("1", "wpComment", "Test Restore") t.submit("restore") # visit the page to make sure that the thumbs get re-rendered properly. # when we get the 404 handler working correctly, this won't be needed. t.go(host + "index.php?title=File:%s" % pagename) # make sure that they got restored correctly. for i, url in enumerate(urls): t.go(url) if i % 2 == 0 and len(browser.get_html()) != filesizes[i / 2]: t.find("Files differ in size") t.code("200") t.back() if len(uploads) != 2: return match = re.search(r'"([^"]+?)" title="[^"]+?">revert', browser.get_html()) if not match: t.find("revert") t.go(match.group(1).replace("&", "&"))
def upload_list(browser, pagename, uploads): # get the file sizes for later comparison. filesizes = [] for fn in uploads: filesizes.append(os.stat(fn)[stat.ST_SIZE]) filesizes.reverse() # because they get listed newest first. # Upload copy #1. t.go(host + "index.php/Special:Upload") t.formfile("1", "wpUploadFile", uploads[0]) t.fv("1", "wpDestFile", pagename) t.fv("1", "wpUploadDescription", "Uploading %s" % pagename) t.submit("wpUpload") # Verify that we succeeded. t.find("File:%s" % pagename) for fn in uploads[1:]: # propose that we upload a replacement t.go(host + "index.php?title=Special:Upload&wpDestFile=%s&wpForReUpload=1" % pagename) t.formfile("1", "wpUploadFile", fn) t.fv("1", "wpUploadDescription", "Uploading %s as %s" % (fn, pagename)) t.submit("wpUpload") # get the URLs for the thumbnails urls = [] for url in re.finditer( r'<td><a href="([^"]*?)"><img alt="Thumbnail for version .*?" src="(.*?)"', browser.get_html()): urls.append(url.group(1)) urls.append(url.group(2)) print filesizes for i, url in enumerate(urls): t.go(url) if i % 2 == 0 and len(browser.get_html()) != filesizes[i / 2]: print i, len(browser.get_html()), filesizes[i / 2] t.find("Files differ in size") t.code("200") t.back() # delete all versions t.go(host + "index.php?title=File:%s&action=delete" % pagename) # after we get the confirmation page, commit to the action. t.fv("1", "wpReason", "Test Deleting...") t.submit("mw-filedelete-submit") # make sure that we can't visit their URLs. for i, url in enumerate(urls): t.go(url) if 0 and i % 2 == 1 and i > 0 and browser.get_code() == 200: # bug 30192: the archived file's thumbnail doesn't get deleted. print "special-casing the last URL" continue t.code("404") # restore the current and archived version. t.go(host + "index.php/Special:Undelete/File:%s" % pagename) t.fv("1", "wpComment", "Test Restore") t.submit("restore") # visit the page to make sure that the thumbs get re-rendered properly. # when we get the 404 handler working correctly, this won't be needed. t.go(host + "index.php?title=File:%s" % pagename) # make sure that they got restored correctly. for i, url in enumerate(urls): t.go(url) if i % 2 == 0 and len(browser.get_html()) != filesizes[i / 2]: t.find("Files differ in size") t.code("200") t.back() if len(uploads) != 2: return match = re.search(r'"([^"]+?)" title="[^"]+?">revert', browser.get_html()) if not match: t.find('revert') t.go(match.group(1).replace('&', '&'))