views:

53

answers:

2

I have some the page elements split into separate visual blocks.

I am currently integrating the front end htmls from the designer, so it is important for me to test how they appear in the browser individually (each block).

What is the simplest way I can implement this using django-testing?

I know I can create a view with all the blocks and call this page via twill or selenium. I am thinking there must be a simpler platform specific command I can use from within the tests like gnome-open render_to_string(abcd.html,{})

Reminds me of Joel's school of thought that hire a "tester" that is disciplined and doesn't mind this boring stuff of testing it again and again; but I don't necessarily accept it.

Also, what is the simplest way to specify to django to use an in-memory-sqlite-db for testing, so that the process can be sped up?

A: 

Maybe write the render_to_string() to file, and then launch a browser with that file as a parameter (using subprocess.call or something similar)?

Ofri Raviv
A: 

On the use sqlite for tests question you can specify a seperate settings module (lets call it test_settings) which defines only the database settings. Then run it like:

manage.py test --settings=test_settings

In that file put:

from settings import *
DATABASE_ENGINE = "sqlite3"

The test runner should use an in memory database by default if sqlite is specified.

Regarding checking the output of individual elements it depends on what you're trying to achieve. If you mean that you want to manually have a look at something in a browser to give it the OK then I'd suggest writing a management command to do just that. The test runner is better suited to things that can be determined to pass or fail in code. As mentioned previously if this is your aim then outputting to file, and then scripting a browser to open tabs with all files in a directory if probably a good idea. You might find Watir useful for this, it's an open-source (BSD) library for automating web browsers.

If what you have can be checked programatically (some CSS stuff, compare to an image, finding a string in the output) then you might find some work I did around testing CSS using selenium and Python useful (http://github.com/garethr/css-test)

Garethr