def add(restaurant_uid, category_name, dish_name, image_key = None): categories = Category.query(ndb.AND( Category.restaurant_key == ndb.Key(Restaurant, restaurant_uid), Category.name == category_name)).fetch() "TODO: check if category exist. Throw exception if so." return add_by_category_key(categories[0].key, dish_name, image_key)
def get_all_by_restaurant_key(restaurant_key): check_get_restaurant(restaurant_key) return Category.query(Category.restaurant_key == restaurant_key).fetch()
def testInsertEntity(self): category = Category() category.put() self.assertEqual(1, len(Category.query().fetch(2)))