def start_app(): import gc gc.collect() try: from main import application application() except Exception as e: print(str(e)) write_error(e) import machine machine.reset()
def test_hello_zaki(self): environ = { 'PATH_INFO' : '/hello/zaki', } response = application(environ, start_response) self.assertTrue('Hello zaki' in "".join(response))
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
def test_not_found(self): environ = { 'PATH_INFO' : '/something', } response = application(environ, start_response) self.assertTrue('Not Found' in "".join(response))
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)
def test_wrapper(environ, start_response): environ['ADFS_PERSONID'] = '0' environ['ADFS_LOGIN'] = '******' environ['ADFS_EMAIL'] = '*****@*****.**' environ['ADFS_FULLNAME'] = 'Konstantin Nikitin' for chunk in main.application(environ, start_response): yield chunk
def test_root_path(self): environ = { 'PATH_INFO' : '/', } response = application(environ, start_response) self.assertTrue('Hello World Application' in "".join(response))
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()
def setUp(self): # First, create an instance of the Testbed class. self.testbed = Testbed() # Then activate the testbed, which prepares the service stubs for use. self.testbed.activate() # Next, declare which service stubs you want to use. #self.testbed.init_datastore_v3_stub() self.testbed.init_memcache_stub() self.testapp = webtest.TestApp(application()) self.testapi = service
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"
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()
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"
#!/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)
def setUp(self): self.app = TestApp(application()) reset_counter()
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))
def test_get(self): app = TestApp(application()) response = app.get('/search') eq_('200 OK', response.status)
def test_get(self): app = TestApp(application()) response = app.get('/') eq_('200 OK', response.status) ok_('MainHandler', str(response))
from webtest import TestApp from main import application, ProtectedResourceHandler from oauth.models import OAuth_Client from google.appengine.api import apiproxy_stub_map, datastore_file_stub app = TestApp(application()) # clear datastore apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map['datastore_v3'].Clear() # set up test client client = OAuth_Client(name='test') client.put() def test_protected_resource_fail_naked(): response = app.get('/protected/resource', status=400) assert not ProtectedResourceHandler.SECRET_PAYLOAD in str(response) def test_protected_resource_success_flow(): response = app.post( '/oauth/token', dict( grant_type='password', username='******', password='******', client_id=client.client_id, client_secret=client.client_secret, scope='read', ))
""" @author miguelCabrera1001 | @date 3/01/20 @project @name run """ from main import create_app as application if __name__ == '__main__': application().run()
# 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()
def setUp(self): clear_datastore() self.app = TestApp(application())
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 *