Here how I realize it :
# Production
if request.env.web2py_path.split('/')[2] == 'www-data' and
request.application == 'app_name':
# print 'Prod...'
db = DAL('postgres://username_prod:[email protected]:5432/dbname',
pool_size=1,
migrate_enabled=False,
lazy_tables=True)
# Systeme under test
elif web2pytest.is_running_under_test(request, request.application):
# print 'Testing mode...'
# When running under test, db cannot be ':memory:'
# because it is recreated in each request and a webclient test
# can make many requests to validate a single scenario.
db = DAL('postgres://username:password&@127.0.0.1:5432/testing_dbname',
migrate_enabled=False,
lazy_tables=True
)
# Normal dev operation
elif request.env.web2py_path.split('/')[2] == 'username' and
request.application.startswith('dbname'):
# print 'Dev mode...'
db = DAL('postgres://
username:password&@127.0.0.1:5432/dbname_dev_from_prod_2015_01_25',
migrate_enabled=False,
lazy_tables=True
)
# Prod DEMO Application
elif request.env.web2py_path.split('/')[2] == 'www-data' and
request.application == 'dbname_demo':
# print 'Prod demo...'
db = DAL('postgres://username_prod:[email protected]:5432/dbname_demo',
pool_size=1,
migrate_enabled=False,
lazy_tables=True)
Richard
On Wed, Aug 10, 2016 at 11:32 AM, Mirek Zvolský <[email protected]> wrote:
> Thank you.
> I have found this inside:
>
> def is_running_under_test(request, appname):
> if request.get('_running_under_test') or testfile_exists(appname):
> return True
> else:
> return False
>
> But I am not sure what mean both parts of the condition.
>
> I think this run on the TESTED machine, so 2nd part - testfile_exists()
> will cause (I think) that such machine cannot serve non-test requests at
> same time.
>
> So I think more important is the 1st part - request.get('_running_under_
> test')
> But how will I set from the TESTING machine request,_running_under_test on
> the TESTED machine?
>
>
>
>
> Dne středa 27. července 2016 16:18:34 UTC+2 Richard napsal(a):
>>
>> Hello Mirek,
>>
>> Did you give a look at how web2py.test is doing that?
>>
>> Bassically, a folder is created with the name of the app when at tests
>> launch if the folder is there the testing database is used...
>>
>> Richard
>>
>> On Tue, Jul 26, 2016 at 6:24 AM, Mirek Zvolský <[email protected]> wrote:
>>
>>> Finally I realized it using
>>>
>>> session.testing = False / True
>>>
>>> Because I think the resulting plugin_splinter is interesting (for
>>> somebody),
>>> I hope I will publish it and write more later.
>>>
>>>
>>>
>>>
>>>
>>>
>>> Dne pondělí 18. července 2016 11:55:57 UTC+2 Mirek Zvolský napsal(a):
>>>>
>>>> 1.
>>>>
>>>> I use postgres database dbapp
>>>> I am trying to make splinter tests and want to run them over the 2nd
>>>> database dbapp_tests.
>>>>
>>>> When I switch to the testing database (which is EMPTY include the
>>>> auth_user table)
>>>> I am logged in thanks the session:
>>>> auth.user and auth.user_id are both set (but auth_user is EMPTY).
>>>>
>>>> Can I avoid this, without deleting sessions for the normal work?
>>>>
>>>>
>>>>
>>>> I have ideas for some workarounds, like:
>>>>
>>>> - populate dbapp_tests with single auth_user row (mine...)
>>>>
>>>> - move sessions into database
>>>>
>>>>
>>>>
>>>> But I'm asking, if somebody has idea how to switch both databases more
>>>> clever.
>>>> Thank you...
>>>>
>>>>
>>>> 2.
>>>>
>>>> I have no good idea how to easy switch between normal and testing
>>>> database.
>>>> At this time I use port (8000/8001), but this works on development, not
>>>> on production.
>>>> What is better?
>>>>
>>>> --
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.