I finally got time to continue on my GTD application. I wrote unit tests for all controller methods.
My first idea was to include a mock framework so I wouldn’t need to execute external logic in my tests, but then I realized that would be overkill. I’m using an in-memory database (SQLite) and executing the whole application stack (except for javascript). All tests runs within 10 seconds, which is acceptable.
TurboGears includes Nose, which is a test discovery and running process for unittest. Typing “nosetests” on the command line runs all tests in the project.
I’ve decided to later use AJAX in my application, and a good way to test the whole stack including javascript is to test with Selenium. I’ll leave this for later.
It just works
I have never felt such a joy developing a web application. I get into flow more often. Things just work and I rarely show the ‘what the heck happened’-face.
baseTest.py:
from turbogears import testutil
from turbogtd.controllers import Root
from turbogtd import model
import cherrypy
cherrypy.root = Root()
cherrypy.config.update({"sqlalchemy.dburi" : "sqlite:///:memory:"})
cherrypy.config.update({'sessionFilter.on': True})
class BaseTest:
def setUp(self):
# a 'dummy' call to initialize the database
testutil.create_request('/')
model.create()
def tearDown(self):
model.drop()
test_project.py:
class TestProject(BaseTest):
def test_create(self):
testutil.create_request('/project/create?title=title¬es=notes')
page = cherrypy.response.body[0]
assert 'Project added' in page, "text not found. page: " +page
project = Project.get(1)
assert 'title' == project.title, "error in title: " +project.title
assert 'notes' == project.notes, "error in notes: " +project.notes
I love your site!
_____________________
Experiencing a slow PC recently? Fix it now!
forex…
[...]MAC5853[...]…
wehostia.com…
[...]MAC5853[...]…
lethal commission bonus…
[...]MAC5853[...]…
Web directory Annuaire de referencement des sites web…
[...]MAC5853[...]…
christmas present ideas, best christmas gifts, best christmas presents…
[...]MAC5853[...]…
continuously i used to read smaller posts which as well clear their motive, and that is also
happening with this post which I am reading at this time.
Asking questions are genuinely fastidious thing if you are not understanding something entirely, however this post gives good
understanding even.
I do not know whether it’s just me or if everybody else encountering problems with your site. It looks like some of the text within your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This might be a issue with my browser because I’ve had this happen before.
Appreciate it