Пример #1
0
def test():
    url = twilltestlib.get_url()

    # test empty page get_title
    namespaces.new_local_dict()
    twill.commands.reset_browser()
    browser = twill.get_browser()
    try:
        browser.get_title()
        assert 0, "should never get here"
    except TwillException:
        pass

    ### now test a few special cases

    commands.go(url)
    commands.go('/login')

    # test no matching forms
    try:
        commands.fv('2', 'submit', '1')
        assert 0
    except TwillAssertionError:
        pass

    # test regexp match
    commands.fv('1', '.*you', '1')

    # test ambiguous match to value
    commands.go('/testform')
    commands.fv('1', 'selecttest', 'val')
    commands.fv('1', 'selecttest', 'value1')
    commands.fv('1', 'selecttest', 'selvalue1')
    commands.formclear('1')
    commands.showforms()
    try:
        commands.fv('1', 'selecttest', 'value')
        assert 0
    except TwillException:
        pass

    # test ambiguous match to name
    commands.go('/testform')
    try:
        commands.fv('1', 'item_', 'value')
        assert 0
    except Exception:
        pass

    try:
        commands.formfile('1', 'selecttest', 'null')
        assert 0
    except Exception:
        pass

    commands.go('http://www.google.com/')
    browser.get_title()

    # test the twill script.
    twilltestlib.execute_twill_script('test-form.twill', initial_url=url)
Пример #2
0
    def test_login_account(self):
        with self.twill as t:
            url = self.twill.url("/login")
            twilltestlib.execute_twill_script('tests/login.twill',
                                              initial_url=url)
            self.assertStatus(self.client.get("/account"), 200)

            initial_url = self.twill.url("/")
            twilltestlib.execute_twill_script('tests/logout.twill',
                                              initial_url=initial_url)
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-dollar-notation-non-strings.twill', initial_url=url)
Пример #4
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
Пример #5
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-http-codes.twill', initial_url=url)
Пример #6
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
Пример #7
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script("test-equiv-refresh.twill", initial_url=url)
Пример #8
0
def test():
    url = twilltestlib.get_url()
    twilltestlib.execute_twill_script('test-info.twill', initial_url=url)
Пример #9
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-find.twill', initial_url=url)
Пример #10
0
 def test_create_account(self):
     with self.twill as t:
         url = self.twill.url("/register/account")
         twilltestlib.execute_twill_script('tests/register.twill',
                                           initial_url=url)
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-non-string-in-fv-echo.twill', initial_url=url)
Пример #12
0
def test():
    inp = "unique1\nunique2\n"
    
    twilltestlib.execute_twill_script('test-basic.twill', inp, initial_url=url)
Пример #13
0
def test():
   url = twilltestlib.get_url()

   if not no_dns_python:
       twilltestlib.execute_twill_script('test-dns.twill', initial_url=url)
Пример #14
0
def test():
    url = twilltestlib.get_url()

    if not no_dns_python:
        twilltestlib.execute_twill_script('test-dns.twill', initial_url=url)
Пример #15
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-http-codes.twill', initial_url=url)
Пример #16
0
def test():
    url = twilltestlib.get_url()
            
    # test empty page get_title
    namespaces.new_local_dict()
    twill.commands.reset_browser()
    browser = twill.get_browser()
    try:
        browser.get_title()
        assert 0, "should never get here"
    except BrowserStateError:
        pass

    ### now test a few special cases
    
    commands.go(url)
    commands.go('/login')
    commands.showforms()

    # test no matching forms
    try:
        commands.fv('2', 'submit', '1')
        assert 0
    except TwillAssertionError:
        pass

    # test regexp match
    commands.fv('1', '.*you', '1')


    # test ambiguous match to value
    commands.go('/testform')
    commands.fv('1', 'selecttest', 'val')
    commands.fv('1', 'selecttest', 'value1')
    commands.fv('1', 'selecttest', 'selvalue1')
    commands.formclear('1')
    try:
        commands.fv('1', 'selecttest', 'value')
        assert 0
    except ClientForm.ItemNotFoundError:
        pass

    # test ambiguous match to name
    commands.go('/testform')
    try:
        commands.fv('1', 'item_', 'value')
        assert 0
    except Exception:
        pass

    try:
        commands.formfile('1', 'selecttest', 'null')
        assert 0
    except Exception:
        pass

    commands.go('http://www.google.com/')
    browser.get_title()

    # test the twill script.
    twilltestlib.execute_twill_script('test-form.twill', initial_url=url)
Пример #17
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-equiv-refresh.twill',
                                      initial_url=url)
Пример #18
0
def test():
    """
    Test the 'formfill' extension stuff.
    """
    url = twilltestlib.get_url()
    twilltestlib.execute_twill_script('test-formfill.twill', initial_url=url)
Пример #19
0
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-find-xpath.twill', initial_url=url)
Пример #20
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-global-form.twill',
                                      initial_url=url)
Пример #21
0
def test():
    inp = "unique1\nunique2\n"

    twilltestlib.execute_twill_script('test-basic.twill', inp, initial_url=url)