Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def delete_agroup(id):
    post('/py/teacher/agroup/%s/delete/' % id, dict(agroup=id,
                                                    delete='Delete'))

    # verify agroup not exists
    cmd.go('/py/teacher/agroup/list/')
    cmd.notfind('py/teacher/agroup/%s/' % id)
Ejemplo n.º 3
0
def catalog_find(searchterm, urlfrag, notfind=False):
    """Just like Twill find, but issues a searchpage-search search"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # This will navigate us away from the place the Twill script is
    # sitting.  Thus, stash away to the current URL, then navigate
    # back to that URL after searching.
    br = get_browser()
    start_url = br.get_url()

    esc_searchterm = urllib.quote(searchterm)
    url = "/searchresults.html?body=" + esc_searchterm
    commands.go(url)

    # Now do the test.  With the fragment of the URL that was
    # provided, we can do a double-check, to make sure the
    # searchresults provide that.
    if notfind:
        commands.notfind(urlfrag)
    else:
        commands.find(urlfrag)

    # Finally, send them back to the original URL.
    commands.go(start_url)
Ejemplo n.º 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)
Ejemplo n.º 5
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)
 def test_blocked_domain_detail_buttons(self):
     self._prepare_domain_detail(blocked=True)
     tc.go('http://localhost:8080/domain/detail/?id=1')
     tc.notfind(self.FILTER_BUTTON_XPATH % 'Block', 'x')
     tc.find(self.FILTER_BUTTON_XPATH % 'Blacklist and delete', 'x')
     tc.find(self.FILTER_BUTTON_XPATH % 'Change blocking', 'x')
     tc.find(self.FILTER_BUTTON_XPATH % 'Unblock', 'x')
Ejemplo n.º 7
0
 def test_logout_web(self):
     self.test_login_web()
     url = "http://openhatch.org/search/"
     url = make_twill_url(url)
     tc.go(url)
     tc.notfind("log in")
     tc.follow("log out")
     tc.find("log in")
Ejemplo n.º 8
0
 def test_logout_web(self):
     self.test_login_web()
     url = 'http://openhatch.org/search/'
     url = make_twill_url(url)
     tc.go(url)
     tc.notfind('log in')
     tc.follow('log out')
     tc.find('log in')
Ejemplo n.º 9
0
 def test_logout_web(self):
     self.test_login_web()
     url = 'http://openhatch.org/search/'
     url = make_twill_url(url)
     tc.go(url)
     tc.notfind('log in')
     tc.follow('log out')
     tc.find('log in')
Ejemplo n.º 10
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')
Ejemplo n.º 11
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')
Ejemplo n.º 12
0
    def test_detail_page(self):
        tc.go('http://localhost:8080/contactcheck/detail/%s/' %
              self.check_handle)
        tc.find('KONTAKT')
        tc.notfind('running')

        # check that both current contact data and tested contact data are displayed:
        tc.find('Namesti republiky')
        tc.find('Namesti generala Fejlureho')
Ejemplo n.º 13
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.")
Ejemplo n.º 14
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")
Ejemplo n.º 15
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.')
Ejemplo n.º 16
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.')
Ejemplo n.º 17
0
def delete_course(id):
    course = admin_find_course(id=id)

    post2(
        '/py/teacher/agroup/%s/course/%s/delete/' % (course['agroup_id'], id),
        dict(course=id, delete='Delete'))

    cmd.url('.*/course_list/')

    cmd.notfind('course/%s' % id)  # in href
Ejemplo n.º 18
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")
Ejemplo n.º 19
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)
Ejemplo n.º 20
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")
Ejemplo n.º 21
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)
Ejemplo n.º 22
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")
Ejemplo n.º 23
0
def admin_login(username='******', password='******'):
    # admin session
    is_admin_session = 'admin_session' in [c.name for c in cmd.browser.cj]

    # search amin session in
    global _last_admin_login
    if _last_admin_login != username or not is_admin_session:
        cmd.go('/YP-admin/login/?next=/YP-admin/')
        cmd.fv(1, 'username', username)
        cmd.fv(1, 'password', password)
        cmd.submit()
        cmd.notfind("Your username and password didn't match")
        _last_admin_login = username
Ejemplo n.º 24
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"')
Ejemplo n.º 25
0
    def test_detail_manual_perms_fail_req(self):
        self.authorizer.add_perms('read.contactcheck_manual',
                                  'change.contactcheck_manual')
        self.verif_mock.getContactCheckDetail.side_effect = self._get_contact_check_func(
            'manual', 'fail_req')

        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.notfind('Resolve as failed')

        self.authorizer.add_perms('delete.domain')
        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('Resolve as failed')
Ejemplo n.º 26
0
    def send(self, msg, *send_to):
        web.go(self.SERVICE_URL)
        self._retry_find("editableSmsComposeForm", 5)

        try:
            page = web.get_browser().get_html()
            web.notfind("inputCaptcha")
        except twill.errors.TwillAssertionError, e:
            found = re.search("(/composer/public/jcaptcha\?id=.*)", page)
            assert found
            web.go(found.groups()[0])
            with tempfile.NamedTemporaryFile(suffix=".jpeg") as captcha:
                web.save_html(captcha.name)
                web.back()
                os.system("open %s " % captcha.name)
                web.formvalue("editableSmsComposeForm", "inputCaptcha", raw_input("Captcha: "))
Ejemplo n.º 27
0
    def test_project_member_sharing(self):

        # tests sharing as a member
        tc.go( testlib.PROJECT_LIST_URL )
        tc.find("Logged in as") 
        
        # a project list with member access
        tc.find("Fly data 19") 
        tc.follow("Fly data 19")
        tc.follow("Sharing")
        tc.find("Current members")
        
        # members may not add access
        tc.notfind("Add access")
        tc.follow("<< return to project")
        tc.find("Project: Fly data 19") 
Ejemplo n.º 28
0
    def test_project_member_sharing(self):

        # tests sharing as a member
        tc.go(testlib.PROJECT_LIST_URL)
        tc.find("Logged in as")

        # a project list with member access
        tc.find("Fly data 19")
        tc.follow("Fly data 19")
        tc.follow("Sharing")
        tc.find("Current members")

        # members may not add access
        tc.notfind("Add access")
        tc.follow("<< return to project")
        tc.find("Project: Fly data 19")
Ejemplo n.º 29
0
    def test_detail_automatic_perms(self):
        tc.go('http://localhost:8080/contactcheck/detail/%s/' %
              self.check_handle)
        tc.find('don\'t have permissions')

        self.authorizer.add_perms('read.contactcheck_automatic')
        tc.go('http://localhost:8080/contactcheck/detail/%s/' %
              self.check_handle)
        tc.notfind('don\'t have permissions')
        tc.notfind('Invalidate')

        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('don\'t have permissions')

        self.authorizer.add_perms('change.contactcheck_automatic')
        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('Invalidate')
        tc.notfind('Resolve as failed')

        self.authorizer.add_perms('add.contactcheck_manual')
        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('Resolve as failed')
Ejemplo n.º 30
0
    def test_detail_manual_perms(self):
        self.verif_mock.getContactCheckDetail.side_effect = self._get_contact_check_func(
            'manual')

        tc.go('http://localhost:8080/contactcheck/detail/%s/' %
              self.check_handle)
        tc.find('don\'t have permissions')

        self.authorizer.add_perms('read.contactcheck_manual')
        tc.go('http://localhost:8080/contactcheck/detail/%s/' %
              self.check_handle)
        tc.notfind('don\'t have permissions')

        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('don\'t have permissions')

        self.authorizer.add_perms('change.contactcheck_manual')
        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('Invalidate')
        tc.notfind('thank letter')

        self.authorizer.add_perms('add.contactcheck_thank_you')
        tc.go('http://localhost:8080/contactcheck/detail/%s/resolve/' %
              self.check_handle)
        tc.find('thank letter')
        tc.notfind('Resolve as failed')
Ejemplo n.º 31
0
def make_files(pagename):
    redfilename = "/tmp/Red-%s" % pagename
    greenfilename = "/tmp/Green-%s" % pagename
    bluefilename = "/tmp/Blue-%s" % pagename

    # create a small test image.
    gd.gdMaxColors = 256
    i = gd.image((200, 100))
    black = i.colorAllocate((0, 0, 0))
    white = i.colorAllocate((255, 255, 255))
    red = i.colorAllocate((255, 55, 55))
    green = i.colorAllocate((55, 255, 55))
    blue = i.colorAllocate((55, 55, 255))

    # now write a red version
    i.rectangle((0, 0), (199, 99), red, red)
    i.line((0, 0), (199, 99), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(redfilename)

    # now write a green version
    i.rectangle((0, 0), (199, 99), green, green)
    i.line((0, 0), (99, 99), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(greenfilename)

    # write a blue version
    i.rectangle((0, 0), (199, 99), blue, blue)
    i.line((0, 0), (99, 199), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(bluefilename)

    # propose that we delete it (in case it exists)
    t.go(host + "index.php?title=File:%s&action=delete" % pagename)
    # make sure that we've NOT gotten the wrong page and HAVE gotten the right one.
    t.notfind("You are about to delete the file")
    t.find("could not be deleted")

    return (redfilename, greenfilename, bluefilename)
Ejemplo n.º 32
0
def make_files(pagename):
    redfilename = "/tmp/Red-%s" % pagename
    greenfilename = "/tmp/Green-%s" % pagename
    bluefilename = "/tmp/Blue-%s" % pagename

    # create a small test image.
    gd.gdMaxColors = 256
    i = gd.image((200, 100))
    black = i.colorAllocate((0, 0, 0))
    white = i.colorAllocate((255, 255, 255))
    red = i.colorAllocate((255, 55, 55))
    green = i.colorAllocate((55, 255, 55))
    blue = i.colorAllocate((55, 55, 255))

    # now write a red version
    i.rectangle((0, 0), (199, 99), red, red)
    i.line((0, 0), (199, 99), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(redfilename)

    # now write a green version
    i.rectangle((0, 0), (199, 99), green, green)
    i.line((0, 0), (99, 99), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(greenfilename)

    # write a blue version
    i.rectangle((0, 0), (199, 99), blue, blue)
    i.line((0, 0), (99, 199), black)
    i.string(gd.gdFontLarge, (5, 50), pagename, white)
    i.writePng(bluefilename)

    # propose that we delete it (in case it exists)
    t.go(host + "index.php?title=File:%s&action=delete" % pagename)
    # make sure that we've NOT gotten the wrong page and HAVE gotten the right one.
    t.notfind('You are about to delete the file')
    t.find("could not be deleted")

    return (redfilename, greenfilename, bluefilename)
Ejemplo n.º 33
0
def _django_admin_change_object(url, **kwargs):
    """ create/edit object in django admin and return his id

    url - url of django object modify form
    kwargs - form fields and values

    """
    cmd.go(url)
    cmd.find('Save and continue editing')
    for k, v in kwargs.iteritems():
        # send checked checkboxes as 'on', unchecked not send.
        if type(v) == bool:
            if v:
                cmd.fv(1, k, 'on')
            else:
                pass
        else:
            # default
            cmd.fv(1, k, str(v))

    cmd.submit('_continue')

    try:
        cmd.notfind('Please correct the error below')
    except TwillAssertionError as e:
        print('Page errors: %s' % soup().findAll('ul', {'class': 'errorlist'}))
        ff()
        raise

    try:
        cmd.find('was \w* successfully. You may edit it again below.')
    except TwillAssertionError as e:
        ff()
        raise

    id = cmd.url('.*/(?P<id>\d+)/')

    return id
Ejemplo n.º 34
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)
Ejemplo n.º 35
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)
Ejemplo n.º 36
0
 def runTest(self):
     """
     The twill test case is useful for emulating a user using HTML forms and clicking on buttons.
     Note we cannot connect to the twill server using urllib2 or any other third party client.
     Also, we cannot verify the header content in a twill response.
     """
     FILTER_FORM = 2
     
     logger = logging.getLogger("TwillTestCase")
     url = URL_BASE
     twill_quiet()
     logger.info('accessing ' + url)
     tc.go(url)
     tc.find("html") # sanity check that this is a html request.
     
     url = URL_BASE + 'filter/'
     logger.info('accessing ' + url)
     tc.go(url)
     tc.formvalue(FILTER_FORM,'tag','esnet')
     tc.submit(9) #simulates a click on the "create filter" button
     tc.find("html")
     tc.find('<table class="sortable">') #a line in event.list.html
     tc.notfind('experiment') #should be filtered out
     
     tc.go(url)
     tc.formvalue(FILTER_FORM,'display','timeline')
     tc.submit(9) #click should direct us to timeline.
     tc.find("html")
     tc.notfind('<table class="sortable">') 
     
     tc.go(url)
     tc.formvalue(FILTER_FORM,'display','json')
     tc.submit(9) #click should give us JSON object.
     tc.find('"pk": 1') #part of JSON string.
     tc.notfind("html")
     
     tc.go(url)
     tc.formvalue(FILTER_FORM,'name','upgrade')
     tc.formvalue(FILTER_FORM,'search','www.es.net')
     tc.formvalue(FILTER_FORM,'description','infrastructure')
     tc.submit(9)
     tc.find('html')
     tc.find('www.es.net') #part of the upgrade event.
     
     #Set headers to contain only the json mime
     tc.clear_extra_headers()
     tc.add_extra_header('Accept',JSON_MIME)
     
     url = URL_BASE
     logger.info('accessing ' + url)
     tc.go(url)
     logger.debug('JSON data:' + tc.show())
     tc.notfind("html") 
     tc.find('"name": "experiment"') #data from the fixture formatted by default serializer
     tc.find('"tags": "esnet"')
     
     url = URL_BASE + '1/'
     logger.info('accessing ' + url)
     tc.go(url)
     tc.notfind("html")
     tc.find('"name": "experiment"') 
     tc.notfind('"tags": "esnet"') 
Ejemplo n.º 37
0
def test_simple_list_no_dotfiles(root):
    root.join(".foo-1.0.zip").write("secret")
    go("/simple/")
    notfind("foo")
Ejemplo n.º 38
0
def test_packages_list_no_dotfiles(root):
    root.join(".foo-1.0.zip").write("secret")
    go("/packages/")
    notfind("foo")
Ejemplo n.º 39
0
 def test_it(self):
     from twill import commands as b
     b.follow('October 1975')
     b.find('1975-10-19')
     b.notfind('1975-12-06')
Ejemplo n.º 40
0
                                                      minute=13,
                                                      second=14),
                last_contact_update=ccReg.DateTimeType(date=ccReg.DateType(
                    day=6, month=6, year=2014),
                                                       hour=14,
                                                       minute=13,
                                                       second=0),
                current_status='auto_to_be_decided'),
        ]

        tc.go('http://localhost:8080/contactcheck/json_filter/')
        tc.find('don\'t have permissions')

        authorizer.add_perms('read.contactcheck_automatic')
        tc.go('http://localhost:8080/contactcheck/json_filter/')
        tc.notfind('don\'t have permissions')
        data = json.loads(tc.browser.result.text)
        assert_equal(data['aaData'][0][2], 'automatic')

        authorizer.rem_perms('read.contactcheck_automatic')
        authorizer.add_perms('read.contactcheck_manual')
        tc.go('http://localhost:8080/contactcheck/json_filter/')
        tc.notfind('Resolve')
        data = json.loads(tc.browser.result.text)
        assert_equal(len(data), 1)
        assert_equal(data['aaData'][0][2], 'manual')

        authorizer.add_perms('change.contactcheck_manual')
        tc.go('http://localhost:8080/contactcheck/json_filter/')
        tc.find('Resolve')
Ejemplo n.º 41
0
def test_packages_list_no_dotfiles(root):
    root.join(".foo-1.0.zip").write("secret")
    go("/packages/")
    notfind("foo")
Ejemplo n.º 42
0
def test_simple_list_no_dotdir(root):
    root.mkdir(".subdir").join("foo-1.0.zip").write("secret")
    go("/simple/")
    show()
    notfind("foo")
Ejemplo n.º 43
0
def test():
    url = twilltestlib.get_url()

    # capture output
    fp = StringIO()
    twill.set_output(fp)

    twill.parse.execute_string('code 200', initial_url=url)

    # from file
    twilltestlib.execute_twill_script('test-go.twill', initial_url=url)

    twill.set_output(None)
    assert fp.getvalue()

    ###

    # from stdin
    filename = os.path.join(twilltestlib.testdir, 'test-go.twill')
    old_in, sys.stdin = sys.stdin, open(filename)
    try:
        twilltestlib.execute_twill_script('-', initial_url=url)
    finally:
        sys.stdin = old_in

    # from parse.execute_file
    twill.parse.execute_file('test-go-exit.twill', initial_url=url)

    # also test some failures.

    old_err, sys.stderr = sys.stderr, StringIO()
    try:
        twill.set_errout(sys.stderr)
        #
        # failed assert in a script
        #
        try:
            twill.parse.execute_file('test-go-fail.twill', initial_url=url)
            assert 0
        except TwillAssertionError:
            pass

        commands.go(url)
        try:
            commands.code(400)
            assert 0
        except TwillAssertionError:
            pass

        #
        # no such command (NameError)
        #

        try:
            twill.parse.execute_file('test-go-fail2.twill', initial_url=url)
            assert 0
        except TwillNameError, e:
            pass
    finally:
        sys.stderr = old_err

    namespaces.new_local_dict()
    gd, ld = namespaces.get_twill_glocals()

    commands.go(url)
    try:
        twill.parse.execute_command('url', ('not this', ), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.follow('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.find('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.notfind('Hello')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        twill.parse.execute_command('exit', ('0', ), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except SystemExit:
        pass
Ejemplo n.º 44
0
def test_packages_list_no_dotdir(root):
    root.mkdir(".subdir").join("foo-1.0.zip").write("secret")
    go("/packages/")
    show()
    notfind("foo")
Ejemplo n.º 45
0
def test_simple_list_no_dotdir(root):
    root.mkdir(".subdir").join("foo-1.0.zip").write("secret")
    go("/simple/")
    show()
    notfind("foo")
Ejemplo n.º 46
0
    def test_homepage(self):
        from twill import commands as b

        b.find("July 1975")
        b.find("1975-12-06")
        b.notfind("New Albums")
Ejemplo n.º 47
0
def test_packages_list_no_dotdir(root):
    root.mkdir(".subdir").join("foo-1.0.zip").write("secret")
    go("/packages/")
    show()
    notfind("foo")
Ejemplo n.º 48
0
def test_simple_list_no_dotfiles(root):
    root.join(".foo-1.0.zip").write("secret")
    go("/simple/")
    notfind("foo")
Ejemplo n.º 49
0
def test():
    url = twilltestlib.get_url()

    # capture output
    fp = StringIO()
    twill.set_output(fp)

    twill.parse.execute_string('code 200', initial_url=url)

    # from file
    twilltestlib.execute_twill_script('test-go.twill', initial_url=url)

    twill.set_output(None)
    assert fp.getvalue()

    ###

    # from stdin
    filename = os.path.join(twilltestlib.testdir, 'test-go.twill')
    old_in, sys.stdin = sys.stdin, open(filename)
    try:
        twilltestlib.execute_twill_script('-', initial_url=url)
    finally:
        sys.stdin = old_in

    # from parse.execute_file
    twill.parse.execute_file('test-go-exit.twill', initial_url=url)
    
    # also test some failures.

    old_err, sys.stderr = sys.stderr, StringIO()
    try:
        twill.set_errout(sys.stderr)
        #
        # failed assert in a script
        #
        try:
            twill.parse.execute_file('test-go-fail.twill', initial_url=url)
            assert 0
        except TwillAssertionError:
            pass

        commands.go(url)
        try:
            commands.code(400)
            assert 0
        except TwillAssertionError:
            pass

        #
        # no such command (NameError)
        #

        try:
            twill.parse.execute_file('test-go-fail2.twill', initial_url=url)
            assert 0
        except TwillNameError, e:
            pass
    finally:
        sys.stderr = old_err

    namespaces.new_local_dict()
    gd, ld = namespaces.get_twill_glocals()

    commands.go(url)
    try:
        twill.parse.execute_command('url', ('not this',), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.follow('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.find('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.notfind('Hello')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        twill.parse.execute_command('exit', ('0',), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except SystemExit:
        pass