Error GAE + nosetest: TypeError: order () expects a property request or request;

I have a small python application in the Google engine that works and can be checked manually.

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

but I get the following error when testing my handlers:

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

my models use ndb datastore.

Violation Class:

 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 request, the test will pass OK.

Anyone have any ideas what might be the problem.

Greetings

Neil

+3
source share

Source: https://habr.com/ru/post/1265226/


All Articles