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.')
 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\.')
Example #3
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
Example #4
0
def authenticate(email, pwd):
    print "Authenticating Google Account: %s" % email
    browser.go(AUTH_URL)
    fv("1", "Email", email)
    fv("1", "Passwd", pwd)
    browser.submit()
    code(200)
 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\.')
Example #6
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")
Example #7
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")
Example #8
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
Example #9
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')
Example #10
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)
Example #11
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")
Example #12
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")
    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") 
Example #14
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')
    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)
Example #16
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___')
Example #17
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")
Example #18
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()
Example #19
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
Example #20
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)
Example #21
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)
Example #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)
Example #23
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")
Example #24
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___')
Example #25
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')
 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.'
     )
Example #27
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_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)
Example #31
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()
Example #32
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")
Example #33
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.')
 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)
    def test_unblock_remove_admin_contacts(self):
        tc.fv(2, 'new_holder', 'KONTAKT')
        tc.fv(2, 'remove_admin_contacts', True)
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.unblockDomainsId.assert_called_once_with(
            [1], 'KONTAKT', True, self.REASON_TEXT, 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()
Example #37
0
    def login(self):
        print "Logging in..."
        twill.go("https://www.cbox.ws")

        twill.formclear("1")
        twill.fv("1", "uname", self.loginInfo["username"])
        twill.fv("1", "pword", self.loginInfo["password"])

        twill.submit("0")
Example #38
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)
Example #39
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
Example #40
0
def agroup_join(agroup_id):

    cmd.go('/py/teacher/agroup/%s/join/' % str(agroup_id))

    #cmd.find('Sign up - step 1/2')
    cmd.fv('YPform', 'message', "test teacher want join to this group " * 3)
    cmd.submit()

    cmd.go('/py/teacher/agroup/%s/' % str(agroup_id))
Example #41
0
def post_file(form, field, file):
    globals, locals = get_twill_glocals()

    test_path = globals.get('test_path')
    file = os.path.join(test_path, file)
    file = open(file)
    body = file.read()
    file.close()
    fv(form, field, body)
Example #42
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
Example #43
0
 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)
def post_file(form, field, file):
    globals, locals = get_twill_glocals()

    test_path = globals.get("test_path")
    file = os.path.join(test_path, file)
    file = open(file)
    body = file.read()
    file.close()
    fv(form, field, body)
Example #45
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()
Example #46
0
    def test(self):

        # Create a project.
        project = Project.create_dummy()

        # Create two profiles, each with a PortfolioEntry linking it to the
        # project, each with descriptions.
        def create_pfe_with_description(username):
            return PortfolioEntry.create_dummy(
                project=project,
                person=Person.get_by_username(username),
                is_published=True)

        pfes = {
            'uncheck_me': create_pfe_with_description('paulproteus'),
            'keep_me_checked': create_pfe_with_description('barry')
        }

        # Get a list of PortfolioEntries that we use to get a random project
        # description for the project page.
        descriptions = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains both PortfolioEntries.
        for entry in pfes.values():
            self.assert_(entry in descriptions)

        self.login_with_twill()

        # Go to the project page.
        url = urlparse.urljoin("http://openhatch.org",
                               project.get_edit_page_url())
        tc.go(better_make_twill_url(url))

        # In preparation for the next set of assertions, make sure that the
        # entries don't have the same description.
        self.assertNotEqual(pfes['uncheck_me'].project_description,
                            pfes['keep_me_checked'].project_description)

        # See a list of project descriptions on the page, which equals the
        # list of descriptions in the DB.
        for entry in pfes.values():
            tc.find(entry.project_description)

        # Uncheck one of the checkboxes and submit the form
        name_of_checkbox_to_uncheck = "%s-use_my_description" % pfes[
            'uncheck_me'].pk
        tc.fv("2", name_of_checkbox_to_uncheck, False)
        tc.submit()

        # Get a list of the PortfolioEntries that we use to get a random
        # project description for the project page.
        good_pfentries = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains only the checked PortfolioEntry.
        self.assert_(pfes['uncheck_me'] not in good_pfentries)
        self.assert_(pfes['keep_me_checked'] in good_pfentries)
    def test_blacklist_to_date_ok(self):
        blacklist_to_date = datetime.date.today() + datetime.timedelta(1)
        tc.fv(2, 'blacklist_to_date', blacklist_to_date.isoformat())
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.blacklistAndDeleteDomainsId.assert_called_once_with(
            [1], Patched_IsoDate(blacklist_to_date.isoformat()),
            self.REASON_TEXT, 0)
Example #48
0
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()
Example #49
0
 def test_create_confirmation_link(self):
     """ filling and submitting form on create confirmation link page """
     go(SITE)
     code(200)
     follow("reset password")
     code(200)
     fv(2, 'email', '*****@*****.**')
     submit()
     code(200)
     find('Please, check your e-mail')
Example #50
0
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()
Example #51
0
 def test_form_sends_data_to_get(self):
     # This test will fail if a query that selects one project but doesn't
     # equal the project's name causes a redirect.
     relevant = mysite.search.models.Project.create_dummy(name='Twisted System')
     tc.go(better_make_twill_url('http://openhatch.org/+projects'))
     query = 'Twisted'
     tc.fv(1, 'search_q', query)
     tc.submit()
     tc.url('\?q=Twisted') # Assert that URL contains this substring.
     tc.find(query)
Example #52
0
    def test(self):

        # Create a project.
        project = Project.create_dummy()

        # Create two profiles, each with a PortfolioEntry linking it to the
        # project, each with descriptions.
        def create_pfe_with_description(username):
            return PortfolioEntry.create_dummy(project=project,
                                               person=Person.get_by_username(
                                                   username),
                                               is_published=True)
        pfes = {'uncheck_me': create_pfe_with_description('paulproteus'),
                'keep_me_checked': create_pfe_with_description('barry')}

        # Get a list of PortfolioEntries that we use to get a random project
        # description for the project page.
        descriptions = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains both PortfolioEntries.
        for entry in pfes.values():
            self.assert_(entry in descriptions)

        self.login_with_twill()

        # Go to the project page.
        url = urlparse.urljoin(
            "http://openhatch.org", project.get_edit_page_url())
        tc.go(better_make_twill_url(url))

        # In preparation for the next set of assertions, make sure that the
        # entries don't have the same description.
        self.assertNotEqual(
            pfes['uncheck_me'].project_description,
            pfes['keep_me_checked'].project_description)

        # See a list of project descriptions on the page, which equals the
        # list of descriptions in the DB.
        for entry in pfes.values():
            tc.find(entry.project_description)

        # Uncheck one of the checkboxes and submit the form
        name_of_checkbox_to_uncheck = "%s-use_my_description" % pfes[
            'uncheck_me'].pk
        tc.fv("2", name_of_checkbox_to_uncheck, False)
        tc.submit()

        # Get a list of the PortfolioEntries that we use to get a random
        # project description for the project page.
        good_pfentries = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains only the checked PortfolioEntry.
        self.assert_(pfes['uncheck_me'] not in good_pfentries)
        self.assert_(pfes['keep_me_checked'] in good_pfentries)
Example #53
0
def push_item(projectname, summary, comment, status, label):
    go("http://code.google.com/p/%s/issues/list" % (projectname,))
    follow("New Issue")
    fv("3", "summary", summary)
    fv("3", "comment", wraptext(comment))
    fv("3", "status", status)
    fv("3", "labelenter0", label)
    fv("3", "labelenter1", "")

    submit("submit")
    notfind("Letters did not match")
Example #54
0
def push_item(projectname, summary, comment, status, label):
    go('http://code.google.com/p/%s/issues/list' % (projectname, ))
    follow('New Issue')
    fv('3', 'summary', summary)
    fv('3', 'comment', wraptext(comment))
    fv('3', 'status', status)
    fv("3", "labelenter0", label)
    fv("3", "labelenter1", "")

    submit('submit')
    notfind("Letters did not match")
 def delete_project(self, name):
     """
     Deletes a project
     """
     tc.follow("Delete")
     tc.find("You are removing")
     tc.fv("1", "delete", True)
     tc.submit()
     tc.code(200)
     tc.find("Project deletion complete")
     tc.notfind(name)
Example #56
0
    def login_with_twill(self):
        # Visit login page
        login_url = 'http://openhatch.org/account/login/old'
        tc.go(make_twill_url(login_url))

        # Log in
        username = "******"
        password = "******"
        tc.fv('login', 'username', username)
        tc.fv('login', 'password', password)
        tc.submit()
Example #57
0
 def test_form_on_project_search_page_submits_to_project_creation_post_handler(self):
     project_search_page_url = better_make_twill_url(
             "http://openhatch.org%s?q=newproject" % reverse(mysite.project.views.projects))
     tc.go(project_search_page_url)
     # Fill form out with slightly different project name, which we
     # anticipate happening sometimes
     tc.fv('create_project', 'project_name', 'NewProject')
     tc.submit()
     post_handler_url = reverse(mysite.project.views.create_project_page_do)
     import re
     tc.url(re.escape(post_handler_url))
Example #58
0
def remove_from_job_queue(id):
    """
    remove a disease model from the job queue on the dismod server
    given in dismod3/settings.py
    """
    dismod_server_login()

    twc.go(DISMOD_REMOVE_JOB_URL)
    twc.fv("1", "id", str(id))
    twc.submit()
    return json.loads(twc.show())
Example #59
0
    def __init__(self, eid, pwd):
        self.url = 'http://utdirect.utexas.edu/' \
            'apps/registrar/course_schedule/20169'
        tc.go(self.url)
        tc.fv('1', 'IDToken1', eid)
        tc.fv('1', 'IDToken2', pwd)
        tc.submit()
        tc.submit()
        print("Logged in successfully.")

        self.grid = [[None for c in range(6)] for r in range(48)]
        self.course_set = set()
Example #60
0
def logInToReddit(username, password):
    try:
        urllib2.urlopen("http://reddit.com/user/%s" % username).read()
    except urllib2.HTTPError as e:
        if "404" in str(e):
            raise AccountBannedError("User %s has been banned." % username)

    t.go("http://www.reddit.com/")
    t.fv(2, "user", username)
    t.fv(2, "passwd", password)
    t.submit()
    return isLoggedIn()