Opened 14 years ago
Last modified 14 years ago
#23 closed defect (FIXED)
Structure for testing views via webtest
| Reported by: | Christopher Allan Webber | Owned by: | Christopher Allan Webber |
|---|---|---|---|
| Priority: | major | Milestone: | 0.0.3 |
| Component: | programming | Keywords: | |
| Cc: | Parent Tickets: |
Description
We need to start testing views to make sure they work right. Right
now we should create a "test app" to start testing things in.
Use webtest:
`http://pythonpaste.org/webtest/ <http://pythonpaste.org/webtest/>`_
The testing app should be importable from something like:
from mediagoblin.tests.tools import get\_test\_app
test\_app, webtest\_app = get\_test\_app()
where the test\_app is the MediaGoblinApp instance and webtest\_app
is a wrapped instance in webtest.
The testapp should do the following things:
- create a new database with the database name
'**mediagoblinunittests**' or something with the default connection
settings, dumping an old database if it exists
- Attach a mediagoblin.app.MediaGoblinApp instance to webtest with
that database... see the structure of paste\_app\_factory to see
how to do this
- create a public\_store and a queue\_store that write to
temporary directories. Use tempfile.mkdtemp() to create these
directories
- when calling setup\_celery\_from\_config it should make sure the
mongodb database that it calls is the *mediagoblinunittests*
database we created.
One note: cache the database connection in a global variable like
mediagoblin.tests.tools.DATABASE\_CONNECTION and also note whether
celery is set up in mediagoblin.tests.tools.CELERY\_IS\_SET\_UP...
we should only set up celery once :)
Change History (13)
comment:1 by , 14 years ago
| Owner: | set to |
|---|---|
| Priority: | Normal → High |
comment:1 by , 14 years ago
comment:3 by , 14 years ago
Hey, I've setup the environment and passed trough the codebase. I was planning to get started this weekend but something else came up so it'll have to wait for a couple of days.
comment:4 by , 14 years ago
Okay, thanks for the update, and let us know. This is a complicated ticket to start with and not very well explained. Let me know if this is an overwhelming task. We might need it soon, so if you can get started on it over the next week that would be great. No pressure for you to push yourself though. If the need comes up and you can't get to it quite in time I might be able to get to it on the week of the 16th and we can assign you to something that's not as overwhelming for a new contributor. All that said I don't want to discourage you from working on this task! Your help is greatly appreciated. :)
comment:5 by , 14 years ago
Thank you for you support. No pressure felt on my side. Started hacking yesterday. I'll come back to you if get in any trouble.
comment:7 by , 14 years ago
| Milestone: | → 0.0.3 |
|---|
As per todays meetup, this issue is targetted for 0.0.3. Setting appropiately.
comment:8 by , 14 years ago
| Owner: | changed from to |
|---|
Tomaz, have you made any further progress on this? This is high priority for 0.0.3... claiming for myself for now as I'll work on it next.
comment:9 by , 14 years ago
| Status: | New → In Progress |
|---|
This is in progress, and chris certainly has accomplished a lot in this area. The 50% are just a wild guess. ;)
comment:10 by , 14 years ago
| Status: | In Progress → Closed |
|---|
This is working really well; I'd even be willing to say "it's done" and any more changes that happen can just be incremental things. I'll write up a braindump of how all this stuff works to the mailing list this week.
comment:11 by , 14 years ago
| Component: | → Programming |
|---|
comment:11 by , 14 years ago
The original url for this bug was http://bugs.foocorp.net/issues/289 .
Relations:
#79: blocks, #80: blocks
Note:
See TracTickets
for help on using tickets.

Sigh, my >>> got borked. :: from mediagoblin.tests.tools import get_test_app test_app, webtest_app = get_test_app() are the lines I meant to put in that thing that was quoted 3 times.