Example #1
0
File: tests.py Project: za/wsgi-101
    def test_not_found(self):
        environ = {
            'PATH_INFO' : '/something',
        }

        response = application(environ, start_response)
        self.assertTrue('Not Found' in "".join(response))
Example #2
0
def init(mode = ""):
    logger.debug("Initializing...")
    app = main.application()
    registry.setValue("application", app)
    
    error = None
    try:
        isfunc = eval("type(app." + mode + "Action)")
    except:
        isfunc = ""
        pass
    
    if (mode != "" and str(isfunc) == "<type 'instancemethod'>"):
        registry.setValue("mode", mode)
        error = eval("app." + mode + "Action()")
    else:
        registry.setValue("mode", "main")
        error = app.mainAction()
    
    if (error is not None):
        logger.logException(error)
    
    # Destroy window event
    try:
        eval("app.destroy()")
    except:
        pass
    
    return False
Example #3
0
def test_wrapper(environ, start_response):
    environ['ADFS_PERSONID'] = '0'
    environ['ADFS_LOGIN'] = 'Tester'
    environ['ADFS_EMAIL'] = '[email protected]'
    environ['ADFS_FULLNAME'] = 'Konstantin Nikitin'
    for chunk in main.application(environ, start_response):
        yield chunk
def application(environ,start_response):
    path = environ['PATH_INFO']
    if path == '/set/set_account_number':
        return main.application(environ,start_response)
    elif path == '/log_in':
        start_response('200 OK', [('Content-Type', 'text/html')])
        return main.log_in(environ,start_response)
    elif path == '/my_thoughts':
        return main.post_my_thoughts(environ,start_response)
    elif path == '/get_my_thoughts':
        return main.get_my_thoughts(environ,start_response)
    elif path == '/focus':
        return main.focus(environ,start_response)
    elif path == '/transmit':
        return main.transmit(environ,start_response)
    elif path == '/collect':
        return main.collect(environ,start_response)
    elif path == '/check_focus':
        return main.check_focus(environ,start_response)
    elif path == '/check_person':
        return main.check_person(environ,start_response)
    elif path == '/post_comment':
        return main.post_comment(environ,start_response)
    elif path == '/comment':
        return main.check_comment(environ,start_response)
Example #5
0
File: tests.py Project: za/wsgi-101
    def test_hello_zaki(self):
        environ = {
            'PATH_INFO' : '/hello/zaki',
        }

        response = application(environ, start_response)
        self.assertTrue('Hello zaki' in "".join(response))
Example #6
0
File: tests.py Project: za/wsgi-101
    def test_root_path(self):
        environ = {
            'PATH_INFO' : '/',
        }

        response = application(environ, start_response)
        self.assertTrue('Hello World Application' in "".join(response))
Example #7
0
    def setUp(self):
        self.app = TestApp(application())
        self.testbed = testbed.Testbed()
        self.testbed.setup_env(auth_domain="testbed")
        self.authenticate("123", "[email protected]", admin=True)

        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_user_stub()
Example #8
0
 def setUp(self):
             
     self.app = TestApp(application())
     apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
     apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub())
     apiproxy_stub_map.apiproxy.RegisterStub('user', user_service_stub.UserServiceStub())
     apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', urlfetch_stub.URLFetchServiceStub())
     apiproxy_stub_map.apiproxy.RegisterStub('memcache', memcache_stub.MemcacheServiceStub())        
     stub = datastore_file_stub.DatastoreFileStub('temp', '/dev/null', '/dev/null')
     apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)
     
     os.environ['APPLICATION_ID'] = "temp"
Example #9
0
    def setUp(self):
        os.environ['SERVER_NAME'] = 'localhost'
        os.environ['SERVER_PORT'] = '8080'
        os.environ['AUTH_DOMAIN'] = 'example.org'
        os.environ['USER_EMAIL'] = ''
        os.environ['USER_ID'] = ''

        self.SAMPLE = '{"intensity":0.3898000121116638,' \
                      '"created":1256423837200,' \
                      '"emotion":0.31779998540878296,' \
                      '"scheduled":0,"comment":""}'

        self.app = webtest.TestApp(application())
        self.clear_datastore()
Example #10
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from webtest import TestApp
from main import application
from nose.tools import *

app = TestApp(application())


def test_index():
    res = app.get('/')
    assert_equal('200 OK', res.status)


def test_index_post():
    res = app.post('/', {'name': 'username'})
    assert_equal('302 Moved Temporarily', res.status)


def test_mmcrss():
    pass
    #res = app.get('/test')
    #assert_equal('200 OK', res.status)
Example #11
0
    def test_get_when_task_is_none(self):
        app = TestApp(application())
        response = app.get('/task')

        eq_('200 OK', response.status)
        ok_('no task' in str(response))
Example #12
0
 def setUp(self):
     self.app = TestApp(application())
     reset_counter()
Example #13
0
    def test_get(self):
        app = TestApp(application())
        response = app.get('/search')

        eq_('200 OK', response.status)
Example #14
0
    def test_get(self):
        app = TestApp(application())
        response = app.get('/')

        eq_('200 OK', response.status)
        ok_('MainHandler', str(response))
# MOCK start_response
is_start_response_call = False
start_response_status = None
start_response_headers = None


def mock_start_response(status, headers):
    global is_start_response_call
    global start_response_headers, start_response_status
    is_start_response_call = True
    start_response_status = status
    start_response_headers = headers

# IMPORT APP
from main import application

# INITIALIZE
if PY3:
    application = wsgiref.validate.validator(application)
result = application(mock_environ, mock_start_response)

# ASSERTS
assert isinstance(result, Iterable), "application() return isn't iterable obj"
assert is_start_response_call, "start_response isn't called"
assert start_response_status == "200 OK", "start_response status != '200 OK'"

# tearDown
if hasattr(result, 'close'):
    result.close()
Example #16
0
 
from google.appengine.tools import dev_appserver
from google.appengine.tools.dev_appserver_main import *
 
option_dict = DEFAULT_ARGS.copy()
option_dict[ARG_CLEAR_DATASTORE] = True
 
config, matcher = dev_appserver.LoadAppConfig(".", {})
dev_appserver.SetupStubs(config.application, **option_dict)
 
import main
reload(main)
 
from webtest import TestApp
SAFARI4_UA = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"
app = TestApp(main.application(), extra_environ={"HTTP_USER_AGENT": SAFARI4_UA})
 
from lxml import etree
from StringIO import StringIO
 
def parseResponse(response):
  parser = etree.HTMLParser()
  return etree.parse(StringIO(response.body), parser)

#
#import bikejibe.model
#reload(bikejibe.model)
# 
#from bikejibe.model import *

Example #17
0
 def setUp(self):
     clear_datastore()
     self.app = TestApp(application())