예제 #1
0
 def testStaticCache(self):
     s = WebClient('http://127.0.0.1:8000/welcome/')
     s.get('static/js/web2py.js')
     assert('expires' not in s.headers)
     assert(not s.headers['cache-control'].startswith('max-age'))
     text = s.text
     s.get('static/_1.2.3/js/web2py.js')
     assert(text == s.text)
     assert('expires' in s.headers)
     assert(s.headers['cache-control'].startswith('max-age'))
예제 #2
0
def startwebserver():
    global webserverprocess
    path = path = os.path.dirname(os.path.abspath(__file__))
    if not os.path.isfile(os.path.join(path, 'web2py.py')):
        i = 0
        while i < 10:
            i += 1
            if os.path.exists(os.path.join(path, 'web2py.py')):
                break
            path = os.path.abspath(os.path.join(path, '..'))
    web2py_exec = os.path.join(path, 'web2py.py')
    webserverprocess = subprocess.Popen([sys.executable, web2py_exec, '-a',  'testpass'])
    print 'Sleeping before web2py starts...'
    for a in range(1, 11):
        time.sleep(1)
        print a, '...'
        try:
            c = WebClient('http://127.0.0.1:8000')
            c.get('/')
            break
        except:
            continue
    print ''
예제 #3
0
def startwebserver():
    global webserverprocess
    path = path = os.path.dirname(os.path.abspath(__file__))
    if not os.path.isfile(os.path.join(path, 'web2py.py')):
        i = 0
        while i < 10:
            i += 1
            if os.path.exists(os.path.join(path, 'web2py.py')):
                break
            path = os.path.abspath(os.path.join(path, '..'))
    web2py_exec = os.path.join(path, 'web2py.py')
    webserverprocess = subprocess.Popen(
        [sys.executable, web2py_exec, '-a', 'testpass'])
    print 'Sleeping before web2py starts...'
    for a in range(1, 11):
        time.sleep(1)
        print a, '...'
        try:
            c = WebClient('http://127.0.0.1:8000')
            c.get('/')
            break
        except:
            continue
    print ''
예제 #4
0
 def testStaticCache(self):
     s = WebClient('http://127.0.0.1:8000/welcome/')
     s.get('static/js/web2py.js')
     assert ('expires' not in s.headers)
     assert (not s.headers['cache-control'].startswith('max-age'))
     text = s.text
     s.get('static/_1.2.3/js/web2py.js')
     assert (text == s.text)
     assert ('expires' in s.headers)
     assert (s.headers['cache-control'].startswith('max-age'))
예제 #5
0
    def testRegisterAndLogin(self):
        client = WebClient('http://127.0.0.1:8000/welcome/default/')

        client.get('index')

        # register
        data = dict(first_name='Homer',
                    last_name='Simpson',
                    email='*****@*****.**',
                    password='******',
                    password_two='test',
                    _formname='register')
        client.post('user/register', data=data)

        # logout
        client.get('user/logout')

        # login again
        data = dict(email='*****@*****.**',
                    password='******',
                    _formname='login')
        client.post('user/login', data=data)
        self.assertTrue('Welcome Homer' in client.text)

        # check registration and login were successful
        client.get('index')

        # COMMENTED BECAUSE FAILS BUT WHY?
        self.assertTrue('Welcome Homer' in client.text)

        client = WebClient('http://127.0.0.1:8000/admin/default/')
        client.post('index', data=dict(password='******'))
        client.get('site')
        client.get('design/welcome')
예제 #6
0
class TestWeb(LiveTest):
    def testRegisterAndLogin(self):
        client = WebClient('http://127.0.0.1:8000/welcome/default/')

        client.get('index')

        # register
        data = dict(first_name='Homer',
                    last_name='Simpson',
                    email='*****@*****.**',
                    password='******',
                    password_two='test',
                    _formname='register')
        client.post('user/register', data=data)

        # logout
        client.get('user/logout')

        # login again
        data = dict(email='*****@*****.**',
                    password='******',
                    _formname='login')
        client.post('user/login', data=data)
        self.assertTrue('Welcome Homer' in client.text)

        # check registration and login were successful
        client.get('index')

        # COMMENTED BECAUSE FAILS BUT WHY?
        self.assertTrue('Welcome Homer' in client.text)

        client = WebClient('http://127.0.0.1:8000/admin/default/')
        client.post('index', data=dict(password='******'))
        client.get('site')
        client.get('design/welcome')

    def testStaticCache(self):
        s = WebClient('http://127.0.0.1:8000/welcome/')
        s.get('static/js/web2py.js')
        assert ('expires' not in s.headers)
        assert (not s.headers['cache-control'].startswith('max-age'))
        text = s.text
        s.get('static/_1.2.3/js/web2py.js')
        assert (text == s.text)
        assert ('expires' in s.headers)
        assert (s.headers['cache-control'].startswith('max-age'))

    def testSoap(self):
        # test soap server implementation
        from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault
        url = 'http://127.0.0.1:8000/examples/soap_examples/call/soap?WSDL'
        client = SoapClient(wsdl=url)
        ret = client.SubIntegers(a=3, b=2)
        # check that the value returned is ok
        assert ('SubResult' in ret)
        assert (ret['SubResult'] == 1)

        try:
            ret = client.Division(a=3, b=0)
        except SoapFault, sf:
            # verify the exception value is ok
            # assert(sf.faultstring == "float division by zero") # true only in 2.7
            assert (sf.faultcode == "Server.ZeroDivisionError")

        # store sent and received xml for low level test
        xml_request = client.xml_request
        xml_response = client.xml_response

        # do a low level raw soap request (using
        s = WebClient('http://127.0.0.1:8000/')
        try:
            s.post('examples/soap_examples/call/soap',
                   data=xml_request,
                   method="POST")
        except HTTPError, e:
            assert (e.msg == 'INTERNAL SERVER ERROR')
예제 #7
0
    def testRegisterAndLogin(self):
        client = WebClient('http://127.0.0.1:8000/welcome/default/')

        client.get('index')

        # register
        data = dict(first_name='Homer',
                    last_name='Simpson',
                    email='*****@*****.**',
                    password='******',
                    password_two='test',
                    _formname='register')
        client.post('user/register', data=data)

        # logout
        client.get('user/logout')

        # login again
        data = dict(email='*****@*****.**',
                    password='******',
                    _formname='login')
        client.post('user/login', data=data)
        self.assertTrue('Welcome Homer' in client.text)

        # check registration and login were successful
        client.get('index')

        self.assertTrue('Welcome Homer' in client.text)

        client = WebClient('http://127.0.0.1:8000/admin/default/')
        client.post('index', data=dict(password='******'))
        client.get('site')
        client.get('design/welcome')