Example #1
0
File: api.py Project: niczy/hyo
 def get(self):
   restaurant_uid = self.request.get(RESTAURANT_UID)
   category_name = self.request.get(CATEGORY_NAME)
   dishes = None
   if restaurant_uid:
     if category_name:
       "TODO: get by restaurant_uid and category name"
       dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
     else:
       dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
   self.send_response(dishes)
Example #2
0
  def testAddAndDeleteDish(self):
    restaurant_uid = 'uid'
    restaurant_logic.add(restaurant_uid, 'fulinmen')
    category_logic.add(restaurant_uid, 'category 1')
    params = {'uid': restaurant_uid, 'category_name': 'category 1', 'name': 'dish 1', "image_data": self.image_data}
    response = self.testapp.post('/api/dish', params)
    self.assertEqual(response.status_int, 200)
    self.assertEqual(json.dumps(response.json), ('{"category_key": "agx0ZXN0YmVkLXRlc3RyDgsSCENhdGVnb3J5GAEM", "img_key": "agx0ZXN0YmVkLXRlc3RyCwsSBUltYWdlGAIM", "restaurant_key": "agx0ZXN0YmVkLXRlc3RyEwsSClJlc3RhdXJhbnQiA3VpZAw", "name": "dish 1", "key": "agx0ZXN0YmVkLXRlc3RyCgsSBERpc2gYAww"}'))
    
    dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
    self.assertEqual(1, len(dishes))

    self.testapp.delete('/api/dish/agx0ZXN0YmVkLXRlc3RyCgsSBERpc2gYAww')
    self.assertEqual(response.status_int, 200)
    dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
    self.assertEqual(0, len(dishes))
Example #3
0
File: pages.py Project: niczy/hyo
 def get(self, restaurant_uid):
   "TODO: get restaurant uid from the path."
   logging.info(restaurant_uid)
   categories = category_logic.get_all_by_restaurant_uid(restaurant_uid)
   dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
   self.render('restaurant.html',
       {"categories": json_encoder.encode(categories),
         "dishes": json_encoder.encode(dishes),
         "restaurant_uid": restaurant_uid})
Example #4
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))