예제 #1
0
    def test_init_menus(self):
        api_dict = {
            "TestBar":
            self.MockAPIPlan(
                self.mockAPI,
                ["shit", "shit", "Stone", "Stone", "Founders"]).executor(),
        }
        good_menu1 = Menu("TestBar", [
            MenuSection("1", "Title1",
                        [Beer("name Stone", "style", 8, "brewery")])
        ])
        good_menu2 = Menu("TestBar", [
            MenuSection("1", "Title1",
                        [Beer("name Founders", "style", 8, "brewery")])
        ])

        mm = MenuManager(api_dict=api_dict)
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({"TestBar": good_menu1}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({"TestBar": good_menu2}, mm.find_good_bars())
예제 #2
0
class TestTelegramBotUtil(unittest.TestCase):

    beer_1 = Beer("Breakfast Stout", "Stout", "8.6", "Founders")
    beer_2 = Beer("Stone IPA", "IPA", "5.6", "Stone")
    section_1 = MenuSection("111", "On Tap (2 bier)", [beer_1, beer_2])
    empty_section = MenuSection("222", "Empty", [])
    menu_1 = Menu("TAP", [section_1, empty_section])
    menu_2 = Menu("FooBar", [section_1, empty_section])

    beer_1_text = "Breakfast Stout\n" \
                    "8.6% ABV\n" \
                    "Stout\n" \
                    "Founders\n"
    beer_2_text = "Stone IPA\n" \
                  "5.6% ABV\n" \
                  "IPA\n" \
                  "Stone\n"
    section_1_text = "_On Tap_ (2 Beers)\n" \
                    "   ---Beer 1---\n" \
                    "{}" \
                    "   ---Beer 2---\n" \
                    "{}".format(beer_1_text, beer_2_text)
    menu_1_text = "*TAP*\n" \
                  "{}".format(section_1_text)

    menu_2_text = "*FooBar*\n" \
                  "{}".format(section_1_text)

    def test_beer_in_markdown(self):
        actual_text = util.beer_to_markdown(self.beer_1)
        self.assertEqual(actual_text, self.beer_1_text)

    def test_menusection_in_markdown(self):
        actual_text = util.section_to_markdown(self.section_1)
        self.assertEqual(actual_text, self.section_1_text)

    def test_menu_in_markdown(self):
        actual_text = util.menu_to_markdown(self.menu_1)
        self.assertEqual(actual_text, self.menu_1_text)

    def test_multiple_menus_in_markdown(self):
        actual_text = util.multiple_menus_to_markdown({
            "TAP": self.menu_1,
            "FooBar": self.menu_2
        })
        self.assertEqual(actual_text,
                         self.menu_1_text + "\n" + self.menu_2_text)
예제 #3
0
 def test_GetMenu(self):
     bars = {
         "TestBar": 0,
     }
     mr = MenuReader(bars)
     expected = Menu("TestBar")
     expected.load_beers_from_file()
     self.assertEqual(expected, mr.get_menu_of("TestBar"))
예제 #4
0
def menu():
    form = request.form
    if session['search'] == "Job Openings":
        result = Menu().search_job(form['start'], form['end'],
                                   form['title']).sort_values(
                                       by=['update_date'], ascending=False)
        return render_template('menu/jobs.html', results=result)
    elif session['search'] == "Company":
        result = Menu().search_company(form['location'], form['region'],
                                       form['country'])
        return render_template('menu/company.html', results=result)
    elif session['search'] == "Both":
        df = Menu().search_both(form['start'], form['end'], form['title'],
                                form['location'], form['region'],
                                form['country'])
        result = Menu().group_by(df, 'locality').sort_values(by='count',
                                                             ascending=False)
        return render_template('menu/openings.html', results=result)
예제 #5
0
 def __init__(self):
     self.name = ""
     self.owner = Owner()
     self.description = ""
     self.clientele = ""
     self.costPerNight = ""
     self.menu = Menu()
     self.lifestyle = Lifestyle.SQUALID
     self.cost = ""
예제 #6
0
 def post(self):
     from models.menu import Menu
     from app import db
     m = Menu()
     m.app_id = self.app_id
     m.name = request.json.get('name')
     m.parent_id = request.json.get('parent_id', None)
     m.refer_path = request.json.get('refer_path', None)
     db.session.add(m)
     db.session.commit()
예제 #7
0
def map():
    if request.method == "POST":
        if 'company' in request.form:
            company = request.form['company']
            continent = request.form['continent']
            current_app.logger.info(continent)
            return render_template('menu/map.html', continent=continent)
        if 'title' in request.form:
            form = request.form
            result = Menu().search_job(form['start'], form['end'],
                                       form['title']).sort_values(
                                           by=['update_date'], ascending=False)
            current_app.logger.info("Get the titles")
            return render_template('menu/map.html', results=result)
    return render_template('menu/map.html')
예제 #8
0
    def build_menu_from_html(self, page):
        tree = html.document_fromstring(page)
        m = Menu(self.bar_name)

        # Get all menu sections
        sections = tree.find_class("menu-section")

        for section in sections:
            # Get section details
            section_id_string = section.get("id")
            section_id = re.search("section_(.+?)$",
                                   section_id_string).group(1)
            title = self.sanitize_markdown_characters(
                section.find_class("menu-section-header")[0].text_content())
            beer_list = section.find_class("menu-section-list")
            beers = beer_list[0].getchildren()
            # If not all beers are loaded
            if len(section.find_class("show-more-section")) > 0:
                logging.debug(
                    "Loading more beers for {}.".format(section_id_string))
                beers += self.load_section(section_id)

            # There are beers in this section
            if len(beers) > 0:
                ms = MenuSection(section_id, title)
                for beer in beers:
                    details = beer.find_class("beer-details")[0]
                    h5, h6 = details.getchildren()
                    name, style = h5.getchildren()
                    abv = h6.getchildren()[0]
                    brewery = h6.getchildren()[0].getchildren()[0]
                    ms.beers.append(
                        Beer(
                            self.sanitize_markdown_characters(
                                name.text_content()),
                            self.sanitize_markdown_characters(
                                style.text_content()),
                            self.sanitize_markdown_characters(
                                self.get_abv_from_span(abv.text_content())),
                            self.sanitize_markdown_characters(
                                brewery.text_content())))
                m.sections.append(ms)
        return m
예제 #9
0
 def __init__(self, window):
     self.window = window
     self.menu = Menu(window)
     self.pantallaJuego = None
     self.jugadores = []
     self.numeroRonda = 0
     self.dado = Dado(300, 300, 100, 100, self.window)
     self.temporizador = None
     self.mazoPuzzles = []
     self.numeroJugadores = 0
     self.enJuego = False
     self.enMenu = True
     self.enRonda = False
     self.finRonda = False
     self.limiteFilasPorJugadorEnRonda = [0 for _ in range(4)]
     self.numeroGanadores = 0
     self.maximoMovimientosFichas = 0
     self.tiempoAuxiliar = 0
     self.tiempoAleatorio = 0
예제 #10
0
def get_taverns():
    menu = Menu()
    menu.breakfast = "poached eggs and potatoes and cup of fruit"
    menu.lunch = "chicken noodle soup"
    menu.dinner = "steak and green beans"
    menu.lifestyle = Lifestyle.WEALTHY
    owner = Owner()
    owner.name = "Gentlemen Johnny"
    owner.description = "A well dressed copper dragonborn full of mirth"
    tavern = Tavern()
    tavern.name = "Countryside Palace"
    tavern.clientele = "A single young man sipping a cup of tea."
    tavern.description = "A victorian style house with a cozy hearth and colorful fabrics"
    tavern.lifestyle = Lifestyle.WEALTHY
    tavern.menu = menu
    tavern.owner = owner
    tavern_list = list()
    tavern_list.append(tavern)
    return tavern_list
예제 #11
0
파일: app.py 프로젝트: AdamF42/acmEat
import json

from models.menu import Menu
from models.order import Order
from flask import jsonify, request, abort
from models.status import Status
from repo.menu_repository import menu
from utils.app_creator import create_app

app = create_app('RestaurantService')

my_menu = Menu(menu)


# ======== Routing =========================================================== #
# -------- PlaceOrder _------------------------------------------------------- #
@app.route('/restaurant/order', methods=['PUT'])
def place_order():
    if 'id' not in request.json:
        abort(400)
    order = json.dumps(request.json)
    order = json.loads(order)
    order = Order.get_order_by_id(order['id'])
    if order.get("status", None) is None:
        order['status'] = Status.NOT_AVAILABLE.name
        return jsonify(order)

    if order['status'] == Status.AVAILABLE.name:
        order['status'] = Status.ACCEPTED.name

    return jsonify(order)
예제 #12
0
def set_menu():
    """
    Set Menu 
    BOOK-A-MEAL API
    Set menu for the day
    ---
    tags:
      - meals
    parameters:
      - in: body
        name: body
        schema:
          id: set_menu
          required:
            - meal_ids
            - user_id
          properties:
            meal_ids:
              type: string
              description: meal name
              default: [1,3,5]
            user_id:
              type: integer
              description: user id
              default: 3 
    responses:
      400:
        description: 
      201:
        description: Order Made
        schema:
          id: menu
          properties:
            id:
              type: integer
              description: price for meal
              default: 3
            meal_ids:
              type: string
              description: meal ids
              default: [1,3,5]
            user_ids:
              type: integer
              description: user id
              default: 3 
            created_at:
              type: string
              description: time created menu
              default: Fri, 04 May 2018 00:10:06 GMT
            updated_at:
              type: string
              description: time updated menu
              default: Fri, 04 May 2018 00:10:06 GMT   

    """
    """ Setting menu 
       We need to cocatenate the items in the lsit with a special character into a string
       And when retrieving it we return it into a string

    """

    if not request.get_json() or 'meal_ids' not in request.get_json()\
    or 'user_id' not in request.get_json():
        abort(400)
    """ We need to check if the id exist in the meals"""

    meal_ids = request.get_json().get('meal_ids')
    user_id = request.get_json().get('user_id')

    if len(meal_ids) == 0:
        return jsonify({'message': 'No meals sent for menu'}), 400

    caterer = Menu.query.filter_by(user_id=user_id).first()
    if caterer is not None:
        return jsonify({'message':
                        'Caterer Already Set Menu For the Day'}), 400

    meal_ids_string = ""
    for ids in meal_ids:
        meal_ids_string += ';%s' % ids

    menu = Menu(user_id=user_id, meal_ids=meal_ids_string)
    db.session.add(menu)
    db.session.commit()

    menu_info = {}
    menu_info['id'] = menu.id
    menu_info['user_id'] = menu.user_id
    """ Converting the meal ids into a list again """
    converted_meal_ids = []
    for idx in menu.meal_ids.split(';'):
        if idx != "":
            converted_meal_ids.append(int(idx))

    menu_info['meal_ids'] = converted_meal_ids
    menu_info['created_at'] = menu.created_at
    menu_info['updated_at'] = menu.updated_at

    return jsonify({'message':'Menu Successfully Created',\
      'menu': menu_info}), 201
예제 #13
0
 def __init__(self, bars):
     for api in bars.keys():
         self.menus[api] = Menu(api)
         self.menus[api].load_beers_from_file()
     logging.info("MenuReader Initialized")
예제 #14
0
파일: app.py 프로젝트: jcromerohdz/FlaskDev
from models.post import Post
from models.database import Database
from models.blog import Blog
from models.menu import Menu

__author__ = 'jcrh'

Database.initialize()

menu = Menu()
menu.run_menu()

# blog = Blog(author='Christian',
#             title='My title',
#             description='Sample description')
#
# blog.new_post()
#
# print(blog.id)
#
# from_database = Blog.get_from_mongo(blog.id)
#
# print(blog.get_posts())

# Insert to mongo
# post = Post(blog_id='12345',
#             title='Super post',
#             content='This the content we send by the app',
#             author='Christian')

#post.save_to_mongo()
예제 #15
0
import pygame
from models.menu import Menu
from models.Juego import Juego

mesa = pygame.image.load('assets/Fondos/fondo mesa.png')
pygame.init()


window = pygame.display.set_mode((1920, 1080))
#window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

pygame.display.set_caption("Prueba")
run = True
menu = Menu(window)
ubongo = Juego(window)


#kejestooo?
paraTirarDado = 0

while run:
    window.fill((0, 0, 0))
    window.blit(mesa, (0, 0))

    if ubongo.enMenu:
        ubongo.dibujarMenu()
    elif ubongo.enJuego:
        ubongo.dibujarJuego()

    pygame.display.update()
예제 #16
0
# Game variables
gameOver = False
gameStarted = False
score = 0
highscore = 0

pygame.init()

pygame.display.set_caption("Snake Game")
window = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

grid = Grid(window, SCREEN_WIDTH, SCREEN_HEIGHT, SQUARE_SIZE)
snake = Snake(snake_pos_x, snake_pos_y, snake_dir, SQUARE_SIZE)
food = Food(15, 15, SCREEN_WIDTH / SQUARE_SIZE, SCREEN_HEIGHT / SQUARE_SIZE,
            SQUARE_SIZE)
menu = Menu(window, SCREEN_WIDTH, SCREEN_HEIGHT)

clock = pygame.time.Clock()

while True:
    pygame.time.delay(40)
    clock.tick(10)

    if gameStarted == False:
        menu.draw(score, highscore)

    if gameOver == False and gameStarted:
        grid.draw(snake, food)

        snake.move()
예제 #17
0
 def mockAPI(self, beername=""):
     return Menu("TestBar", [
         MenuSection("1", "Title1",
                     [Beer("name " + beername, "style", 8, "brewery")])
     ])
예제 #18
0
 def parse_menu(cls) -> Menu:
     content = cls.get_page_content()
     main_dishes = cls.parse_main_dishes(content)
     soups = cls.parse_soups(content)
     return Menu(main_dishes, soups)
예제 #19
0
__author__ = "mohsin"

from database import Database
from models.post import Post
from models.blog import Blog
from models.menu import Menu

Database.initialize()

main_menu = Menu()

# my_blog = Blog(author="Mohsin", title="My Adventures", description="Some musings about my travels")
# my_blog.save_to_mongo()
# my_blog.new_post()

#my_blog = Blog.get_from_mongo("4a24cb4444334ab78a63013f1306ab85")
#post_cursor = my_blog.get_posts()

#for post in post_cursor:
#    print(post)

# new_blog = Blog(author="Mac", title="Shiba Summers", description="The summer of a shiba")
# new_blog.save_to_mongo()
# new_blog.new_post()

#new_blog = Blog.get_from_mongo("e79d9b9bab9b4a25b0685f20067f6a0d")
#new_blog_cursor = new_blog.get_posts()

#for post_document in new_blog_cursor:
#    print(post_document)
예제 #20
0
from models.menu import Menu

Menu()
예제 #21
0
파일: forcook.py 프로젝트: Moai-Team/cook
            record = Time(**{'id': i[0], 'minutes': i[1]})
            session3.add(record)

        data4 = Load_Data_1("csv/1categories.csv")
        for i in data4:
            record = Categories(**{'id': i[0], 'category_name': i[1]})
            session3.add(record)

        data5 = Load_Data_1("csv/1cuisine.csv")
        for i in data5:
            record = Cuisine(**{'id': i[0], 'cuisine_name': i[1]})
            session3.add(record)

        data6 = Load_Data_1("csv/1menu.csv")
        for i in data6:
            record = Menu(**{'id': i[0], 'menu_name': i[1]})
            session3.add(record)

        data7 = Load_Data_3("csv/1recipe_has_ingredients.csv")
        for i in data7:
            record = Recipe_has_ingredients(**{
                'recipe_id': i[0],
                'ingredients_id': i[1]
            })
            session3.add(record)

        data8 = Load_Data_3("csv/1recipe_has_categories.csv")
        for i in data8:
            record = Recipe_has_categories(**{
                'recipe_id': i[0],
                'categories_id': i[1]