Пример #1
0
 def testGetDishes(self):
   restaurant_uid = 'uid'
   category_name = 'soup'
   restaurant_logic.add(restaurant_uid, 'fulinmen')
   category_logic.add(restaurant_uid, category_name)
   dish_logic.add(restaurant_uid, category_name, 'Dish 1')
   dish_logic.add(restaurant_uid, category_name, 'Dish 2')
   response = self.testapp.get('/api/dish?uid=%s' % restaurant_uid)
   self.assertEqual(response.status_int, 200)
   self.assertEqual(json.dumps(response.json), '[{"category_key": "agx0ZXN0YmVkLXRlc3RyDgsSCENhdGVnb3J5GAEM", "img_key": null, "restaurant_key": "agx0ZXN0YmVkLXRlc3RyEwsSClJlc3RhdXJhbnQiA3VpZAw", "name": "Dish 1", "key": "agx0ZXN0YmVkLXRlc3RyCgsSBERpc2gYAgw"}, {"category_key": "agx0ZXN0YmVkLXRlc3RyDgsSCENhdGVnb3J5GAEM", "img_key": null, "restaurant_key": "agx0ZXN0YmVkLXRlc3RyEwsSClJlc3RhdXJhbnQiA3VpZAw", "name": "Dish 2", "key": "agx0ZXN0YmVkLXRlc3RyCgsSBERpc2gYAww"}]')
Пример #2
0
  def test_add_and_get_dishes(self):
    restaurant = restaurant_logic.add('FulinMen', 'restaurant', self.image_key)
    category = category_logic.add(restaurant.key, "category")
    dish_logic.add_by_category_key(category.key, 'Dish1')
    dish_logic.add_by_category_key(category.key, 'Dish2')
    dishes = dish_logic.get_all_by_category_key(category.key)
    self.assertEqual(2, len(dishes))
    "Test adding by restaurant_uid and category name"
    dish_logic.add('FulinMen', 'category', 'Dish3')
    dish_logic.add('FulinMen', 'category', 'Dish4')
    dishes = dish_logic.get_all_by_category_key(category.key)
    self.assertEqual(4, len(dishes))

    dishes = dish_logic.get_all_by_restaurant_uid('FulinMen')
    self.assertEquals(4, len(dishes))

    dish_logic.delete_by_id(dishes[0].key.id())
    dishes = dish_logic.get_all_by_restaurant_uid('FulinMen')
    self.assertEquals(3, len(dishes))
Пример #3
0
Файл: api.py Проект: niczy/hyo
 def post(self):
   restaurant_uid = self.request.get(RESTAURANT_UID)
   category_name = self.request.get(CATEGORY_NAME)
   dish_name = self.request.get(NAME)
   dish_image_data = self.request.get(IMAGE_DATA)
   img_key = None
   if dish_image_data:
     image = Image.from_image_data(dish_image_data) 
     image.put()
     img_key = image.key
   dish = dish_logic.add(restaurant_uid, category_name, dish_name, img_key)
   self.send_response(dish)