Guys,

What are the steps i need to take to be able to run tests while using GAE?

Do you want me to to create an issue?



On Sunday, October 13, 2013 3:14:46 PM UTC+2, Quint wrote:
>
> That indeed had something to do with it.
> After i changed it to this:
>
> db = DAL('google:datastore')
> session.connect(request, response, db=db)
>
> I got this error:
>
> Traceback (most recent call last):
>   File "X:\GAE\*******\tests\test_fragments.py", line 25, in setUp
>     exec_environment('applications/init/models/db.py')
>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\shell.py",
>  line 93, in exec_environment
>     execfile(pyfile, env)
>   File "applications/init/models/db.py", line 30, in <module>
>     session.connect(request, response, db=db)
>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\globals.py
> ", line 730, in connect
>     response.session_id_name = 'session_id_%s' % masterapp.lower()
> AttributeError: 'NoneType' object has no attribute 'lower'
>
> After i removed this line
>
> session.connect(request, response, db=db)
>
> I get this:
>
> Traceback (most recent call last):
>   File "X:\GAE\*******\tests\test_fragments.py", line 25, in setUp
>     exec_environment('applications/init/models/db.py')
>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\shell.py",
>  line 93, in exec_environment
>     execfile(pyfile, env)
>   File "applications/init/models/db.py", line 34, in <module>
>     auth = Auth(db)                      # authentication/authorization
>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\tools.py",
>  line 1144, in __init__
>     request = current.request
> AttributeError: 'thread._local' object has no attribute 'request'
>
> There is no request object?
>
>
> On Sunday, October 13, 2013 2:51:35 PM UTC+2, Niphlod wrote:
>>
>> I think that that's a problem on how by default web2py recognize a GAE 
>> environment. If I'm right, you didn't change at all the db.py lines that do 
>> something like this
>>
>> if not request.env.web2py_runtime_gae:
>>     ## if NOT running on Google App Engine use SQLite or other DB
>>     db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>> else:
>>     ## connect to Google BigTable (optional 'google:datastore://namespace')
>>     db = DAL('google:datastore')
>>
>>
>> I think that you run your tests where request.env.web2py_runtime_gae is 
>> False. To confirm this, strip that part and just use
>>
>> db = DAL('google:datastore')
>>
>> On Sunday, October 13, 2013 2:35:14 PM UTC+2, Quint wrote:
>>>
>>> Hi,
>>>
>>> I am trying to create a test for one of my modules.
>>> This module depends on several global variables like "Resonse" and some 
>>> extra things i store in current from one of my Models. (current.myapp.*** ).
>>> So to be able to run the test i need to execute some of the models like 
>>> this. (Is this the correct way?)
>>> (The testbed stuff is for GAE to create stubs for GAE services)
>>>
>>> def setUp (self):
>>>         self.testbed = testbed.Testbed()
>>>         self.testbed.activate()
>>>         self.testbed.init_datastore_v3_stub()
>>>         self.testbed.init_memcache_stub()
>>>         exec_environment('applications/init/models/0.py')
>>>         exec_environment('applications/init/models/db.py')
>>>
>>> I am using GAE with web2py 2.6.4 source and Python 2.7.3
>>>
>>> Now when i run the test i get this error:
>>>
>>> No handlers could be found for logger "web2py"
>>> DEBUG: connect attempt 0, connection error:
>>> Traceback (most recent call last):
>>>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\dal.py", l
>>> ine 7854, in __init__
>>>     self._adapter = ADAPTERS[self._dbname](**kwargs)
>>>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\dal.py", l
>>> ine 2288, in __init__
>>>     if do_connect: self.find_driver(adapter_args)
>>>   File "C:\Users\Quint\Documents\Projects\GAE\*******\gluon\dal.py", l
>>> ine 791, in find_driver
>>>     raise RuntimeError("no driver available %s" % str(self.drivers))
>>> RuntimeError: no driver available ('sqlite2', 'sqlite3')
>>>
>>> So it looks like DAL is instantiated and by default it tries to connect 
>>> to sqlite?
>>>
>>> What can i do about this?
>>>
>>> BTW when i try to start the web2py shell i get a similar error only now 
>>> i says that it find a "google" driver:
>>>
>>> No handlers could be found for logger "web2py"
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2013
>>> Version 2.6.4-stable+timestamp.2013.09.22.01.43.37
>>> Database drivers available: google
>>> DEBUG: connect attempt 0, connection error:
>>> Traceback (most recent call last):
>>>   File "X:\GAE\*******\gluon\dal.py", line 7854, in __init__
>>>     self._adapter = ADAPTERS[self._dbname](**kwargs)
>>>   File "X:\GAE\*******\gluon\dal.py", line 2288, in __init__
>>>     if do_connect: self.find_driver(adapter_args)
>>>   File "X:\GAE\*******\gluon\dal.py", line 791, in find_driver
>>>     raise RuntimeError("no driver available %s" % str(self.drivers))
>>> RuntimeError: no driver available ('sqlite2', 'sqlite3')
>>>
>>> Thanks!
>>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to