Flask-Fixtures
Flask-Fixtures copied to clipboard
Add the ability to nest fixtures
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.