GAE + nosetest error: TypeError: order() expects a

2019-07-02 22:01发布

I have a small python app in google app engine which works and can be manually tested.

I want to start driving the development using tests and I'm trying to use nosetests --with-gae

but I'm getting the following error on testing my handlers:

TypeError: order() expects a Property or query Order; received DateTimeProperty('date')

my models are using ndb datastore.

The offending class is:

import datetime
from google.appengine.ext import ndb

class Event(ndb.Model):
    date = ndb.DateTimeProperty(indexed=True)
    description = ndb.StringProperty(indexed=True)

    @staticmethod
    def get_next_event_by_date():
        next_event = Event.query(Event.date >= datetime.datetime.now()).order(Event.date).fetch(1)
        return next_event[0] if next_event else None

If I remove the order clause from the Event query then the test passes OK.

Anyone got any ideas what might be the problem.

Cheers

Neil

0条回答
登录 后发表回答