Re: [web2py] Unit testing apis

2018-03-08 Thread Kevin Huang
Thanks all for the replies,

I was able to go to gluon.globals and get the HTTP 400 error to show what 
the problem was, turns out the request was still sending args and vars from 
the previous test.

Oddly enough, clearing the request variables and arguments (setting them to 
[] for instance) was able to solve the problem of getting the API calls to 
not have any more bad arguments.

I still am not sure how to start fresh (or perfectly reset) the request 
variables though, it seems that declaring

request = Request(env=[])

in setUp() does seem to work as I thought it would.



As a sidenote, thanks all for the recommendation for py2test, I'll take a 
look at it going forward, although I have a suspicion it wouldn't address 
my issue straight on.

>
>

-- 
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/d/optout.


Re: [web2py] Unit testing apis

2018-03-07 Thread Richard Vézina
I do have customized web2py.test while integrating some of welcome_enhanced
stuff like using splinter api for conducting testing + create a test
launcher to save some boiler plate initialization... I just don't have time
to exectract it form my own app and publish it... It rely on pytest... It
gear around system testing more than unit testing though...

On Wed, Mar 7, 2018 at 1:12 PM, Yoel Benítez Fonseca 
wrote:

> idk if that is the right way... i'm using this approach in on of my
> projects and at the moment the only problem i have is with the memory usage
> or the slow access with a file base sqlite database for the tests.
>
>
> On Wed, Mar 7, 2018 at 1:08 PM, António Ramos 
> wrote:
>
>> Next chapter in web2py book
>>
>> Pytest your app the right way
>>
>> 2018-03-07 18:02 GMT+00:00 Yoel Benítez Fonseca :
>>
>>> H!
>>>
>>> checkout: https://github.com/viniciusban/web2py.test
>>>
>>>
>>>
>>> On Wed, Mar 7, 2018 at 10:10 AM, Kevin Huang  wrote:
>>>

 Hi all,


 I'm relatively new to web2py, and still trying to find more resources,
 but i've hit a wall, and I'm not quite sure on this issue I'm working with:


 So working with the "guide" from http://web2py.com/AlterEgo/def
 ault/show/260, I'm trying to create a few unit tests to test some
 RESTFUL api functions. However, while testing multiple test suites, it
 seems that the request information is carrying over somehow despite my
 attempts to make sure that I start with a new request object via setUp each
 time.

 The tests will run just fine if they're alone in the suite, but running
 some of them after the other I was running into HTTP 400 errors and during
 debugging I found out that the request data carrying over.

 Some "sample" code to illustrate what I was trying to do...

 import unittest
 from gluon.globals import Request

 # import api code
 execfile("applications/appname/controllers/app_api.py", globals())class


 # Test Put api
 TestPutAPI(unittest.TestCase):

  def setUp(self):
request = Request(env=[])  # new request, env must be set.

  def test_some_function(self):
request.vars['var1'] = 1
request.vars['var2'] = 2
request.env.request_method = 'PUT'
response = api() # call api

self.assertEquals(response['result'], 'success')

   def tearDown(self):
db.table.truncate()  # clean up db (nothing request related here)


 # Test Post api
 TestPostAPI(unittest.TestCase):

  def setUp(self):
request = Request(env=[])  # new request

  def test_some_function(self):
request.vars['var5'] = "asdf"
request.vars['var6'] = 6
request.env.request_method = 'POST'
response = api() # call api

self.assertEquals(response['result'], 'success')

  def tearDown(self):
db.table.truncate()  # clean up db (nothing request related here)


 # Run tests
 suite = unittest.TestSuite()
 suite.addTest(unittest.makeSuite(TestPutAPI))
 suite.addTest(unittest.makeSuite(TestPostAPI))

 unittest.TextTestRunner(verbosity=2).run(suite)


 Is my entire approach to unit testing wrong? I know there's a lot a
 mention of doctests being recommended, also that the line request =
 Request() recommended by the original article also being wrong (or simply
 out of date), but I'm also unsure of how the request and api call is being
 processed in this scenario. Earlier I tried doing 2 calls to the same api
 in one test function and found that web2py (and this unittest) simply could
 not overwrite the request function - if that made any sense (it didn't, and
 didn't work).

 Anyone have any pointers?

 Thank you,
 KH


 --
 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/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 web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> Resources:
>> - http://web2py.com
>>

Re: [web2py] Unit testing apis

2018-03-07 Thread Yoel Benítez Fonseca
idk if that is the right way... i'm using this approach in on of my 
projects and at the moment the only problem i have is with the memory 
usage or the slow access with a file base sqlite database for the tests.


On Wed, Mar 7, 2018 at 1:08 PM, António Ramos  
wrote:

Next chapter in web2py book

Pytest your app the right way

2018-03-07 18:02 GMT+00:00 Yoel Benítez Fonseca 
:

H!

checkout: https://github.com/viniciusban/web2py.test



On Wed, Mar 7, 2018 at 10:10 AM, Kevin Huang  
wrote:


Hi all,


I'm relatively new to web2py, and still trying to find more 
resources, but i've hit a wall, and I'm not quite sure on this 
issue I'm working with:



So working with the "guide" from 
http://web2py.com/AlterEgo/default/show/260, I'm trying to create a 
few unit tests to test some RESTFUL api functions. However, while 
testing multiple test suites, it seems that the request information 
is carrying over somehow despite my attempts to make sure that I 
start with a new request object via setUp each time.


The tests will run just fine if they're alone in the suite, but 
running some of them after the other I was running into HTTP 400 
errors and during debugging I found out that the request data 
carrying over.


Some "sample" code to illustrate what I was trying to do...

import unittest
from gluon.globals import Request

# import api code
execfile("applications/appname/controllers/app_api.py", 
globals())class



# Test Put api
TestPutAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request, env must be set.

 def test_some_function(self):
   request.vars['var1'] = 1
   request.vars['var2'] = 2
   request.env.request_method = 'PUT'
   response = api() # call api

   self.assertEquals(response['result'], 'success')

  def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Test Post api
TestPostAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request

 def test_some_function(self):
   request.vars['var5'] = "asdf"
   request.vars['var6'] = 6
   request.env.request_method = 'POST'
   response = api() # call api

   self.assertEquals(response['result'], 'success')

 def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Run tests
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPutAPI))
suite.addTest(unittest.makeSuite(TestPostAPI))

unittest.TextTestRunner(verbosity=2).run(suite)


Is my entire approach to unit testing wrong? I know there's a lot a 
mention of doctests being recommended, also that the line request = 
Request() recommended by the original article also being wrong (or 
simply out of date), but I'm also unsure of how the request and api 
call is being processed in this scenario. Earlier I tried doing 2 
calls to the same api in one test function and found that web2py 
(and this unittest) simply could not overwrite the request function 
- if that made any sense (it didn't, and didn't work).


Anyone have any pointers?

Thank you,
KH


--
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/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 web2py+unsubscr...@googlegroups.com.

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 web2py+unsubscr...@googlegroups.com.

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Unit testing apis

2018-03-07 Thread António Ramos
Next chapter in web2py book

*Pytest your app the right way*

2018-03-07 18:02 GMT+00:00 Yoel Benítez Fonseca :

> H!
>
> checkout: https://github.com/viniciusban/web2py.test
>
>
>
> On Wed, Mar 7, 2018 at 10:10 AM, Kevin Huang  wrote:
>
>>
>> Hi all,
>>
>>
>> I'm relatively new to web2py, and still trying to find more resources,
>> but i've hit a wall, and I'm not quite sure on this issue I'm working with:
>>
>>
>> So working with the "guide" from http://web2py.com/AlterEgo/def
>> ault/show/260, I'm trying to create a few unit tests to test some
>> RESTFUL api functions. However, while testing multiple test suites, it
>> seems that the request information is carrying over somehow despite my
>> attempts to make sure that I start with a new request object via setUp each
>> time.
>>
>> The tests will run just fine if they're alone in the suite, but running
>> some of them after the other I was running into HTTP 400 errors and during
>> debugging I found out that the request data carrying over.
>>
>> Some "sample" code to illustrate what I was trying to do...
>>
>> import unittest
>> from gluon.globals import Request
>>
>> # import api code
>> execfile("applications/appname/controllers/app_api.py", globals())class
>>
>>
>> # Test Put api
>> TestPutAPI(unittest.TestCase):
>>
>>  def setUp(self):
>>request = Request(env=[])  # new request, env must be set.
>>
>>  def test_some_function(self):
>>request.vars['var1'] = 1
>>request.vars['var2'] = 2
>>request.env.request_method = 'PUT'
>>response = api() # call api
>>
>>self.assertEquals(response['result'], 'success')
>>
>>   def tearDown(self):
>>db.table.truncate()  # clean up db (nothing request related here)
>>
>>
>> # Test Post api
>> TestPostAPI(unittest.TestCase):
>>
>>  def setUp(self):
>>request = Request(env=[])  # new request
>>
>>  def test_some_function(self):
>>request.vars['var5'] = "asdf"
>>request.vars['var6'] = 6
>>request.env.request_method = 'POST'
>>response = api() # call api
>>
>>self.assertEquals(response['result'], 'success')
>>
>>  def tearDown(self):
>>db.table.truncate()  # clean up db (nothing request related here)
>>
>>
>> # Run tests
>> suite = unittest.TestSuite()
>> suite.addTest(unittest.makeSuite(TestPutAPI))
>> suite.addTest(unittest.makeSuite(TestPostAPI))
>>
>> unittest.TextTestRunner(verbosity=2).run(suite)
>>
>>
>> Is my entire approach to unit testing wrong? I know there's a lot a
>> mention of doctests being recommended, also that the line request =
>> Request() recommended by the original article also being wrong (or simply
>> out of date), but I'm also unsure of how the request and api call is being
>> processed in this scenario. Earlier I tried doing 2 calls to the same api
>> in one test function and found that web2py (and this unittest) simply could
>> not overwrite the request function - if that made any sense (it didn't, and
>> didn't work).
>>
>> Anyone have any pointers?
>>
>> Thank you,
>> KH
>>
>>
>> --
>> 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/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 web2py+unsubscr...@googlegroups.com.
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Unit testing apis

2018-03-07 Thread Yoel Benítez Fonseca

H!

checkout: https://github.com/viniciusban/web2py.test


On Wed, Mar 7, 2018 at 10:10 AM, Kevin Huang  wrote:


Hi all,


I'm relatively new to web2py, and still trying to find more 
resources, but i've hit a wall, and I'm not quite sure on this issue 
I'm working with:



So working with the "guide" from 
http://web2py.com/AlterEgo/default/show/260, I'm trying to create a 
few unit tests to test some RESTFUL api functions. However, while 
testing multiple test suites, it seems that the request information 
is carrying over somehow despite my attempts to make sure that I 
start with a new request object via setUp each time.


The tests will run just fine if they're alone in the suite, but 
running some of them after the other I was running into HTTP 400 
errors and during debugging I found out that the request data 
carrying over.


Some "sample" code to illustrate what I was trying to do...

import unittest
from gluon.globals import Request

# import api code
execfile("applications/appname/controllers/app_api.py", 
globals())class



# Test Put api
TestPutAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request, env must be set.

 def test_some_function(self):
   request.vars['var1'] = 1
   request.vars['var2'] = 2
   request.env.request_method = 'PUT'
   response = api() # call api

   self.assertEquals(response['result'], 'success')

  def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Test Post api
TestPostAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request

 def test_some_function(self):
   request.vars['var5'] = "asdf"
   request.vars['var6'] = 6
   request.env.request_method = 'POST'
   response = api() # call api

   self.assertEquals(response['result'], 'success')

 def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Run tests
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPutAPI))
suite.addTest(unittest.makeSuite(TestPostAPI))

unittest.TextTestRunner(verbosity=2).run(suite)


Is my entire approach to unit testing wrong? I know there's a lot a 
mention of doctests being recommended, also that the line request = 
Request() recommended by the original article also being wrong (or 
simply out of date), but I'm also unsure of how the request and api 
call is being processed in this scenario. Earlier I tried doing 2 
calls to the same api in one test function and found that web2py (and 
this unittest) simply could not overwrite the request function - if 
that made any sense (it didn't, and didn't work).


Anyone have any pointers?

Thank you,
KH


--
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/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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Unit testing apis

2018-03-07 Thread António Ramos
Some discussion here
https://groups.google.com/forum/#!topic/web2py/4HdkjbnlhBU

There should be a link in web2py docs to suggest the best way to test.

Regards

2018-03-07 15:10 GMT+00:00 Kevin Huang :

>
> Hi all,
>
>
> I'm relatively new to web2py, and still trying to find more resources, but
> i've hit a wall, and I'm not quite sure on this issue I'm working with:
>
>
> So working with the "guide" from http://web2py.com/AlterEgo/
> default/show/260, I'm trying to create a few unit tests to test some
> RESTFUL api functions. However, while testing multiple test suites, it
> seems that the request information is carrying over somehow despite my
> attempts to make sure that I start with a new request object via setUp each
> time.
>
> The tests will run just fine if they're alone in the suite, but running
> some of them after the other I was running into HTTP 400 errors and during
> debugging I found out that the request data carrying over.
>
> Some "sample" code to illustrate what I was trying to do...
>
> import unittest
> from gluon.globals import Request
>
> # import api code
> execfile("applications/appname/controllers/app_api.py", globals())class
>
>
> # Test Put api
> TestPutAPI(unittest.TestCase):
>
>  def setUp(self):
>request = Request(env=[])  # new request, env must be set.
>
>  def test_some_function(self):
>request.vars['var1'] = 1
>request.vars['var2'] = 2
>request.env.request_method = 'PUT'
>response = api() # call api
>
>self.assertEquals(response['result'], 'success')
>
>   def tearDown(self):
>db.table.truncate()  # clean up db (nothing request related here)
>
>
> # Test Post api
> TestPostAPI(unittest.TestCase):
>
>  def setUp(self):
>request = Request(env=[])  # new request
>
>  def test_some_function(self):
>request.vars['var5'] = "asdf"
>request.vars['var6'] = 6
>request.env.request_method = 'POST'
>response = api() # call api
>
>self.assertEquals(response['result'], 'success')
>
>  def tearDown(self):
>db.table.truncate()  # clean up db (nothing request related here)
>
>
> # Run tests
> suite = unittest.TestSuite()
> suite.addTest(unittest.makeSuite(TestPutAPI))
> suite.addTest(unittest.makeSuite(TestPostAPI))
>
> unittest.TextTestRunner(verbosity=2).run(suite)
>
>
> Is my entire approach to unit testing wrong? I know there's a lot a
> mention of doctests being recommended, also that the line request =
> Request() recommended by the original article also being wrong (or simply
> out of date), but I'm also unsure of how the request and api call is being
> processed in this scenario. Earlier I tried doing 2 calls to the same api
> in one test function and found that web2py (and this unittest) simply could
> not overwrite the request function - if that made any sense (it didn't, and
> didn't work).
>
> Anyone have any pointers?
>
> Thank you,
> KH
>
>
> --
> 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/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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Unit testing apis

2018-03-07 Thread Kevin Huang

Hi all,


I'm relatively new to web2py, and still trying to find more resources, but 
i've hit a wall, and I'm not quite sure on this issue I'm working with:


So working with the "guide" from 
http://web2py.com/AlterEgo/default/show/260, I'm trying to create a few 
unit tests to test some RESTFUL api functions. However, while testing 
multiple test suites, it seems that the request information is carrying 
over somehow despite my attempts to make sure that I start with a new 
request object via setUp each time.

The tests will run just fine if they're alone in the suite, but running 
some of them after the other I was running into HTTP 400 errors and during 
debugging I found out that the request data carrying over.

Some "sample" code to illustrate what I was trying to do...

import unittest
from gluon.globals import Request

# import api code
execfile("applications/appname/controllers/app_api.py", globals())class 


# Test Put api
TestPutAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request, env must be set.

 def test_some_function(self):
   request.vars['var1'] = 1
   request.vars['var2'] = 2
   request.env.request_method = 'PUT'
   response = api() # call api

   self.assertEquals(response['result'], 'success') 

  def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Test Post api
TestPostAPI(unittest.TestCase):

 def setUp(self):
   request = Request(env=[])  # new request

 def test_some_function(self):
   request.vars['var5'] = "asdf"
   request.vars['var6'] = 6
   request.env.request_method = 'POST'
   response = api() # call api

   self.assertEquals(response['result'], 'success') 

 def tearDown(self):
   db.table.truncate()  # clean up db (nothing request related here)


# Run tests
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPutAPI))
suite.addTest(unittest.makeSuite(TestPostAPI))

unittest.TextTestRunner(verbosity=2).run(suite)


Is my entire approach to unit testing wrong? I know there's a lot a mention 
of doctests being recommended, also that the line request = Request() 
recommended by the original article also being wrong (or simply out of 
date), but I'm also unsure of how the request and api call is being 
processed in this scenario. Earlier I tried doing 2 calls to the same api 
in one test function and found that web2py (and this unittest) simply could 
not overwrite the request function - if that made any sense (it didn't, and 
didn't work).

Anyone have any pointers?

Thank you,
KH


-- 
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/d/optout.


Re: [web2py] unit testing newbiew ... and error...

2017-08-17 Thread António Ramos
seems that removing "people" solves it.




2017-08-17 17:29 GMT+01:00 António Ramos :

> I deleted the line
> del web2py_env['__file__']
>
> then next error
>
> [image: Imagem inline 1]
>
> disabling the code i then get to the tests execution
>
> My simple test is
>
> def test_index_exists(client):
> '''page index exists?
> '''
> client.get('people/default/index')
>
>
> i get an error from
> gluon.contrib.webclient.py
> [image: Imagem inline 2]
>
> Any ideas?
>
> Regards
> António
>
> 2017-08-17 14:19 GMT+01:00 António Ramos :
>
>> [image: Imagem inline 1]
>>
>> 2017-08-17 14:18 GMT+01:00 António Ramos :
>>
>>> Great
>>> Where can i find some discussion on this file ?
>>> i get an error at line 149
>>> https://github.com/viniciusban/web2py.test/blob/master/tests
>>> /conftest.py#L149
>>>
>>> Regards
>>>
>>> 2017-08-17 12:53 GMT+01:00 José Luis Redrejo :
>>>
 Antonio, I would not recommend you usint unittest classes, if you read
 any modern Python testing book or article, they all recommend using pytest.
 I used it in this project https://github.com/jre
 drejo/bancal/tree/master/web2py/applications/bancal
 just in case it can help you.

 Regards
 José L.

 2017-08-17 13:11 GMT+02:00 António Ramos :

> Hello i´m trying to test my web2py app
> Never used any testing before, so be patient..
>
> after reading this
>
> http://www.web2py.com/AlterEgo/default/show/260
>
> and this
> http://www.web2py.com/AlterEgo/default/show/213
>
>
> i tried the code but got this error
>
> [image: Imagem inline 1]
>
> i opened globals.py and saw init gets 2 params
> def __init__(self, env):
>
> and the code
> self.request=Request() is missing 1 param..
>
> any help?
>
> regards
> António
>
> --
> 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/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 web2py+unsubscr...@googlegroups.com.
 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] unit testing newbiew ... and error...

2017-08-17 Thread António Ramos
I deleted the line
del web2py_env['__file__']

then next error

[image: Imagem inline 1]

disabling the code i then get to the tests execution

My simple test is

def test_index_exists(client):
'''page index exists?
'''
client.get('people/default/index')


i get an error from
gluon.contrib.webclient.py
[image: Imagem inline 2]

Any ideas?

Regards
António

2017-08-17 14:19 GMT+01:00 António Ramos :

> [image: Imagem inline 1]
>
> 2017-08-17 14:18 GMT+01:00 António Ramos :
>
>> Great
>> Where can i find some discussion on this file ?
>> i get an error at line 149
>> https://github.com/viniciusban/web2py.test/blob/master/
>> tests/conftest.py#L149
>>
>> Regards
>>
>> 2017-08-17 12:53 GMT+01:00 José Luis Redrejo :
>>
>>> Antonio, I would not recommend you usint unittest classes, if you read
>>> any modern Python testing book or article, they all recommend using pytest.
>>> I used it in this project https://github.com/jre
>>> drejo/bancal/tree/master/web2py/applications/bancal
>>> just in case it can help you.
>>>
>>> Regards
>>> José L.
>>>
>>> 2017-08-17 13:11 GMT+02:00 António Ramos :
>>>
 Hello i´m trying to test my web2py app
 Never used any testing before, so be patient..

 after reading this

 http://www.web2py.com/AlterEgo/default/show/260

 and this
 http://www.web2py.com/AlterEgo/default/show/213


 i tried the code but got this error

 [image: Imagem inline 1]

 i opened globals.py and saw init gets 2 params
 def __init__(self, env):

 and the code
 self.request=Request() is missing 1 param..

 any help?

 regards
 António

 --
 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/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 web2py+unsubscr...@googlegroups.com.
>>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] unit testing newbiew ... and error...

2017-08-17 Thread António Ramos
[image: Imagem inline 1]

2017-08-17 14:18 GMT+01:00 António Ramos :

> Great
> Where can i find some discussion on this file ?
> i get an error at line 149
> https://github.com/viniciusban/web2py.test/blob/
> master/tests/conftest.py#L149
>
> Regards
>
> 2017-08-17 12:53 GMT+01:00 José Luis Redrejo :
>
>> Antonio, I would not recommend you usint unittest classes, if you read
>> any modern Python testing book or article, they all recommend using pytest.
>> I used it in this project https://github.com/jre
>> drejo/bancal/tree/master/web2py/applications/bancal
>> just in case it can help you.
>>
>> Regards
>> José L.
>>
>> 2017-08-17 13:11 GMT+02:00 António Ramos :
>>
>>> Hello i´m trying to test my web2py app
>>> Never used any testing before, so be patient..
>>>
>>> after reading this
>>>
>>> http://www.web2py.com/AlterEgo/default/show/260
>>>
>>> and this
>>> http://www.web2py.com/AlterEgo/default/show/213
>>>
>>>
>>> i tried the code but got this error
>>>
>>> [image: Imagem inline 1]
>>>
>>> i opened globals.py and saw init gets 2 params
>>> def __init__(self, env):
>>>
>>> and the code
>>> self.request=Request() is missing 1 param..
>>>
>>> any help?
>>>
>>> regards
>>> António
>>>
>>> --
>>> 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/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 web2py+unsubscr...@googlegroups.com.
>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] unit testing newbiew ... and error...

2017-08-17 Thread António Ramos
Great
Where can i find some discussion on this file ?
i get an error at line 149
https://github.com/viniciusban/web2py.test/blob/master/tests/conftest.py#L149

Regards

2017-08-17 12:53 GMT+01:00 José Luis Redrejo :

> Antonio, I would not recommend you usint unittest classes, if you read any
> modern Python testing book or article, they all recommend using pytest.
> I used it in this project https://github.com/jre
> drejo/bancal/tree/master/web2py/applications/bancal
> just in case it can help you.
>
> Regards
> José L.
>
> 2017-08-17 13:11 GMT+02:00 António Ramos :
>
>> Hello i´m trying to test my web2py app
>> Never used any testing before, so be patient..
>>
>> after reading this
>>
>> http://www.web2py.com/AlterEgo/default/show/260
>>
>> and this
>> http://www.web2py.com/AlterEgo/default/show/213
>>
>>
>> i tried the code but got this error
>>
>> [image: Imagem inline 1]
>>
>> i opened globals.py and saw init gets 2 params
>> def __init__(self, env):
>>
>> and the code
>> self.request=Request() is missing 1 param..
>>
>> any help?
>>
>> regards
>> António
>>
>> --
>> 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/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 web2py+unsubscr...@googlegroups.com.
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] unit testing newbiew ... and error...

2017-08-17 Thread José Luis Redrejo
Antonio, I would not recommend you usint unittest classes, if you read any
modern Python testing book or article, they all recommend using pytest.
I used it in this project
https://github.com/jredrejo/bancal/tree/master/web2py/applications/bancal
just in case it can help you.

Regards
José L.

2017-08-17 13:11 GMT+02:00 António Ramos :

> Hello i´m trying to test my web2py app
> Never used any testing before, so be patient..
>
> after reading this
>
> http://www.web2py.com/AlterEgo/default/show/260
>
> and this
> http://www.web2py.com/AlterEgo/default/show/213
>
>
> i tried the code but got this error
>
> [image: Imagem inline 1]
>
> i opened globals.py and saw init gets 2 params
> def __init__(self, env):
>
> and the code
> self.request=Request() is missing 1 param..
>
> any help?
>
> regards
> António
>
> --
> 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/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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] unit testing newbiew ... and error...

2017-08-17 Thread António Ramos
Hello i´m trying to test my web2py app
Never used any testing before, so be patient..

after reading this

http://www.web2py.com/AlterEgo/default/show/260

and this
http://www.web2py.com/AlterEgo/default/show/213


i tried the code but got this error

[image: Imagem inline 1]

i opened globals.py and saw init gets 2 params
def __init__(self, env):

and the code
self.request=Request() is missing 1 param..

any help?

regards
António

-- 
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/d/optout.


Re: [web2py] Unit Testing in PyCharm

2016-11-10 Thread 'Roman' via web2py-users
Thank you very much for the links, i will read and report my findings here.

Roman

Am Mittwoch, 9. November 2016 15:37:52 UTC+1 schrieb Richard:
>
> Not exactly what you want but it could help you understand testing with 
> web2py :
>
> https://github.com/viniciusban/web2py.test
>
> https://github.com/niphlod/welcome_augmented
>
> New initiative here : 
> https://groups.google.com/d/msg/web2py/hcsHgJiFEwc/apeBhnf0AgAJ
>
> Good read!
>
> RIchard
>
>
> On Thu, Nov 3, 2016 at 4:56 PM, 'Roman' via web2py-users <
> web...@googlegroups.com > wrote:
>
>> Hi people.
>>
>> Short question: is there a way to run unit tests for my web2py 
>> controllers from PyCharm?
>>
>> I am running the latest web2py with version:  2.14.6-stable
>>
>> What i found out so far:
>>
>> There is an approach to run unit tests from command line. Following this 
>> blogpost: http://web2py.com/AlterEgo/default/show/260 i am able to run a 
>> unit test for my controller. BUT just for convinience i want to let my IDE 
>> manage those tests (i.e. start them and show me the results in a PyCharming 
>> way).
>>
>> To let PyCharm run a unit test, you have to create a new run/debug 
>> configuration, you have to enter the location of a unit test script, to run 
>> it directly. PyCharm does some thing with "utrunner.py" (unit_test_runner?).
>> I tried to give the run/debug configuration the path to web2py.py and as 
>> parameter the "--shell= --import_models --run=my_script.py" 
>> thing. But unfortunately the "utrunner.py" needs well formatted unit test 
>> scripts.
>>
>> Prior to the mentioned blogpost, there was another approach to run unit 
>> tests for web2py controllers: 
>> http://www.web2py.com/AlterEgo/default/show/213
>> Unfortunately, as mentioned in the other post, going that way, my 
>> controller action is not able to see the db :-(
>>
>> Fazit:
>> Does anybody know a way how to run unit tests for my web2py controllers 
>> from PyCharm?
>> Or
>> Does anybody know how to run a unit test for my web2py controllers 
>> directly from command line (without web2py.py) and how can i pass a DAL 
>> object to the environment of my controller?
>>
>> Many thanks in advance and greetings from Berlin
>>
>> Roman
>>
>> -- 
>> 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+un...@googlegroups.com .
>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Unit Testing in PyCharm

2016-11-09 Thread Richard Vézina
Not exactly what you want but it could help you understand testing with
web2py :

https://github.com/viniciusban/web2py.test

https://github.com/niphlod/welcome_augmented

New initiative here :
https://groups.google.com/d/msg/web2py/hcsHgJiFEwc/apeBhnf0AgAJ

Good read!

RIchard


On Thu, Nov 3, 2016 at 4:56 PM, 'Roman' via web2py-users <
web2py@googlegroups.com> wrote:

> Hi people.
>
> Short question: is there a way to run unit tests for my web2py controllers
> from PyCharm?
>
> I am running the latest web2py with version:  2.14.6-stable
>
> What i found out so far:
>
> There is an approach to run unit tests from command line. Following this
> blogpost: http://web2py.com/AlterEgo/default/show/260 i am able to run a
> unit test for my controller. BUT just for convinience i want to let my IDE
> manage those tests (i.e. start them and show me the results in a PyCharming
> way).
>
> To let PyCharm run a unit test, you have to create a new run/debug
> configuration, you have to enter the location of a unit test script, to run
> it directly. PyCharm does some thing with "utrunner.py" (unit_test_runner?).
> I tried to give the run/debug configuration the path to web2py.py and as
> parameter the "--shell= --import_models --run=my_script.py" thing.
> But unfortunately the "utrunner.py" needs well formatted unit test scripts.
>
> Prior to the mentioned blogpost, there was another approach to run unit
> tests for web2py controllers: http://www.web2py
> .com/AlterEgo/default/show/213
> Unfortunately, as mentioned in the other post, going that way, my
> controller action is not able to see the db :-(
>
> Fazit:
> Does anybody know a way how to run unit tests for my web2py controllers
> from PyCharm?
> Or
> Does anybody know how to run a unit test for my web2py controllers
> directly from command line (without web2py.py) and how can i pass a DAL
> object to the environment of my controller?
>
> Many thanks in advance and greetings from Berlin
>
> Roman
>
> --
> 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/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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Unit Testing in PyCharm

2016-11-04 Thread 'Roman' via web2py-users
Hi people.

Short question: is there a way to run unit tests for my web2py controllers 
from PyCharm?

I am running the latest web2py with version:  2.14.6-stable

What i found out so far:

There is an approach to run unit tests from command line. Following this 
blogpost: http://web2py.com/AlterEgo/default/show/260 i am able to run a 
unit test for my controller. BUT just for convinience i want to let my IDE 
manage those tests (i.e. start them and show me the results in a PyCharming 
way).

To let PyCharm run a unit test, you have to create a new run/debug 
configuration, you have to enter the location of a unit test script, to run 
it directly. PyCharm does some thing with "utrunner.py" (unit_test_runner?).
I tried to give the run/debug configuration the path to web2py.py and as 
parameter the "--shell= --import_models --run=my_script.py" thing. 
But unfortunately the "utrunner.py" needs well formatted unit test scripts.

Prior to the mentioned blogpost, there was another approach to run unit 
tests for web2py 
controllers: http://www.web2py.com/AlterEgo/default/show/213
Unfortunately, as mentioned in the other post, going that way, my 
controller action is not able to see the db :-(

Fazit:
Does anybody know a way how to run unit tests for my web2py controllers 
from PyCharm?
Or
Does anybody know how to run a unit test for my web2py controllers directly 
from command line (without web2py.py) and how can i pass a DAL object to 
the environment of my controller?

Many thanks in advance and greetings from Berlin

Roman

-- 
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/d/optout.


[web2py] unit testing controllers with auth decorators

2015-02-05 Thread James O' Driscoll
All,

I am having trouble unit-testing web2py app controllers which are decorated 
with @auht.requires_login().

I think I am missing something declaring the enviroment as I get, auth is 
not defined error. It would be great if I could get some assistance on this.

class TestListClients(unittest.TestCase):
def setUp(self):
self.env = env("contacts")
self.request = Request(self.env)  # Use a clean Request object
self.controller = 
exec_environment('applications/contacts/controllers/default.py', 
request=self.request)

-- 
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/d/optout.


[web2py] Unit Testing

2014-10-31 Thread Ben Olivas
What do people use to perform unit testing in web2py?

-- 
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/d/optout.


Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Mark Li
Regarding Martin's response for anyone who is learning the ropes like me, I 
removed the execfile() line and placed my unit_test.py script in the module 
folder.

On Monday, July 23, 2012 12:13:07 PM UTC-7, Martin.Mulone wrote:
>
> I'm following http://www.web2py.com/AlterEgo/default/show/260 
>>
>
> that guide is too old, have execfile() :S. Search in the group on how to 
> use modules in your app.
>
> 2012/7/22 Mark Li 
>
>> I'm fairly new to test-driven development and have decided it is the best 
>> way to go for my new webapp. While functional tests with selenium seem to 
>> be more straightforward (as far as what the tests want to accomplish), I'm 
>> lost on what unit tests for the database should test for.
>>
>> For example, if I have a database table with columns id, 'dogowner', and 
>> 'dogname', and have a controller returning a dict with 'dogowners', what 
>> should I be testing in the unit tests for the database and controller? 
>>
>> The database table will be fixed with a limited number of 'dogowner' 
>> entries, about 10, so should I be testing whether the database has 10 
>> entries, and if the len of the dict returned by the controller is 10? This 
>> datatable may not be fixed in the future, so what functionality of the 
>> database would I be testing for?
>>
>>
>>
>> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but 
>> while that page explains HOW to go about unit testing, it doesn't explain 
>> what I should be testing for. Anyone experienced with TDD in web2py want to 
>> point me in the right direction? Thanks in advance!
>>
>> -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>  http://www.tecnodoc.com.ar
>
>

-- 





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Richard Vézina
http://ncdegroot.blogspot.ca/2011/09/web2py-automate-unittesting-doctesting.html

http://www.web2pyslices.com/slice/show/1392/unit-testing

On Mon, Jul 23, 2012 at 4:17 PM, Richard Vézina  wrote:

> I know it is not exactly what you want, but there is this tutorial for TDD
> and web2py :
>
> http://killer-web-development.com/section/4/3
>
> Richard
>
>
> On Mon, Jul 23, 2012 at 3:13 PM, Martín Mulone wrote:
>
>> I'm following http://www.web2py.com/AlterEgo/default/show/260
>>>
>>
>> that guide is too old, have execfile() :S. Search in the group on how to
>> use modules in your app.
>>
>>
>> 2012/7/22 Mark Li 
>>
>>> I'm fairly new to test-driven development and have decided it is the
>>> best way to go for my new webapp. While functional tests with selenium seem
>>> to be more straightforward (as far as what the tests want to accomplish),
>>> I'm lost on what unit tests for the database should test for.
>>>
>>> For example, if I have a database table with columns id, 'dogowner', and
>>> 'dogname', and have a controller returning a dict with 'dogowners', what
>>> should I be testing in the unit tests for the database and controller?
>>>
>>> The database table will be fixed with a limited number of 'dogowner'
>>> entries, about 10, so should I be testing whether the database has 10
>>> entries, and if the len of the dict returned by the controller is 10? This
>>> datatable may not be fixed in the future, so what functionality of the
>>> database would I be testing for?
>>>
>>>
>>>
>>> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but
>>> while that page explains HOW to go about unit testing, it doesn't explain
>>> what I should be testing for. Anyone experienced with TDD in web2py want to
>>> point me in the right direction? Thanks in advance!
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>>  http://www.tecnodoc.com.ar
>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Richard Vézina
I know it is not exactly what you want, but there is this tutorial for TDD
and web2py :

http://killer-web-development.com/section/4/3

Richard

On Mon, Jul 23, 2012 at 3:13 PM, Martín Mulone wrote:

> I'm following http://www.web2py.com/AlterEgo/default/show/260
>>
>
> that guide is too old, have execfile() :S. Search in the group on how to
> use modules in your app.
>
>
> 2012/7/22 Mark Li 
>
>> I'm fairly new to test-driven development and have decided it is the best
>> way to go for my new webapp. While functional tests with selenium seem to
>> be more straightforward (as far as what the tests want to accomplish), I'm
>> lost on what unit tests for the database should test for.
>>
>> For example, if I have a database table with columns id, 'dogowner', and
>> 'dogname', and have a controller returning a dict with 'dogowners', what
>> should I be testing in the unit tests for the database and controller?
>>
>> The database table will be fixed with a limited number of 'dogowner'
>> entries, about 10, so should I be testing whether the database has 10
>> entries, and if the len of the dict returned by the controller is 10? This
>> datatable may not be fixed in the future, so what functionality of the
>> database would I be testing for?
>>
>>
>>
>> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but
>> while that page explains HOW to go about unit testing, it doesn't explain
>> what I should be testing for. Anyone experienced with TDD in web2py want to
>> point me in the right direction? Thanks in advance!
>>
>> --
>>
>>
>>
>>
>
>
>
> --
>  http://www.tecnodoc.com.ar
>
>  --
>
>
>
>

-- 





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Martín Mulone
>
> I'm following http://www.web2py.com/AlterEgo/default/show/260
>

that guide is too old, have execfile() :S. Search in the group on how to
use modules in your app.

2012/7/22 Mark Li 

> I'm fairly new to test-driven development and have decided it is the best
> way to go for my new webapp. While functional tests with selenium seem to
> be more straightforward (as far as what the tests want to accomplish), I'm
> lost on what unit tests for the database should test for.
>
> For example, if I have a database table with columns id, 'dogowner', and
> 'dogname', and have a controller returning a dict with 'dogowners', what
> should I be testing in the unit tests for the database and controller?
>
> The database table will be fixed with a limited number of 'dogowner'
> entries, about 10, so should I be testing whether the database has 10
> entries, and if the len of the dict returned by the controller is 10? This
> datatable may not be fixed in the future, so what functionality of the
> database would I be testing for?
>
>
>
> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but while
> that page explains HOW to go about unit testing, it doesn't explain what I
> should be testing for. Anyone experienced with TDD in web2py want to point
> me in the right direction? Thanks in advance!
>
> --
>
>
>
>



-- 
 http://www.tecnodoc.com.ar

-- 





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Mark Li
Thanks Richard, for now I am going to create a special database table that 
will follow the structure of the actual data tables, but with a fixed data 
set like you suggested (controls for count very well).

I'm still interested in any real examples people use for unit testing 
databases and controller functions, I'm sure i'm glossing over something!

On Monday, July 23, 2012 7:40:51 AM UTC-7, Richard wrote:
>
> I am interesting in what will come out of this thread...
>
> But, to me I think your last question on fact that database will have 
> undertermined set of data mean that you maybe not validate your app base on 
> the entries of the database but on a testing database with a set of known 
> data, that you can even charge on need for the test. Also, you will just 
> test the limit with data that will for example help to demonstrate that a 
> field type is appropriately defined to get all type of data you intend to 
> put in in. Count, if variable get creates, etc., is more in the basic thing 
> you can always check for every function...
>
> I am also pretty new to unit test in general and have most the same 
> questions.
>
> Cheers!
>
> Richard
>
>
> On Sun, Jul 22, 2012 at 9:41 PM, Mark Li  wrote:
>
>> I'm fairly new to test-driven development and have decided it is the best 
>> way to go for my new webapp. While functional tests with selenium seem to 
>> be more straightforward (as far as what the tests want to accomplish), I'm 
>> lost on what unit tests for the database should test for.
>>
>> For example, if I have a database table with columns id, 'dogowner', and 
>> 'dogname', and have a controller returning a dict with 'dogowners', what 
>> should I be testing in the unit tests for the database and controller? 
>>
>> The database table will be fixed with a limited number of 'dogowner' 
>> entries, about 10, so should I be testing whether the database has 10 
>> entries, and if the len of the dict returned by the controller is 10? This 
>> datatable may not be fixed in the future, so what functionality of the 
>> database would I be testing for?
>>
>>
>>
>> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but 
>> while that page explains HOW to go about unit testing, it doesn't explain 
>> what I should be testing for. Anyone experienced with TDD in web2py want to 
>> point me in the right direction? Thanks in advance!
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread vinicius...@gmail.com

+1

On 07/23/2012 11:40 AM, Richard Vézina wrote:

I am interesting in what will come out of this thread...

But, to me I think your last question on fact that database will have
undertermined set of data mean that you maybe not validate your app base
on the entries of the database but on a testing database with a set of
known data, that you can even charge on need for the test. Also, you
will just test the limit with data that will for example help to
demonstrate that a field type is appropriately defined to get all type
of data you intend to put in in. Count, if variable get creates, etc.,
is more in the basic thing you can always check for every function...

I am also pretty new to unit test in general and have most the same
questions.

Cheers!

Richard


On Sun, Jul 22, 2012 at 9:41 PM, Mark Li mailto:markruole...@gmail.com>> wrote:

I'm fairly new to test-driven development and have decided it is the
best way to go for my new webapp. While functional tests with
selenium seem to be more straightforward (as far as what the tests
want to accomplish), I'm lost on what unit tests for the database
should test for.

For example, if I have a database table with columns id, 'dogowner',
and 'dogname', and have a controller returning a dict with
'dogowners', what should I be testing in the unit tests for the
database and controller?

The database table will be fixed with a limited number of 'dogowner'
entries, about 10, so should I be testing whether the database has
10 entries, and if the len of the dict returned by the controller is
10? This datatable may not be fixed in the future, so what
functionality of the database would I be testing for?



I'm following http://www.web2py.com/AlterEgo/default/show/260 , but
while that page explains HOW to go about unit testing, it doesn't
explain what I should be testing for. Anyone experienced with TDD in
web2py want to point me in the right direction? Thanks in advance!

--




--





--





Re: [web2py] Unit Testing Database Best Practices

2012-07-23 Thread Richard Vézina
I am interesting in what will come out of this thread...

But, to me I think your last question on fact that database will have
undertermined set of data mean that you maybe not validate your app base on
the entries of the database but on a testing database with a set of known
data, that you can even charge on need for the test. Also, you will just
test the limit with data that will for example help to demonstrate that a
field type is appropriately defined to get all type of data you intend to
put in in. Count, if variable get creates, etc., is more in the basic thing
you can always check for every function...

I am also pretty new to unit test in general and have most the same
questions.

Cheers!

Richard


On Sun, Jul 22, 2012 at 9:41 PM, Mark Li  wrote:

> I'm fairly new to test-driven development and have decided it is the best
> way to go for my new webapp. While functional tests with selenium seem to
> be more straightforward (as far as what the tests want to accomplish), I'm
> lost on what unit tests for the database should test for.
>
> For example, if I have a database table with columns id, 'dogowner', and
> 'dogname', and have a controller returning a dict with 'dogowners', what
> should I be testing in the unit tests for the database and controller?
>
> The database table will be fixed with a limited number of 'dogowner'
> entries, about 10, so should I be testing whether the database has 10
> entries, and if the len of the dict returned by the controller is 10? This
> datatable may not be fixed in the future, so what functionality of the
> database would I be testing for?
>
>
>
> I'm following http://www.web2py.com/AlterEgo/default/show/260 , but while
> that page explains HOW to go about unit testing, it doesn't explain what I
> should be testing for. Anyone experienced with TDD in web2py want to point
> me in the right direction? Thanks in advance!
>
> --
>
>
>
>

-- 





[web2py] Unit Testing Database Best Practices

2012-07-23 Thread Mark Li
I'm fairly new to test-driven development and have decided it is the best 
way to go for my new webapp. While functional tests with selenium seem to 
be more straightforward (as far as what the tests want to accomplish), I'm 
lost on what unit tests for the database should test for.

For example, if I have a database table with columns id, 'dogowner', and 
'dogname', and have a controller returning a dict with 'dogowners', what 
should I be testing in the unit tests for the database and controller? 

The database table will be fixed with a limited number of 'dogowner' 
entries, about 10, so should I be testing whether the database has 10 
entries, and if the len of the dict returned by the controller is 10? This 
datatable may not be fixed in the future, so what functionality of the 
database would I be testing for?



I'm following http://www.web2py.com/AlterEgo/default/show/260 , but while 
that page explains HOW to go about unit testing, it doesn't explain what I 
should be testing for. Anyone experienced with TDD in web2py want to point 
me in the right direction? Thanks in advance!

-- 





[web2py] Unit Testing

2012-05-06 Thread Rod Watkins
Hi everyone,

I am fairly new to web2py and python programming, but have had some rather 
wonderful success in the month or so I've been learning it.

I am now preparing to start a real project and want to have unit tests as I 
go.  I've read a bit (will be doing more) about python unit testing 
(doctests, unittest, nose, coverage, selenium), but I want to get some 
expert advise before I fully dive in, if I may. So a few questions:

1. Do you use unit tests?
2. What tools do you use (doctests, unittest, nose, coverage, selenium, 
mocker, or others)?
3. Do you use any of the test runners from the community? (
http://packages.python.org/web2py_utils/test_runner.html,http://www.web2pyslices.com/slices/take_slice/142,http://web2py.com/AlterEgo/default/show/260)
 
Which, if any, would you suggest using?

I'm mainly looking for some guidance about how to proceed, what to study 
and the best manner you've found to do unit tests.  For example, it is 
worth doing anything more than doctests in controllers? If so, what beyond 
them should I learn to use, etc.

Thanks everyone.
Rod



[web2py] Unit testing and faking authentication

2012-04-07 Thread Keith Edmunds
I've been looking that the unit testing page
(http://www.web2py.com/AlterEgo/default/show/260), which is very helpful.
However, most of my controller functions are decorated with
'@auth.requires_login()', and thus if I call them from the test suite,
they fail (issuing a redirect):

  File "/home/kae/hg/kae/web2py/gluon/tools.py", line 934, in 
settings.on_failed_authentication = lambda x: redirect(x)
  File "/home/kae/hg/kae/web2py/gluon/http.py", line 128, in redirect
Location=location)
HTTP: 303 SEE OTHER

One could argue that's a "correct" failure because the test suite isn't
authenticated, but I'd like to use unit tests to test functions that need
authentication. I don't want to test the authentication mechanism itself.

Is there a way to fake authentication to allow unit testing? Do others
have a better way of doing this?
-- 
"You can have everything in life you want if you help enough other people
get what they want" - Zig Ziglar. 

Who did you help today?


[web2py] unit testing web2py and app engine

2012-03-20 Thread David Phillips
I am writing a web application using web2py for execution on app
engine. I've deployed other web2py apps there but I've never used any
app engine-specific utilities. In this project I want to use app
engine's taskqueue and run it on a backend instance.

I'm developing on app engine's dev_appserver which is working out
okay, but but I'm not seeing how to do unit testing.

Is this a problem that has been solved already?


[web2py] Unit Testing - exec not adding controller to globals

2010-05-02 Thread Matthew
I'm following the instructions from this post 
http://web2py.com/AlterEgo/default/show/260
but cannot get my methods recognized globally.

ERROR MESSAGE:

ERROR: test_suggest_performer (__builtin__.TestSearch)
--
Traceback (most recent call last):
  File "applications/myapp/tests/test_search.py", line 24, in
test_suggest_performer
suggs = suggest_flavors("straw")
NameError: global name 'suggest_flavors' is not defined

TEST FILE:

import unittest

from gluon.globals import Request
db = test_db

execfile("applications/myapp/controllers/search.py", globals())

class TestSearch(unittest.TestCase):
def setUp(self):
request = Request()

def test_suggest_flavors(self):
suggs = suggest_flavors("straw")
self.assertEqual(len(suggs), 1)
self.assertEqual(suggs[0][1], 'Strawberry')

CONTROLLER:

def suggest_flavors(term):
return []


Re: [web2py] Unit testing in web2py : Some thoughts

2010-02-22 Thread Thadeus Burgess
Are we looking at the same thing?

The link you provided gives an example of using the unittest classes
(not doctest), in which you can import anything you want since it is
just a python file.

In the example is an example of executing your controllers in a web2py
environment.

Also the doctest example
http://www.web2py.com/examples/default/examples#testing_examples
anything in the >>> is python code so you can import modules if you
want.

Also, the doctests have access to the web2py environment, so they have
access to db.

-Thadeus





On Mon, Feb 22, 2010 at 12:49 PM, Jon Romero  wrote:
> I've read about web2py and unit testing and I tried many things.
> These are my thoughts (please correct me If I am wrong)
>
> 1. web2py uses doctests. doctests must be inside the controller
> (increasing the noise) and are not flexible. Also, is not trivial to
> use them in another automated built/test system
> 2. The only official example online is here 
> http://www.web2py.com/AlterEgo/default/show/213
> where you
> cannot import models. I think that you have to load the environment
> first (any code snippet how to do that)?
>
> So, any decent solution that you guys know?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Unit testing in web2py : Some thoughts

2010-02-22 Thread Jon Romero
I've read about web2py and unit testing and I tried many things.
These are my thoughts (please correct me If I am wrong)

1. web2py uses doctests. doctests must be inside the controller
(increasing the noise) and are not flexible. Also, is not trivial to
use them in another automated built/test system
2. The only official example online is here 
http://www.web2py.com/AlterEgo/default/show/213
where you
cannot import models. I think that you have to load the environment
first (any code snippet how to do that)?

So, any decent solution that you guys know?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.