Beispiel #1
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")
Beispiel #2
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()
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
0
 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')
Beispiel #6
0
def test_profile():
    """
    Test user profile
    """
    go(SITE + '/accounts/profile/')
    code(404)
    return
 def set_history(self):
     """Sets the history (stores the cookies for this run)"""
     if self.history_id:
         tc.go( "./history?id=%s" % self.history_id )
     else:
         tc.go( "./history" )
     tc.code(200)
Beispiel #8
0
    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)
Beispiel #9
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)
Beispiel #10
0
    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!")
Beispiel #11
0
def get(url):
    cmd.go(url)
    try:
        cmd.code(200)
    except TwillAssertionError as s:
        ff()
        raise TwillAssertionError('%s url %s' % (s, fullurl(url)))
    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)
 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")
Beispiel #14
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)
    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 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)
Beispiel #17
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)
Beispiel #18
0
 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)
 def set_history(self):
     """Sets the history (stores the cookies for this run)"""
     if self.history_id:
         tc.go("./history?id=%s" % self.history_id)
     else:
         tc.go("./history")
     tc.code(200)
Beispiel #20
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)
Beispiel #21
0
 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")
Beispiel #22
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()
def main():
    joker = SpawnKillerThread()
    try:
        SpawnDistributedCluster()
        print "Waiting for two JBoss instances to start up in cluster mode..."
        time.sleep(10)
        joker.start()
        #commands.debug('http', 1)
        #commands.debug('commands',1)
        b = get_browser()
        import socket
        myip = "http://" + socket.gethostbyname(socket.gethostname())
        b.go(myip + "/session-basket")
        b.submit(5)
        wordBatch = listOfRandomWords()
        for idx, w in enumerate(wordBatch):
            print "Adding word %d: '%s' to the list..." % (idx, w)
            commands.formvalue("1", "newItem:j_idt11", w)
            b.submit(4)
            commands.code(200)
            commands.find(w)
            time.sleep(0.25)
        print wordBatch, len(wordBatch)
        b.submit(5)
        commands.code(200)
        commands.reload()
        for w in wordBatch:
            commands.find(w)
    finally:
        joker.stopKilling = True
        joker.join()
        KillJBoss(0)
        KillJBoss(1)
    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 run_tool(self, tool_id, **kwd):
     tool_id = tool_id.replace(" ", "+")
     """Runs the tool 'tool_id' and pass it the key/values from the *kwd"""
     tc.go("%s/tool_runner/index?tool_id=%s" % (self.url, tool_id))
     tc.code(200)
     tc.find('runtool_btn')
     self.submit_form(**kwd)
     tc.code(200)
 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.'
     )
    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)
Beispiel #28
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')
 def run_tool(self, tool_id, **kwd):
     tool_id = tool_id.replace(" ", "+")
     """Runs the tool 'tool_id' and pass it the key/values from the *kwd"""
     tc.go("%s/tool_runner/index?tool_id=%s" % (self.url, tool_id) )
     tc.code(200)
     tc.find('runtool_btn')
     self.submit_form(**kwd)
     tc.code(200)
 def delete_data(self, hid):
     """Deletes data at a certain history id"""
     hid = str(hid)
     data_list = self.get_data_list()
     self.assertTrue( data_list )
     elems = [ elem for elem in data_list if elem.get('hid') == hid ]
     self.assertEqual(len(elems), 1)
     tc.go("/delete?id=%s" % elems[0].get('id') )
     tc.code(200)
Beispiel #31
0
 def test_it(self):
     from twill import commands as b
     b.follow('1975-11-04')
     b.find('1975-11-04')
     b.follow('photo_02.jpg')
     b.find('Test 2')
     b.find('November 4, 1975')
     b.follow('download')
     b.code(200)
Beispiel #32
0
def parse_entry_count(instance, kind):
    url = BASE_URL + instance + "&kind=" + kind
    browser.go(url)
    code(200)
    html = browser.get_html()
    result = count_regex.search(html)
    if result:
        return result.group(1).replace(",", "")#Avoid commas
    return "0"
 def delete_data(self, hid):
     """Deletes data at a certain history id"""
     hid = str(hid)
     data_list = self.get_data_list()
     self.assertTrue(data_list)
     elems = [elem for elem in data_list if elem.get('hid') == hid]
     self.assertEqual(len(elems), 1)
     tc.go("/delete?id=%s" % elems[0].get('id'))
     tc.code(200)
    def test_submit_default_data(self):
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.updateBlockDomainsId.assert_called_once_with([1], [
            'serverDeleteProhibited', 'serverTransferProhibited',
            'serverUpdateProhibited'
        ], None, self.REASON_TEXT, 0)
    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)
Beispiel #36
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 check_data(self, fname, hid=None, wait=True):
        """
        Verifies that a data at a history id is indentical to
        the contents of a file
        """

        if wait:  # wait for tools to finish
            self.wait()

        data_list = self.get_data_list()
        self.assertTrue( data_list )

        if hid is None: # take last hid
            elem = data_list[-1]
        else:
            hid = str(hid)
            elems = [ elem for elem in data_list if elem.get('hid') == hid ]
            self.assertTrue( len(elems) == 1 )
            elem = elems[0]

        if elem.get('state') != 'ok':
            tc.go("./history")
            tc.code(200)
#          print tc.show()

        hid = elem.get('hid')
        self.assertTrue( hid )
        self._assert_dataset_state( elem, 'ok' )

        local_name = self.get_fname(fname)
        temp_name  = self.get_fname('temp_%s' % fname)
        tc.go("./display?hid=" + str(hid) )

        data = self.last_page()
        file(temp_name, 'wb').write(data)

        if not filecmp.cmp(local_name, temp_name):
            #maybe it is just the line endings
            lc = 0
            for line1, line2 in zip(file(local_name), file(temp_name)):
                lc += 1
                line1 = line1.strip()
                line2 = line2.strip()
                if line1 != line2:
                    # nicer message
                    fromlines = open( local_name, 'U').readlines()
                    tolines = open( temp_name, 'U').readlines()
                    diff = difflib.unified_diff( fromlines, tolines, "local_file", "history_data" )
                    diff_slice = list( islice( diff, 40 ) )
                    if len( diff_slice ) == 40:
                        errmsg = [ 'Data at history id %s does not match expected, first 40 lines of diff:\n' % hid ]
                    else:
                        errmsg = [ 'Data at history id %s does not match expected, diff:\n' % hid ]
                    errmsg += diff_slice
                    raise AssertionError( "".join( errmsg ) )
        os.remove(temp_name)
    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)
Beispiel #39
0
 def send(self, msg, *send_to):
     for contact in send_to:
         web.follow(self.SERVICE_URL)
         web.follow("newsms")
         web.formvalue("sendSMS", "smsBody", msg)
         to = getattr(contact, "mobile", contact)
         web.formvalue("sendSMS", "smsTo", to)
         web.submit()
         web.code(200)
         web.find("newsms")
 def test_login_success_no_profile(self):
     """ successfull login for user without profile """
     user1 = User.objects.get(username__exact='user1')
     user1.get_profile().delete()
     self.general_login_action('user1',
                               'password1',
                               'Welcome, user1')
     follow('profile')
     code(200)
     find('Profile for this user not exists')
 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)
Beispiel #42
0
 def code(self,status):
     """
     By default Twill commands throw exceptions rather than failures when 
     an assertion fails. Here we wrap the Twill code command and return
     the expected response along with a helpful message.     
     """
     try:
         tc.go(self.url)
         tc.code(status)
     except TwillAssertionError:
         self.fail("%s did not return a %s" % (self.url, status))
Beispiel #43
0
def test_root_count(root):
    go("/")
    show()
    code(200)
    find("PyPI compatible package index serving 0 packages")
    showlinks()

    root.join("Twisted-11.0.0.tar.bz2").write("")
    reload()
    show()
    find("PyPI compatible package index serving 1 packages")
Beispiel #44
0
def test_profile_record():
    """
    Test availability of user profile
    """
    go(SITE + '/accounts/login/')
    code(200)
    show()
    formvalue(1, 'username', 'root')
    formvalue(1, 'password', '1')
    submit()
    code(200)
Beispiel #45
0
def test_root_count(root):
    go("/")
    show()
    code(200)
    find("PyPI compatible package index serving 0 packages")
    showlinks()

    root.join("Twisted-11.0.0.tar.bz2").write("")
    reload()
    show()
    find("PyPI compatible package index serving 1 packages")
    def test_submit_default_data(self):
        self.blocking_mock.blockDomainsId.return_value = []

        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.blockDomainsId.assert_called_once_with([1], [
            'serverDeleteProhibited', 'serverTransferProhibited',
            'serverUpdateProhibited'
        ], Registry.Administrative.KEEP_OWNER, None, self.REASON_TEXT, 0)
Beispiel #47
0
 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)
Beispiel #48
0
def test_reset_password():
    """
    Test user password reset
    """
    go(SITE + '/accounts/password/reset/')
    code(200)
    show()
    formvalue(1, 'email', '*****@*****.**')
    submit()
    code(200)
    find('Password reset successful')
    return
 def delete_history(self, hid):
     """Deletes a history at a certain id"""
     data_list = self.get_history_ids()
     self.assertTrue(data_list)
     if hid < 0:
         hid = len(data_list) + hid + 1
         print hid
     hid = str(hid)
     elems = [elem for elem in data_list if elem.get('hid') == hid]
     self.assertEqual(len(elems), 1)
     tc.go("/history_delete?id=%s" % elems[0].get('id'))
     tc.code(200)
Beispiel #50
0
 def create_user(self, user, pw):
     self.get("/user/create")
     tc.fv("1", "email", user)
     tc.fv("1", "password", pw)
     tc.fv("1", "confirm", pw)
     tc.submit("Create")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.already_exists:
             raise Exception, 'The user you were trying to create already exists'
Beispiel #51
0
 def create_user(self, user, pw):
     self.get("/user/create")
     tc.fv("1", "email", user)
     tc.fv("1", "password", pw)
     tc.fv("1", "confirm", pw)
     tc.submit("Submit")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.already_exists:
             raise Exception('The user you were trying to create already exists')
 def delete_history(self, hid):
     """Deletes a history at a certain id"""
     data_list = self.get_history_ids()
     self.assertTrue( data_list )
     if hid < 0:
         hid = len(data_list) + hid +1
         print hid
     hid = str(hid)
     elems = [ elem for elem in data_list if elem.get('hid') == hid ]
     self.assertEqual(len(elems), 1)
     tc.go("/history_delete?id=%s" % elems[0].get('id') )
     tc.code(200)
Beispiel #53
0
def studentset_leave(id, teacher_id=221):
    cmd.go('/py/teacher/studentset/%d/' % id)
    cmd.code(200)
    b = cmd.get_browser()
    mb = b._browser
    r = mb.open(
        '/py/teacher/studentset/teacher_remove/',
        urllib.urlencode({
            'setID': id,
            'remove': 'Remove',
            'id_list[]': '221'
        }))
Beispiel #54
0
    def login(self, name='admin', passwd='1'):
        "Performs a login"
        tc.go(testlib.BASE_URL)
        tc.follow('Log in now')
        tc.find("Please log in")
        tc.code(200)

        # logs in on every test
        tc.fv("1", "email", name)
        tc.fv("1", "password", passwd)
        tc.submit('0')
        tc.code(200)
        tc.find("Logged in as")
    def test_with_other_data(self):
        block_to_date = datetime.date.today() + datetime.timedelta(1)
        tc.fv(2, 'block_to_date', block_to_date.isoformat())
        tc.fv(2, 'blocking_status_list', '-serverTransferProhibited')
        tc.fv(2, 'blocking_status_list', '-serverUpdateProhibited')
        tc.fv(2, 'blocking_status_list', 'serverRenewProhibited')
        tc.submit()
        tc.code(200)
        tc.find('successful')

        self.blocking_mock.updateBlockDomainsId.assert_called_once_with(
            [1], ['serverDeleteProhibited', 'serverRenewProhibited'],
            Patched_IsoDate(block_to_date.isoformat()), self.REASON_TEXT, 0)
 def login(self, name='admin', passwd='1'):
     "Performs a login"
     tc.go( testlib.BASE_URL )
     tc.follow('Log in now')
     tc.find("Please log in") 
     tc.code(200)
     
     # logs in on every test
     tc.fv("1", "email", name)
     tc.fv("1", "password", passwd)
     tc.submit('0')
     tc.code(200)
     tc.find("Logged in as") 
Beispiel #57
0
def teacher_login(username='******', password='******'):
    cmd.go('/py/teacher/login/')

    cmd.fv(1, 'login', username)
    cmd.fv(1, 'password', password)

    cmd.submit()
    #alt: post('/py/teacher/login/', data=dict(login='******', password='******'))

    cmd.code(200)
    cmd.go('/py/teacher/')

    cmd.notfind('type="password"')
Beispiel #58
0
 def create_project(self, name, info='no info'):
     """
     Creates a new project
     """
     tc.go(testlib.PROJECT_LIST_URL)
     tc.find("Logged in as")
     tc.follow('New Project')
     tc.code(200)
     tc.find("Create New Project")
     tc.fv("1", "name", name)
     tc.fv("1", "info", info)
     tc.submit()
     tc.code(200)
     tc.find(name)
Beispiel #59
0
def download_with_login(url,
                        login_url,
                        login=None,
                        password=None,
                        ext='',
                        username_field='username',
                        password_field='password',
                        form_id=1):
    ''' Download a URI from a website using Django by loging-in first

        1. Logs in using supplied login & password (if provided)
        2. Create a temp file on disk using extension if provided
        3. Write content of URI into file '''

    # log-in to Django site
    if login and password:
        tw.go(login_url)
        tw.formvalue('%s' % form_id, username_field, login)
        tw.formvalue('%s' % form_id, password_field, password)
        tw.submit()

    # retrieve URI
    try:
        tw.go(url)
        tw.code('200')
    except TwillAssertionError:
        code = get_browser().get_code()
        # ensure we don't keep credentials
        tw.reset_browser()
        raise DownloadFailed(u"Unable to download %(url)s. "
                             u"Received HTTP #%(code)s." % {
                                 'url': url,
                                 'code': code
                             })
    buff = StringIO.StringIO()
    twill.set_output(buff)
    try:
        tw.show()
    finally:
        twill.set_output(None)
        tw.reset_browser()

    # write file on disk
    suffix = '.%s' % ext if ext else ''
    fileh, filename = tempfile.mkstemp(suffix=suffix)
    os.write(fileh, buff.getvalue())
    os.close(fileh)
    buff.close()

    return filename