Appengine fixture loader
Project description
A simple way to load Django-like fixtures into the local development datastore, originally intended to be used by testable_appengine.
Let’s say you have a model like this:
class Person(ndb.Model): """Our sample class""" first_name = ndb.StringProperty() last_name = ndb.StringProperty() born = ndb.DateTimeProperty() userid = ndb.IntegerProperty() thermostat_set_to = ndb.FloatProperty() snores = ndb.BooleanProperty() started_school = ndb.DateProperty() sleeptime = ndb.TimeProperty() favorite_movies = ndb.JsonProperty() processed = ndb.BooleanProperty(default=False)
If you want to load a data file like this:
[ { "born": "1968-03-03T00:00:00", "first_name": "John", "last_name": "Doe", "favorite_movies": [ "2001", "The Day The Earth Stood Still (1951)" ], "snores": false, "sleeptime": "23:00", "started_school": "1974-02-15", "thermostat_set_to": 18.34, "userid": 1 }, ... { "born": "1980-05-25T00:00:00", "first_name": "Bob", "last_name": "Schneier", "favorite_movies": [ "2001", "Superman" ], "snores": true, "sleeptime": "22:00", "started_school": "1985-08-01", "thermostat_set_to": 18.34, "userid": -5 } ]
All you need to do is to:
from appengine_fixture_loader.loader import load_fixture
and then:
loaded_data = load_fixture('tests/persons.json', Person)
In our example, loaded_data will contain a list of already persisted Person models you can then manipulate and persist again.
History
0.1.0 (2014-10-13)
First release on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for Appengine-Fixture-Loader-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9778f1d3826b139e93e170369e48787dc1a8474b7deaabb400b9e95c38dfe8b3 |
|
MD5 | 1a5ce97cd7b05671ef690235b9e24d69 |
|
BLAKE2b-256 | 5e1a6e4d25ea277259567f5a6e1a9a790e6d41ab7c22de0968c7b7a99f4491a3 |
Close
Hashes for Appengine_Fixture_Loader-0.1.0-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 565cf2af839a9a65b40bba68119e4439c1bfba18f007b86714a6fc76b8004fee |
|
MD5 | 788bed70b34391f63fea4a4a8681032f |
|
BLAKE2b-256 | 5700a1e774c1a2a54736521c269fb3a1cfa67fb93c660b8c672b15f1c5196471 |