Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#241 closed defect (wontfix)

Test fixture support — at Version 8

Reported by: Caleb Davis Owned by:
Priority: minor Milestone:
Component: programming Keywords: post-sql
Cc: Parent Tickets:

Description (last modified by Christopher Allan Webber)

A few tickets are blocking on being able to rip test data into the
database, and some giant put me on his shoulders and then I saw the
promised land of test fixtures. We need to support test fixtures.



Change History (10)

comment:1 by Christopher Allan Webber, 13 years ago

There are two possible ways we could do this, too.


-  We could make use of the envball stuff we have. That would be
   easiest, maybe?
-  We could write something different. The envball stuff exports to
   I think binary database files which aren't so great for fixtures.
   What I'd really like are bson->json exports of the data and not
   gzipped tarballs... that would make it easier for us to edit our
   fixture data going forward as things change in a git-friendly way.

`#1 </issues/1>`_ is probably faster, #2 is probably nicer.



comment:2 by Caleb Davis, 13 years ago

2 would be fine I think. A thin wrapper around mongo{import/export} would seem to do the trick!
===============================================================================================

`http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportTools-mongoimport <http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportTools-mongoimport>`_



comment:3 by Christopher Allan Webber, 13 years ago

Milestone: 0.1.00.2.0

comment:3 by Elrond, 13 years ago

A simple start: Creating the test user in the database. I factored
that out into a tool function.
My branch: ``misc/fixture_add_user``.
If nobody cries "stupid idea" or "found a bug", I'll merge/push on
sunday.

Okay, merged. (commit ea5a5b15a3d5)



comment:4 by Christopher Allan Webber, 13 years ago

Milestone: 0.2.00.2.1

comment:4 by Christopher Allan Webber, 13 years ago

The requirements for this have massively changed now that we're
moving to SQL, but I say "leave it open for now".



comment:5 by Will Kahn-Greene, 13 years ago

The original url for this bug was http://bugs.foocorp.net/issues/570 .
Relations:
#142: related, #55: related, #379: blocked

comment:6 by Elrond, 13 years ago

Keywords: post-sql added

comment:7 by Elrond, 13 years ago

Milestone: 0.2.1

This will be interesting after sql lands.
sql hopefully lands in the next release.
So this will be after the next release, probably.

Of course, if someone wants to take it, go for it!

comment:8 by Christopher Allan Webber, 13 years ago

Description: modified (diff)
Resolution: wontfix
Status: acceptedclosed

I'm going to kill this one.

I saw a talk at pycon that significantly convinced me that test fixtures are the wrong way to go. See:

http://www.youtube.com/watch?v=ickNQcNXiS4&feature=player_embedded

starting at 16:26

All sorts of reasons given for why this is bad!

Instead he suggests writing code like this:

def create_profile(**kwargs):
    defaults = {
        "likes_cheese": True,
        "age": 32,
        "address": "3815 Brookside Dr",
    }
    defaults.update(kwargs)
    if "user" not in defaults:
        defaults["user"] = create_user()
    return Profile.objects.create(
        **defaults)

and using that to *only* change the fields that you need to test for each thing you're trying out.

fixture_add_user() as elrond made above already pretty close to this.

Anyway, wontfix'ing my own bug! :)

Note: See TracTickets for help on using tickets.