我有一个用于测试的具有多个模型的夹具。它适用于基本模型,但无法为具有关系的模型创建实体。这是 app-engine-patch 的已知限制还是我遗漏了什么?我正在使用 JSON 作为夹具文件。
我正在使用“manage.py dumpdata --format=json >> file.json”创建夹具文件
以下是涉及的模型:
class BibleBook(db.Model):
name = db.StringProperty(required=True)
description = db.TextProperty(required=True)
class Task(db.Model):
name = db.StringProperty(required=True)
description = db.TextProperty(required=True)
energy = db.IntegerProperty(default=1)
focus = db.IntegerProperty(default=0)
empathy = db.IntegerProperty(default=0)
denarii = db.IntegerProperty(default=0)
talents = db.IntegerProperty(default=0)
experience = db.IntegerProperty(default=1)
percent_per_task = db.IntegerProperty(default=5)
bibleBook = db.ReferenceProperty(BibleBook)
level = db.StringProperty(required=True, choices=set(["Catachumen", "Laymen", "Elder"]))
drop_percentage = db.IntegerProperty(default=10)
夹具文件中的 json 如下所示:
[
{"pk": "ag5sYXctYW5kLWdvc3BlbHIcCxIWbGF3YW5kZ29zcGVsX2JpYmxlYm9vaxgDDA",
"model": "lawandgospel.biblebook",
"fields": {"name": "Luke", "description": "Description"}},
{"pk": "ag5sYXctYW5kLWdvc3BlbHIXCxIRbGF3YW5kZ29zcGVsX3Rhc2sYBQw",
"model": "lawandgospel.task",
"fields": {"empathy": 0, "name": "Study Luke", "level": "Catachumen", "energy": 1,
"focus": 0, "experience": 1, "drop_percentage": 10, "talents": 0,
"bibleBook": "ag5sYXctYW5kLWdvc3BlbHIcCxIWbGF3YW5kZ29zcGVsX2JpYmxlYm9vaxgDDA",
"percent_per_task": 5, "denarii": 0, "description": "The Book of Luke"}}
]
BibleBook 模型正确加载,但 Task one 没有。我正在通过以下方式检查:
books = BibleBook.gql('')
self.assertEquals(books.count(), 1)
tasks = Task.gql('')
self.assertEquals(tasks.count(), 1)
第一个测试通过,但第二个没有。
谢谢,
布莱恩·山部