Hello, is there a way to fake the user group and membership as well?
Thanks!
On Saturday, April 7, 2012 at 5:24:09 PM UTC+2, Anthony wrote:
>
> For @auth.requires_login() to pass, I think you just need auth.user to
> exist (and not be None). If your layout includes auth.navbar(), I think the
>
Please exclude the code below.
I followed the only major testing slice I could find.
http://www.web2pyslices.com/slice/show/1465/unittesting-doctesting-and-userinterface-testing
I can now register and login using auth, I am using a testing db all tables
in auth in db are being populated correct
Attached (assuming google groups accepts it) is my unit testing
controller that i run on GAE development SDK.
also note that my db connection is defined as:
db = DAL('google:datastore') # connect to Google BigTable
if request.test_db or request.function == "_TEST":
db = DAL('go
I'd be interested in seeing this controller. Especially the part about
running the unittests.
On Wednesday, 9 May 2012 00:19:07 UTC+3, howesc wrote:
>
> while i would not call anything i have great tests or a wonderful example
> of testing, i have used doctests in controllers successfully. th
while i would not call anything i have great tests or a wonderful example
of testing, i have used doctests in controllers successfully. those are
nice as the web2py environment is auto-setup for you.
i'm working on using the unittest module to test my modules - those don't
always need all the
I'm also trying to get unit tests working on web2py by following the
slices, but so far I've not been able to make them run properly. I'd like
to see some clear examples and maybe some real projects with unit tests on
web2py, to see how it's done in practice.
On Sunday, 6 May 2012 20:40:10 UTC
Hi Rod,
To add to your resources, I noticed on this site
http://killer-web-development.com the author talks about using Selenium
with web2py.
Regards, David
On Sunday, 6 May 2012 18:40:10 UTC+1, Rod Watkins wrote:
>
> Hi everyone,
>
> I am fairly new to web2py and python programming, but hav
For @auth.requires_login() to pass, I think you just need auth.user to
exist (and not be None). If your layout includes auth.navbar(), I think the
auth.user object at least needs to include an "id" attribute as well (i.e.,
auth.user.id should be some integer). So maybe add something like this in
I should have mentioned one other thing. Before running my unit test,
I set the PYTHONPATH environment variable so that I could import the
Google app engine libraries.
export PYTHONPATH=~/dev/python/google/google_appengine_1.6.3_source/
google_appengine
On Mar 21, 11:14 am, David Phillips
wrote:
Thank you, howesc. I'll take a close look at your file.
I finally cobbled together a file to unit test an object in my project
that uses the unittest library, Google's memcache and the testbed
library, and a web2py model. I am hoping it will scale up to test
controller actions as well as individua
attached is a controller that i use, adapted from the testing tools in the
admin interface. note that i set a request parameter 'test_db' and in
models i detect that parameter and connect to a different namespace so that
my tests run in a controlled DB environment - remember that if you want to
test_runner in web2py_utils was designed around slice 67. test_runner lets
you do a little more, and handles more of the state management for you.
--
Thadeus
On Tue, Mar 1, 2011 at 5:57 AM, eddie wrote:
> I should add I'm on web2py version 1.92.1.
>
> And I should also add I'm extremely supp
I should add I'm on web2py version 1.92.1.
And I should also add I'm extremely supportive of the efforts to build some
better unit testing infrastructure like this, these examples are fantastic.
Hi all,
I'm looking at adding unit tests to a project I am working on. I had a
couple of questions.
First of all, is the testRunner.py approach, as documented in slice 67,
still a reasonable way to go, or has all the effort switched over to the
test_runner tool in the web2py_utils package?
I
I made a slice:
http://www.web2pyslices.com/main/slices/take_slice/67
I'll post a project also to bitbucket.
I've created a unit system but I made a lot of assumptions and I think
that we should talk about it:
First, I created a testRunner.py file (in the same directory level
with web2py.py) that
Thank you very much for this. I've been wanting to integrate unit tests in
my project but didn't found the time to investigate this issue.
Best regards,
Tiago
---
On Tue, Mar 2, 2010 at 2:41 PM, spiffytech wrote:
> I finally finished the article I promised. I couldn't post to the
> wiki, so I p
Very cool SpiffyTech!
It is much appreciated :)
I would like to see (at some point) documentation with a sample application
and its respective tests - so one can see how it all fits together.
Still very informative.
Nicolaas
On Tue, Mar 2, 2010 at 4:41 PM, spiffytech wrote:
> I finally finis
I finally finished the article I promised. I couldn't post to the
wiki, so I posted to AlterEgo instead:
http://web2py.com/AlterEgo/default/show/260
Since I've done little with web2py forms and auth, they're not
covered. Feel free to change the article to include how to test them.
On Mar 2, 8:5
I'll post a full example in bitbucket and then a slice :)
On Mar 2, 2:30 pm, mdipierro wrote:
> Would you post a web2pyslice?
>
> On Mar 2, 4:39 am, Jon Romero wrote:
>
> > ok I managed to do unit testing on forms:
>
> > def testForm(self):
> > request.vars["username"] = "great-guy"
>
Good job!
I am still having problem with unit testing forms. It seems that I
cannot do a post.
# Set variables for the test function
request.env.request_method = 'POST'
request.post_vars["body"] = "body"
#request.vars = Storage(body = "bod")
resp = ind
I'm really glad to see this work happening, and I look forward to the slice.
Perhaps we could eventually have unit tests as part of the welcome app, or
indeed all three standard apps, both for documentation purposes and to set a
good example.
--
You received this message because you are subscr
I had not tried taking the sys.argv statement out of my code. You are
correct: when using TestTextRunner, sys.argv does not need to be
cleaned. I like the idea of a command line flag. It's probably a good
idea to offer such a flag, even though it turns out it's not needed to
run unit tests.
On Fe
I do not like the idea of having to specify the name of the app twice,
it breaks DRY.
What about an additional command line flag that can tell whether to
strip sys.argv or not. This will keep backwards compatibility, and
also allow for scripts to have a simple sys.argv if required.
web2py.py --cl
What about adding to the shell environment a variable containing the
name of the current app? Then scripts like yours could still get the
information they need, and the extra values could be removed from
sys.argv without a script having to import a helper.
Does this count as breaking backward-comp
Yes, I forgot to mention the db.commit().
In fact, I would db.commit() after every successful
insertion/delete/update this way your tests will be more in line?
I do not know any reason as to why web2py passes along args that it is
not using. However I think this could be beneficial in certain scr
Last question: Is there any value in having web2py.py pass scripts the
full command line (sys.argv)? If not, would you be open to a patch to
gluon/shell.py so that it only passes the script's filename and any
CLI variables shell.py didn't use? I'd also appreciate suggestions on
how to do that more
Works great! I added an "import copy" in db.py, and added a line in my
unit test to rename "test_db" to "db" so that functions in the test
script will use the test DB.
For posterity, here is a complete working example of unit tests with
web2py, with access to the database, using test database. The
So the easiest way to use a testing db and your existing tables is to
automatically recreate them.
So assuming you are in the web2py environment and have access to ``db``
>>> test_db = DAL('testing.sqlite')
>>> for tablename in db.tables:
>>> table_copy = [copy.copy(f) for f in db[tablename]]
I concur. Thanks :)
On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe
wrote:
> Super awesome, thanks!
>
>
> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech wrote:
>
>> I'm going to write up a nice, clear wiki article on unit testing with
>> the unittest module based on what I learned in this dis
execfile() did the trick! Things are working nicely now.
Using a test database would be very helpful. How do you recommend
setting one up? Do I need to copy/paste the table/field definitions
from the 'db' object, or is there a way to make a copy of the 'db'
object and point it to a different SQLit
Super awesome, thanks!
On Thu, Feb 25, 2010 at 3:43 PM, spiffytech wrote:
> I'm going to write up a nice, clear wiki article on unit testing with
> the unittest module based on what I learned in this discussion. I'll
> be sure to link to it here when it's done.
>
>
> On Feb 25, 4:20 am, Nicol va
I'm going to write up a nice, clear wiki article on unit testing with
the unittest module based on what I learned in this discussion. I'll
be sure to link to it here when it's done.
On Feb 25, 4:20 am, Nicol van der Merwe wrote:
> Hi guys
>
> This stuff is very interesting. I would like to reque
Yeap, spiffytech where you able to run tests (no doctests) using the
database?
On Feb 25, 11:20 am, Nicol van der Merwe
wrote:
> Hi guys
>
> This stuff is very interesting. I would like to request, if possible, that
> someone makes a web2pyslice or proper AlterEgo entry on how to setup and run
>
Hi guys
This stuff is very interesting. I would like to request, if possible, that
someone makes a web2pyslice or proper AlterEgo entry on how to setup and run
these kinds of tests for web2py. I am very interested in setting up tests
for my application but I'm a bit lost as I've never done so befo
The unit test already has access to web2py environment (and db or
anything else in your models). ``exec_environment`` just recreates a
blank environment, when executing your controller it executes it
outside of the current global scope.
Instead of running exec_environment on your controller, run
`
Thanks! Interesting article! My test cases now execute. However, I
have a couple new questions, including a problem accessing the db in
my controller.
I modified my test file as AlterEgo 213 indicates so my unit tests can
access the controller's functions. Here is my updated test file:
==
Replacing the way you run test suites helps. Instead of using .main()
add them manually.
I would suggest reading the following article, as it includes methods
to aggregate your test suites together.
http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html
import sys
sys.
The confusion is not with doctests, but with external unit tests
created with the 'unittest' module. Could you please post your
testControllerDefault.py so I can see what you're doing different from
me?
Please allow me to elaborate on my problems running unit tests with
web2py. Here is my (very mi
If I create a unittest
init/tests/testControllerDefault.py
and run the following command line
python web2py.py -S -M -R
applications/init/tests/testControllerDefault.py
My test is ran.
I don't see what is so confusing.
-Thadeus
On Wed, Feb 24, 2010 at 12:01 PM, Thadeus Burgess wrote:
>
consider controllers/default.py
def index():
"""
>>> db(db.people.id > 0).count()
'35'
"""
return db(db.people.id > 0).count()
now when I run
`python web2py.py -T init/default/index`
produces my doctest.
-Thadeus
On Wed, Feb 24, 2010 at 2:28 AM, Jon Romero wrote:
> So, any idea/hint
So, any idea/hint how to do it? Do we need a patch?
On Feb 23, 10:40 pm, spiffytech wrote:
> I'm running the latest version, 1.75.4.
>
> On Feb 23, 11:35 am, Thadeus Burgess wrote:
>
> > What version of web2py are you running?
>
> > What is the output of ``python web2py.py --help``
>
> > -Thadeu
I'm running the latest version, 1.75.4.
On Feb 23, 11:35 am, Thadeus Burgess wrote:
> What version of web2py are you running?
>
> What is the output of ``python web2py.py --help``
>
> -Thadeus
>
> On Tue, Feb 23, 2010 at 5:23 AM, Jon Romero wrote:
> > ust put a prin "Hello world!" inside the te
That is unittest.main() trying to parse the arguments on the command
line. Web2py is passing the original command line (sys.argv) to the
unit test script, which sees the arguments for web2py.py and says "I
don't know what these mean". A quick hack to gluon/shell.py ("sys.argv
= sys.argv[4:]" on lin
What version of web2py are you running?
What is the output of ``python web2py.py --help``
-Thadeus
On Tue, Feb 23, 2010 at 5:23 AM, Jon Romero wrote:
> ust put a prin "Hello world!" inside the test file, everything
> works ok. So, I suppose that this file tries to load AGAIN the web2py
> en
Thanks! That was what I was looking for!
The problem now is that is you try to run the unit test the way it is
described here (http://www.web2py.com/AlterEgo/default/show/213 ), I
get this error:
> python web2py.py -S init -M -R applications/myapp/tests/default.py
option -S not recognized
Usage: w
python web2py.py --help
-S APPNAME, --shell=APPNAME
run web2py in interactive shell or IPython (if
installed) with specified appname
-T TEST_PATH, --test=TEST_PATH
run doctests in web2py environment; TEST_PATH like
> 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.
AlterEgo 213 (which Jon linked to) does not show how to get your
controllers to see your database models- the example code doesn't
int
47 matches
Mail list logo