Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to nest fixtures #4

Open
croach opened this issue Jul 1, 2014 · 0 comments
Open

Add the ability to nest fixtures #4

croach opened this issue Jul 1, 2014 · 0 comments

Comments

@croach
Copy link
Owner

croach commented Jul 1, 2014

The idea here is that, instead of creating two separate fixture objects, when one is a child of the other, it would be nice if we could nest them. For example, assume we have the following classes:

class Author(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(30))
    last_name = db.Column(db.String(30))

class Book(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(200))
    author = db.relationship('Author', backref='books')

It would be nice to be able to do something like this in the fixtures data:

[
    {
        "table": "authors",
        "fields": {
            "first_name": "Christopher",
                "last_name": "Roach",
                "books": [{
                    "title": "Flask in Action"
                }]
        }
    }
]

Flask-Fixtures should be able to match up attribute names against relationships and add them accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant