Пример #1
0
def main(restaurant, order, show_count, token):
    restaurant_id = restaurant
    fig = get_statistics_per_restaurant(restaurant_id, Orders.all(token),
                                        order, int(show_count))
    output = io.BytesIO()
    FigureCanvasSVG(fig).print_svg(output)
    return output.getvalue()
Пример #2
0
 def test_recommendation_output(self):
     token = TestConstants.REST_FOOD_RECOMM_TOKEN
     orders = Orders.all(token)
     decoded = decode(token, Constants.SECRET)
     customer_id = decoded['_id']
     restaurant_id = "5ebcf11126e32517c46effff"
     self.assertEqual(TestConstants.REST_FOOD_RECOMM_OUTPUT,
                      final(customer_id, restaurant_id, orders))
Пример #3
0
    def test_recommendation_output(self):
        token = TestConstants.REST_FOOD_FOR_REST_TOKEN
        orders = Orders.all(token)
        restaurant_id =Restaurants.by_id("5ebcf11126e32517c46effff", token)
        self.assertEqual(TestConstants.REST_FOOD_FOR_REST_OUTPUT, final(restaurant_id, orders))


#127.0.0.1:5000/recommendations/food/5ebcf11126e32517c46effff
#token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWIxNmZkZjRhZmJmNjU0OTY2Y2I2OGQiLCJpYXQiOjE1ODgyMzc0NTZ9.OG3o5XPIDDGlyFusinKVN11w27b5JYCSwLMl9XhYHeI
 def test_recommendation_output1(self):
     token = TestConstants.SEARCH_BY_REST_TOKEN
     decoded = decode(token, Constants.SECRET)
     customer_id = decoded['_id']
     restaurant_prefix = "Ram"
     orders = Orders.all(token)
     reviews= Reviews.by_customer_id(customer_id, token)
     restaurants = Restaurants.all(token)
     self.assertEqual("5ebcf11126e32517c46effff",
     final(reviews, restaurants, orders, customer_id, restaurant_prefix, token)[0]["id"])
Пример #5
0
def recommendForRestaurant(restaurant_id, customer_id, token):
    try:
        foods_ids = final(customer_id, restaurant_id, Orders.all(token))
        foods_data = map(lambda e: Foods.by_id(e, token), foods_ids)

    except Exception as error:
        answer = dict({
            Constants.SUCCESS: "false",
            Constants.ERROR: error.__str__()
        })
        return answer

    answer = dict({Constants.SUCCESS: "true", Constants.DATA: foods_data})
    return answer
Пример #6
0
def main(customer_id, restaurant_prefix, token):

    try:
        restaurants_data = final(Reviews.by_customer_id(customer_id, token),
                                 Restaurants.all(token), Orders.all(token),
                                 customer_id, restaurant_prefix, token)
    except Exception as error:
        answer = dict({
            Constants.SUCCESS: "false",
            Constants.ERROR: error.__str__()
        })
        return answer

    answer = dict({
        Constants.SUCCESS: "true",
        Constants.DATA: restaurants_data
    })
    return answer
Пример #7
0
def main(restaurant_id, token):
    try:
        orders = Orders.all(token)
        orders_with_userid = []
        for order in orders:
            if 'userId' in order:
                orders_with_userid.append(order)
        foods_ids = final(Restaurants.by_id(id=restaurant_id, token=token),
                          orders_with_userid)
        foods_data = map(lambda e: Foods.by_id(e, token), foods_ids)

    except Exception as error:
        answer = dict({
            Constants.SUCCESS: "false",
            Constants.ERROR: error.__str__()
        })
        return answer

    answer = dict({Constants.SUCCESS: "true", Constants.DATA: foods_data})
    return answer
Пример #8
0
def number_of_orders(token):
    fig = main_hours(Orders.all(token))
    output = io.BytesIO()
    FigureCanvasSVG(fig).print_svg(output)
    return output.getvalue()
Пример #9
0
 def test_raise_exception(self):
     self.assertRaises(ValueError, final,  {"_id": "abcdef"}, Orders.all("1234") )
Пример #10
0
 def test_recommendation_output(self):
     token = TestConstants.REST_FOOD_RECOMM_TOKEN
     orders = Orders.all(token)
     customer_id = "5eb16fdf4afbf654966cb68d"
     restaurant_id = "5e9494aadd757435187a6dbd"
     self.assertNotEqual({}, final(customer_id, restaurant_id, orders))
Пример #11
0
 def test_raise_exception(self):
     self.assertRaises(ValueError, final, "12345", "abcdef",
                       Orders.all("1234"))
     self.assertRaises(ValueError, final, "1234",
                       "5eb16fdf4afbf654966cb68d", Orders.all("1234"))