def test_unblock_holder_not_exists(self):
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.unblockDomainsId.side_effect = Registry.Administrative.NEW_OWNER_DOES_NOT_EXISTS(
         what='KONTAKT')
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'New holder KONTAKT does not exists.')
예제 #2
0
    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") 
예제 #3
0
def login(username):
    """Find user for given username and make the browser logged in"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # Set a globabl Twill variable to let Twill scripts now the name
    # of the test, e.g. the directory, as well as community name.
    #global_dict['test_name'] = test_name
    #global_dict['community_name'] = test_name + "-testcase"
    global_dict['cwd'] = os.getcwd()

    hn = global_dict['localhost_url']

    # First logout
    logout()

    # Do a login
    au = global_dict['%s_user' % username]

    # Echo to screen
    dump("Logging into %s as %s" % (hn, au))

    # Continue
    ap = global_dict['%s_password' % username]
    commands.go(hn + '/login.html')
    commands.fv("formLogin", "login", au)
    commands.fv("formLogin", "password", ap)
    commands.submit()

    # Make sure the login succeeded
    commands.show()
    commands.find("My Profile")
 def test_restore_domain_not_found(self):
     tc.fv(2, 'restore_prev_state', True)
     self.blocking_mock.restorePreAdministrativeBlockStatesId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_FOUND(
         what=[1])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) with id 1 not found\.')
예제 #5
0
def login(username, password):
    t.add_extra_header("User-Agent", "*****@*****.**")

    t.go(host + "index.php/Special:UserLogin")
    t.fv("1", "wpName", username)
    t.fv("1", "wpPassword", password)
    t.submit("wpLoginAttempt")
예제 #6
0
    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")
def login():
    if s218:
        page = 'http://129.21.142.218:8008/securesync/login/'
        username = '******'
        password = '******'
        facility = '0939bcf9d5fe59ff8fde46b5a729a232'
    else:
        page = 'http://129.21.142.118:8008/securesync/login/'
        username = '******'
        password = '******'
        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))
예제 #8
0
파일: contrib.py 프로젝트: lukmdo/smsgates
    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)
 def test_file_missing_columns(self):
     tc.formfile(
         2, 'domains_emails',
         os.path.join(os.path.dirname(__file__),
                      'data/domain_2016-09-16_missing_column_id.csv'))
     tc.submit()
     tc.find('Missing column "Id" on the row 2.')
예제 #10
0
파일: contrib.py 프로젝트: lukmdo/smsgates
    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!")
예제 #11
0
def find_price(name, vintage, volume):

	formlist = []
	#com.showforms()
	all_forms = cbrw.get_all_forms()
	for each_form in all_forms:
		formlist.append(each_form.name)
	if 'searchform' in formlist:
		com.formclear("searchform")
		com.fv("searchform", "Xwinename", name)
		com.fv("searchform", "Xvintage", vintage)
		com.fv("searchform", "Xstateid", "CA")
		com.fv("searchform", "Xbottle_size", "Bottles")
		#com.fv("searchform", "Xprice_set", "CUR")
		com.submit()    
		url = com.browser.get_url()
		#print url

		page=urllib2.urlopen(url)

		soup = BeautifulSoup(page.read())
		prices=soup.findAll('span',{'class':'offer_price boldtxt'})

		price_values = []
		for price in prices:
			#print float((price.next).replace(",", ""))
			price_values.append(float((price.next).replace(",", "")))

		if len(price_values) > 0:
			return min(price_values), max(price_values), np.mean(price_values)
		else:
			return 'unknown', 'unknown', 'unknown'
	else:
		return 'unknown', 'unknown', 'unknown'
예제 #12
0
 def upload(self, input):
     self.get("/tool_runner/index?tool_id=upload1")
     tc.fv("1", "file_type", "bed")
     tc.fv("1", "dbkey", input.get('dbkey', '?'))
     tc.formfile("1", "file_data", input['file_path'])
     tc.submit("runtool_btn")
     tc.code(200)
예제 #13
0
 def create(self, cntrller='user', email='*****@*****.**', password='******', username='******', redirect=''):
     # HACK: don't use panels because late_javascripts() messes up the twill browser and it
     # can't find form fields (and hence user can't be logged in).
     params = dict(cntrller=cntrller, use_panels=False)
     self.visit_url("/user/create", params)
     tc.fv('registration', 'email', email)
     tc.fv('registration', 'redirect', redirect)
     tc.fv('registration', 'password', password)
     tc.fv('registration', 'confirm', password)
     tc.fv('registration', 'username', username)
     tc.submit('create_user_button')
     previously_created = False
     username_taken = False
     invalid_username = False
     try:
         self.check_page_for_string("Created new user account")
     except Exception:
         try:
             # May have created the account in a previous test run...
             self.check_page_for_string("User with that email already exists")
             previously_created = True
         except Exception:
             try:
                 self.check_page_for_string('Public name is taken; please choose another')
                 username_taken = True
             except Exception:
                 try:
                     # Note that we're only checking if the usr name is >< 4 chars here...
                     self.check_page_for_string('Public name must be at least 4 characters in length')
                     invalid_username = True
                 except Exception:
                     pass
     return previously_created, username_taken, invalid_username
예제 #14
0
 def refresh_form(self, control_name, value, form_no=0, form_id=None, form_name=None, **kwd):
     """Handles Galaxy's refresh_on_change for forms without ultimately submitting the form"""
     # control_name is the name of the form field that requires refresh_on_change, and value is
     # the value to which that field is being set.
     for i, f in enumerate(self.showforms()):
         if i == form_no or (form_id is not None and f.id == form_id) or (form_name is not None and f.name == form_name):
             break
     formcontrols = self.get_form_controls(f)
     try:
         control = f.find_control(name=control_name)
     except Exception:
         log.debug('\n'.join(formcontrols))
         # This assumes we always want the first control of the given name, which may not be ideal...
         control = f.find_control(name=control_name, nr=0)
     # Check for refresh_on_change attribute, submit a change if required
     if 'refresh_on_change' in control.attrs.keys():
         # Clear Control and set to proper value
         control.clear()
         tc.fv(f.name, control.name, value)
         # Create a new submit control, allows form to refresh, instead of going to next page
         control = ClientForm.SubmitControl('SubmitControl', '___refresh_grouping___', {'name': 'refresh_grouping'})
         control.add_to_form(f)
         control.fixup()
         # Submit for refresh
         tc.submit('___refresh_grouping___')
예제 #15
0
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()
예제 #16
0
def login():
    c.clear_cookies()
    c.go('http://icfpcontest.org/icfp10/login')
    c.fv(1, 'j_username', 'Side Effects May Include...')
    c.fv(1, 'j_password', '<redacted>')
    c.submit()
    c.save_cookies('/tmp/icfp.cookie')
예제 #17
0
def handle(msg):
    print "Handle funct"
    content_type, chat_type, chat_id = telepot.glance2(msg)
    data = open("users.txt", "a")
    if str(chat_id) in open('users.txt').read():
        print "User exists"
    else:
        data.write(str(chat_id) + " ")
        data.write(
            str(msg['chat']['first_name']) + " " +
            str(msg['chat']['last_name']) + "\n")
    cmd = str(msg['text'])

    if cmd == 'Results':
        bot.sendMessage(chat_id, "Enter USN number to see your results.")

    elif len(cmd) == 10:
        bot.sendMessage(chat_id, "Processing")
        go("http://results.vtu.ac.in/")
        formclear('1')
        fv("1", "rid", cmd)
        submit('submit')
        save_html(cmd + ".html")
        lines = open(cmd + '.html').readlines()
        open(cmd + '.html', 'w').writelines(lines[241:-84])
        open(cmd + '.html', 'a').writelines(
            "@vtu_bot- if this file is empty please check the USN or try again when the results are announced "
        )
        f = open(cmd + '.html', 'rb')
        response = bot.sendDocument(chat_id, f)
    else:
        bot.sendMessage(chat_id, "Please enter a valid USN number")
예제 #18
0
    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)
예제 #19
0
def login(username, password):
    t.add_extra_header("User-Agent", "*****@*****.**")

    t.go(host + "index.php/Special:UserLogin")
    t.fv("1", "wpName", username)
    t.fv("1", "wpPassword", password)
    t.submit("wpLoginAttempt")
예제 #20
0
    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)
예제 #21
0
파일: test.py 프로젝트: xaratt/andrytest
 def test_confirm_password_reset(self):
     """
     create confirmation link as Django engine and
     test it for resetting password
     """
     test_email = '*****@*****.**'
     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)
예제 #22
0
 def upload(self, input):
     self.get("/tool_runner/index?tool_id=upload1")
     tc.fv("1", "file_type", "bed")
     tc.fv("1", "dbkey", input.get('dbkey', '?'))
     tc.formfile("1", "file_data", input['file_path'])
     tc.submit("runtool_btn")
     tc.code(200)
예제 #23
0
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()
예제 #24
0
    def test_image_processing_library_error(self):
        """
        If the image processing library errors while preparing a photo, report a
        helpful message to the user and log the error. The photo is not added
        to the user's profile.
        """
        # Get a copy of the error log.
        string_log = StringIO.StringIO()
        logger = logging.getLogger()
        my_log = logging.StreamHandler(string_log)
        logger.addHandler(my_log)
        logger.setLevel(logging.ERROR)

        self.login_with_twill()
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus/'))
        tc.follow('photo')
        # This is a special image from issue166 that passes Django's image
        # validation tests but causes an exception during zlib decompression.
        tc.formfile('edit_photo', 'photo', photo('static/images/corrupted.png'))
        tc.submit()
        tc.code(200)

        self.assert_("Something went wrong while preparing this" in tc.show())
        p = Person.objects.get(user__username='******')
        self.assertFalse(p.photo.name)

        # an error message was logged during photo processing.
        self.assert_("zlib.error" in string_log.getvalue())
        logger.removeHandler(my_log)
예제 #25
0
 def refresh_form(self, control_name, value, form_no=0, form_id=None, form_name=None, **kwd):
     """Handles Galaxy's refresh_on_change for forms without ultimately submitting the form"""
     # control_name is the name of the form field that requires refresh_on_change, and value is
     # the value to which that field is being set.
     for i, f in enumerate(self.showforms()):
         if i == form_no or (form_id is not None and f.id == form_id) or (form_name is not None and f.name == form_name):
             break
     formcontrols = self.get_form_controls(f)
     try:
         control = f.find_control(name=control_name)
     except Exception:
         log.debug('\n'.join(formcontrols))
         # This assumes we always want the first control of the given name, which may not be ideal...
         control = f.find_control(name=control_name, nr=0)
     # Check for refresh_on_change attribute, submit a change if required
     if 'refresh_on_change' in control.attrs.keys():
         # Clear Control and set to proper value
         control.clear()
         tc.fv(f.name, control.name, value)
         # Create a new submit control, allows form to refresh, instead of going to next page
         control = ClientForm.SubmitControl('SubmitControl', '___refresh_grouping___', {'name': 'refresh_grouping'})
         control.add_to_form(f)
         control.fixup()
         # Submit for refresh
         tc.submit('___refresh_grouping___')
예제 #26
0
def get_bank(cert, get_bhc=False):

    try:

        if not completed_certs.has_key(cert):

            completed_certs[cert] = True

            go('http://www2.fdic.gov/idasp/confirmation.asp?inCert1=%s&AsOf=9/30/2008'
               % (cert))

            html = get_browser().get_html()

            bhc_links = bhc_cert_href.findall(html)

            if bhc_links is not None:
                for bhc_link in bhc_links:
                    pending_certs.append(bhc_link)

            save_html('%s_bank.html' % (cert))

            fv('1', 'ReportName', '99')
            submit()
            fv('2', 'ReportName', '99')
            submit()

            save_html('%s_report.html' % (cert))

            go('http://www2.fdic.gov/sod/sodInstBranchRpt.asp?rCert=%s&baritem=1&ryear=2008'
               % (cert))
            save_html('%s_sod.html' % (cert))

    except Exception, e:
        print e
예제 #27
0
파일: tests.py 프로젝트: rahdev/oh-mainline
    def test_image_processing_library_error(self):
        """
        If the image processing library errors while preparing a photo, report a
        helpful message to the user and log the error. The photo is not added
        to the user's profile.
        """
        # Get a copy of the error log.
        string_log = StringIO.StringIO()
        logger = logging.getLogger()
        my_log = logging.StreamHandler(string_log)
        logger.addHandler(my_log)
        logger.setLevel(logging.ERROR)

        self.login_with_twill()
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus/'))
        tc.follow('photo')
        # This is a special image from issue166 that passes Django's image
        # validation tests but causes an exception during zlib decompression.
        tc.formfile('edit_photo', 'photo',
                    photo('static/images/corrupted.png'))
        tc.submit()
        tc.code(200)

        self.assert_("Something went wrong while preparing this" in tc.show())
        p = Person.objects.get(user__username='******')
        self.assertFalse(p.photo.name)

        # an error message was logged during photo processing.
        self.assert_("zlib.error" in string_log.getvalue())
        logger.removeHandler(my_log)
예제 #28
0
    def test_edit_email_address(self):
        # Opt out of the periodic emails. This way, the only "checked"
        # checkbox is the one for if the user's email address gets shown.
        paulproteus = Person.objects.get()
        paulproteus.email_me_re_projects = False
        paulproteus.save()

        self.login_with_twill()

        _url = "http://openhatch.org/account/settings/contact-info/"
        url = make_twill_url(_url)

        email = "*****@*****.**"

        # Go to contact info form
        tc.go(url)

        # Let's first ensure that "*****@*****.**" doesn't appear on the page.
        # (We're about to add it.)
        tc.notfind('checked="checked"')
        tc.notfind(email)

        # Edit email
        tc.fv("a_settings_tab_form", "edit_email-email", email)
        tc.submit()

        # Form submission ought to redirect us back to the form.
        tc.url(url)

        # Was email successfully edited?
        tc.find(email)

        # And does the email address show up on the profile?
        tc.go(make_twill_url("http://openhatch.org/people/1"))
        tc.find(email)
예제 #29
0
def create_task(course_id, name, instructions, template='epf', **kwargs):
    """ create task and return through_id

       kwargs - additional parameters

    """
    agroup_id = admin_find_course(id=course_id)['agroup_id']

    cmd.go('/py/teacher/agroup/%s/course/%s/task/new/' %
           (agroup_id, course_id))

    cmd.fv(1, 'task_name', name)
    cmd.fv(1, 'task_template', template)
    cmd.submit()

    through_id = cmd.url('.+/task/(?P<task_through_id>\d+)/edit/')

    cmd.fv(1, 'instructions', instructions)
    cmd.submit('save')

    errors = soup().findAll('ul', {'class': 'errorlist'})
    if errors:
        raise AssertionError('Page errors: %s' % errors)

    cmd.find('Changes saved')

    return through_id
예제 #30
0
def student_login(login, password):
    """ login student by username and password """
    cmd.go('/py/student/login/')
    cmd.fv(1, 'login', login)
    cmd.fv(1, 'passwd', password)
    cmd.submit()
    cmd.find('Attempts/Cards')
예제 #31
0
	def __init__ (self, email, password):
		Browser.go(PANDORA_LOGIN_URL)
		Browser.formvalue(1, 'login_username', email)
		Browser.formvalue(1, 'login_password', password)
		Browser.submit()

		self.webname = Browser.info().split('/').pop()
예제 #32
0
def get_linkedin_viewer_count(username=None, password=None):
    from twill import get_browser
    from twill.commands import add_extra_header, go, fv, submit, reset_browser
    reset_browser()
    add_extra_header(
        'User-Agent',
        'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36'
    )
    go("https://www.linkedin.com/nhome/")
    #fv("login", 'session_password', 'LetsTryPrime')
    #fv("login", 'session_key', '*****@*****.**')
    fv("login", 'session_key', username)
    fv("login", 'session_password', password)
    submit()
    go('http://www.linkedin.com/wvmx/profile?trk=nav_responsive_sub_nav_wvmp')

    try:
        for i in get_browser().result.lxml\
                .get_element_by_id('viewers_list-content')\
                .iterchildren():
            user_listing = simplejson.loads(i.text.replace('\\u002d', '-'))
    except Exception as e:
        log.err('Failed to extract user_listing from page: {error}'.format(
            error=e))
        raise LinkedInFailure()

    try:
        current_count = user_listing['content']['wvmx_profile_viewers'][
            'viewersCount']
        return current_count
    except KeyError:
        log.err('Profile view struct in unknown format: {user_listing}'.format(
            user_listing=user_listing))
        raise LinkedInFailure()
 def test_unblock_domain_not_found(self):
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.unblockDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_FOUND(
         what=[1])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) with id 1 not found\.')
예제 #34
0
파일: tests.py 프로젝트: rahdev/oh-mainline
    def test_set_avatar(self):
        self.login_with_twill()
        for image in [
                photo('static/sample-photo.png'),
                photo('static/sample-photo.jpg')
        ]:
            url = 'http://openhatch.org/people/paulproteus/'
            tc.go(make_twill_url(url))
            tc.follow('photo')
            tc.formfile('edit_photo', 'photo', image)
            tc.submit()
            # Now check that the photo == what we uploaded
            p = Person.objects.get(user__username='******')
            self.assert_(p.photo.read() == open(image).read())

            response = self.login_with_client().get(
                reverse(mysite.account.views.edit_photo))
            self.assertEqual(
                response.context[0]['photo_url'], p.photo.url,
                "Test that once you've uploaded a photo via the photo editor, "
                "the template's photo_url variable is correct.")
            self.assert_(p.photo_thumbnail)
            thumbnail_as_stored = mysite.base.depends.Image.open(
                p.photo_thumbnail.file)
            w, h = thumbnail_as_stored.size
            self.assertEqual(w, 40)
예제 #35
0
 def create(self, cntrller='user', email='*****@*****.**', password='******', username='******', redirect=''):
     # HACK: don't use panels because late_javascripts() messes up the twill browser and it
     # can't find form fields (and hence user can't be logged in).
     params = dict(cntrller=cntrller, use_panels=False)
     self.visit_url("/user/create", params)
     tc.fv('registration', 'email', email)
     tc.fv('registration', 'redirect', redirect)
     tc.fv('registration', 'password', password)
     tc.fv('registration', 'confirm', password)
     tc.fv('registration', 'username', username)
     tc.submit('create_user_button')
     previously_created = False
     username_taken = False
     invalid_username = False
     try:
         self.check_page_for_string("Created new user account")
     except Exception:
         try:
             # May have created the account in a previous test run...
             self.check_page_for_string("User with that email already exists")
             previously_created = True
         except Exception:
             try:
                 self.check_page_for_string('Public name is taken; please choose another')
                 username_taken = True
             except Exception:
                 try:
                     # Note that we're only checking if the usr name is >< 4 chars here...
                     self.check_page_for_string('Public name must be at least 4 characters in length')
                     invalid_username = True
                 except Exception:
                     pass
     return previously_created, username_taken, invalid_username
    def test_success(self):
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.blacklistAndDeleteDomainsId.assert_called_once_with(
            [1], None, self.REASON_TEXT, 0)
예제 #37
0
def make_intranets(intranets_name):
    """ Make the offices root hierarchy, deleting if it exists"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    global_dict['intranets_name'] = intranets_name

    # Check to see if we have that community, if so, delete it.
    commands.go('/' + intranets_name)
    br = get_browser()
    status = br.get_code()
    if status != 404:
        # The community shouldn't exist, and so we should get 404
        # looking for it.  If no 404, then it exists and we should
        # delete it.
        url = "/%s/delete.html?confirm=1" % intranets_name
        commands.go(url)

    # Now, make the community and make sure it exists
    commands.go("/add_community.html")
    commands.fv("save", "title", intranets_name)
    desc = "Test intranets root created for Twill test case named '%s'"
    commands.fv("save", "description", desc % test_name)
    commands.submit()
    commands.find("Add Existing")
예제 #38
0
def _django_admin_delete_object(url):
    """ delete object with id from django admin by url """
    admin_login()
    cmd.go(url)
    cmd.code(200)
    cmd.find('Are you sure?')
    cmd.submit()
    cmd.find('deleted successfully')
예제 #39
0
파일: disease_json.py 프로젝트: flaxter/gbd
def dismod_server_login():
    """ login to the dismod server given in dismod3/settings.py."""

    twc.go(DISMOD_LOGIN_URL)
    twc.fv("1", "username", DISMOD_USERNAME)
    twc.fv("1", "password", DISMOD_PASSWORD)
    twc.submit()
    twc.url("accounts/profile")
 def test_restore_error_when_use_remove_admin_contact(self):
     tc.fv(2, 'restore_prev_state', True)
     tc.fv(2, 'remove_admin_contacts', True)
     tc.submit()
     tc.code(200)
     tc.find(
         'You cannot use "Remove admin. contacts" and "Restore prev. state" at the same time.'
     )
예제 #41
0
def authAndRedirect(username, password):
    tw.reset_browser()
    tw.go(SYS_REDIRECT_URL)
    tw.fv('1', "username", username)
    tw.fv('1', "password", password)
    tw.formaction('1', AUTH_URL)
    tw.submit()
    return tw.get_browser().get_html()
예제 #42
0
def dismod_server_login():
    """ login to the dismod server given in dismod3/settings.py."""
    
    twc.go(DISMOD_LOGIN_URL)
    twc.fv('1', 'username', DISMOD_USERNAME)
    twc.fv('1', 'password', DISMOD_PASSWORD)
    twc.submit()
    twc.url('accounts/profile')
예제 #43
0
def authAndRedirect(username, password):
    tw.reset_browser()
    tw.go(SYS_REDIRECT_URL)
    tw.fv('1', "username", username)
    tw.fv('1', "password", password)
    tw.formaction('1', AUTH_URL)
    tw.submit()
    return tw.get_browser().get_html()
 def test_file_with_invalid_id(self):
     tc.formfile(
         2, 'domains_emails',
         os.path.join(os.path.dirname(__file__),
                      'data/domain_2016-09-16_invalid_id.csv'))
     tc.submit()
     tc.find(
         'Invalid value in column Id: "asdf9". It must be a whole number.')
    def test_restore_success(self):
        tc.fv(2, 'restore_prev_state', True)
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.restorePreAdministrativeBlockStatesId.assert_called_once_with(
            [1], '', self.REASON_TEXT, 0)
 def test_restore_holder_not_exists(self):
     tc.fv(2, 'restore_prev_state', True)
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.restorePreAdministrativeBlockStatesId.side_effect = Registry.Administrative.NEW_OWNER_DOES_NOT_EXISTS(
         what='KONTAKT')
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'New holder KONTAKT does not exists.')
    def test_unblock_success(self):
        tc.fv(2, 'new_holder', 'KONTAKT')
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.unblockDomainsId.assert_called_once_with(
            [1], 'KONTAKT', False, self.REASON_TEXT, 0)
예제 #48
0
    def login(self):
        from twill import commands as b
        b.go('/login')
        b.fv('login', 'login', 'chris')
        b.fv('login', 'password', 'chris')
        b.submit()

        b.find('You are logged in as chris.')
예제 #49
0
파일: tests.py 프로젝트: reik/oh-mainline
 def test_usernames_case_insensitive(self):
     tc.go(make_twill_url("http://openhatch.org/account/signup/"))
     tc.notfind("already got a user in our database with that username")
     tc.fv("signup", "username", "PaulProteus")
     tc.fv("signup", "email", "*****@*****.**")
     tc.fv("signup", "password1", "blahblahblah")
     tc.fv("signup", "password2", "blahblahblah")
     tc.submit()
     tc.find("already got a user in our database with that username")
예제 #50
0
파일: test.py 프로젝트: xaratt/andrytest
 def general_login_action(self, username, password, message):
     """ login with given login/password and find given message on page """
     go(SITE)
     code(200)
     fv(1, 'username', username)
     fv(1, 'password', password)
     submit()
     code(200)
     find(message)
예제 #51
0
    def __create_session(self):
        browser = get_browser()
        browser.go('http://www.erstenachhilfe.de/user?destination=node%2F767')
        tw.fv('2', 'edit-name', LOGIN)
        tw.fv('2', 'edit-pass', PASSWORD)
        tw.showforms()
        tw.submit('op')

        return browser
예제 #52
0
 def submit_form(self, form=1, button="runtool_btn", **kwd):
     """Populates and submits a form from the keyword arguments"""
     for key, value in kwd.items():
         # needs to be able to handle multiple values per key
         if type(value) != type([]):
             value = [ value ]
         for elem in value:
             tc.fv(str(form), str(key), str(elem) )
     tc.submit(button)
예제 #53
0
 def upload_file(self, fname, ftype='auto', dbkey='hg17'):
     """Uploads a file"""
     fname = self.get_fname(fname)
     tc.go("./tool_runner/index?tool_id=upload1")
     tc.fv("1","file_type", ftype)
     tc.fv("1","dbkey", dbkey)
     tc.formfile("1","file_data", fname)
     tc.submit("runtool_btn")
     self.home()
예제 #54
0
파일: tests.py 프로젝트: reik/oh-mainline
 def test_reserved_username(self):
     tc.go(make_twill_url("http://openhatch.org/account/signup/"))
     tc.notfind("That username is reserved.")
     tc.fv("signup", "username", "admin")
     tc.fv("signup", "email", "*****@*****.**")
     tc.fv("signup", "password1", "blahblahblah")
     tc.fv("signup", "password2", "blahblahblah")
     tc.submit()
     tc.find("That username is reserved.")
예제 #55
0
 def test_reserved_username(self):
     tc.go(make_twill_url('http://openhatch.org/account/signup/'))
     tc.notfind('That username is reserved.')
     tc.fv('signup', 'username', 'admin')
     tc.fv('signup', 'email', '*****@*****.**')
     tc.fv('signup', 'password1', 'blahblahblah')
     tc.fv('signup', 'password2', 'blahblahblah')
     tc.submit()
     tc.find('That username is reserved.')
예제 #56
0
파일: tests.py 프로젝트: rahdev/oh-mainline
 def test_usernames_case_insensitive(self):
     tc.go(make_twill_url('http://openhatch.org/account/signup/'))
     tc.notfind('already got a user in our database with that username')
     tc.fv('signup', 'username', 'PaulProteus')
     tc.fv('signup', 'email', '*****@*****.**')
     tc.fv('signup', 'password1', 'blahblahblah')
     tc.fv('signup', 'password2', 'blahblahblah')
     tc.submit()
     tc.find('already got a user in our database with that username')
예제 #57
0
 def test_usernames_case_insensitive(self):
     tc.go(make_twill_url('http://openhatch.org/account/signup/'))
     tc.notfind('already got a user in our database with that username')
     tc.fv('signup', 'username', 'PaulProteus')
     tc.fv('signup', 'email', '*****@*****.**')
     tc.fv('signup', 'password1', 'blahblahblah')
     tc.fv('signup', 'password2', 'blahblahblah')
     tc.submit()
     tc.find('already got a user in our database with that username')
예제 #58
0
    def __create_session(self):
        browser = get_browser()
        browser.go('http://www.erstenachhilfe.de/user?destination=node%2F767')
        tw.fv('2', 'edit-name', LOGIN)
        tw.fv('2', 'edit-pass', PASSWORD)
        tw.showforms()
        tw.submit('op')

        return browser
예제 #59
0
    def test_edit_email_address(self):
        # Opt out of the periodic emails. This way, the only "checked"
        # checkbox is the one for if the user's email address gets shown.
        paulproteus = Person.objects.get()
        paulproteus.email_me_re_projects = False
        paulproteus.save()

        self.login_with_twill()
        

        _url = 'http://openhatch.org/account/settings/contact-info/'
        url = make_twill_url(_url)

        email = '*****@*****.**'

        # Go to contact info form
        tc.go(url)

        # Let's first ensure that "*****@*****.**" doesn't appear on the page.
        # (We're about to add it.)
        tc.notfind('checked="checked"')
        tc.notfind(email)

        # Edit email
        tc.fv("a_settings_tab_form", 'edit_email-email', email)
        # Show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '1') # [1]
        tc.submit()

        # Form submission ought to redirect us back to the form.
        tc.url(url)

        # Was email successfully edited? 
        tc.find(email)

        # Was email visibility successfully edited? [2]
        tc.find('checked="checked"')

        # And does the email address show up on the profile?
        tc.go(make_twill_url(
                'http://openhatch.org/people/paulproteus'))
        tc.find(email)

        # 2. And when we uncheck, does it go away?
        
        # 2.1. Go to contact info form
        tc.go(url)

        # 2.2. Don't show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '0') # [1]
        tc.submit()

        # 2.3. Verify it's not on profile anymore
        tc.go(make_twill_url(
                'http://openhatch.org/people/paulproteus'))
        tc.notfind(email)
예제 #60
0
파일: disease_json.py 프로젝트: flaxter/gbd
def add_covariates_to_disease_model(dm):
    """
    submit request to dismod server to add covariates to disease model dm
    wait for response (which can take a while)
    """
    dismod_server_login()

    twc.go(DISMOD_BASE_URL + "dismod/run/%d" % dm)
    twc.fv("1", "update", "")
    twc.submit()