2009-10-31 3 views
0

테스트 용으로 여러 모델이있는 고정 장치가 있습니다. 은 기본 모델에서 작동하지만 관계가있는 모델의 엔티티를 만들지 못합니다. 이것은 알려진 app-engine-patch 한계입니까 아니면 무언가 있습니까? JSON을 조명기 파일에 사용하고 있습니다. 고정 장치에관계가있는 조명기는 app-engine-patch에서 작동합니까?

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으로 :

나는 'manage.py dumpdata --format = JSON >> file.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 모델은 올바르게로드되지만 작업은 올바르게로드되지 않습니다.

books = BibleBook.gql('') 
self.assertEquals(books.count(), 1) 
tasks = Task.gql('') 
self.assertEquals(tasks.count(), 1) 

첫 번째 테스트를 통과하지만, 두 번째는하지 않습니다 : 나는 수행하여이를 확인하고있다.

감사합니다,

브라이언 야마 베

+2

조명기는 어떻게 만들었습니까? 로드가 실패한 모델을 포함하여 조명기 샘플을 제공 할 수 있습니까? – cethegeek

답변

1

감사합니다, celopes, 추가 코드를 요청합니다. 나는 json 파일로 놀기로 결정하고 pk의 간단한 숫자를 사용하여 문제를 해결했습니다. 게시 된 모델 및 테스트의 문제를 해결하는 JSON은 다음과 같습니다.

[ 
{"pk": "1", 
"model": "lawandgospel.biblebook", 
"fields": {"name": "Luke", "description": "The Gospel According to St. Luke."}}, 

{"pk": "2", 
"model": "lawandgospel.task", 
"fields": {"empathy": 0, "name": "Study the Gospel of Luke", "level": "Catachumen", 
"energy": 1, "focus": 0, "experience": 1, "drop_percentage": 10, "talents": 0, 
"bibleBook": "1", "percent_per_task": 5, "denarii": 0, 
"description": "The Book of Luke"}} 
]