Example #1
0
File: tests.py Project: ryanhle/idb
    def setUp(self):
        self.engine = create_engine('sqlite:///:memory:', echo=False)
        Session = sessionmaker(bind=self.engine)
        session = Session()

        Base.metadata.create_all(self.engine)
        session.commit()
        self.db = Database(self.engine)
        self.session = session
Example #2
0
File: tests.py Project: ryanhle/idb
    def setUp(self):
        self.engine = create_engine('sqlite:///:memory:', echo=False)
        Session = sessionmaker(bind=self.engine)
        session = Session()

        Base.metadata.create_all(self.engine)

        iPhoneX = Model(name="Apple iPhoneX")
        iPhoneX.brand = Brand(name="Apple", location="Cupertino, United States")
        iPhoneX.os = OS(name="iOS", developer="Apple")

        session.add(iPhoneX)
        session.commit()

        self.db = Database(self.engine)
Example #3
0
File: tests.py Project: ryanhle/idb
    def setUp(self):
        self.engine = create_engine('sqlite:///:memory:', echo=False)
        Session = sessionmaker(bind=self.engine)
        session = Session()

        Base.metadata.create_all(self.engine)

        lgv10 = Model(name="LG v10")
        lgv10.brand = Brand(name="LG", location="Seoul, South Korea")
        lgv10.os = OS(name="Android", developer="Google")
        lgv10.carriers = [Carrier(name="Verizon")]

        session.add(lgv10)
        session.commit()

        self.db = Database(self.engine)
Example #4
0
File: tests.py Project: ryanhle/idb
    def setUp(self):
        self.engine = create_engine('sqlite:///:memory:', echo=False)
        Session = sessionmaker(bind=self.engine)
        session = Session()

        Base.metadata.create_all(self.engine)

        lgv10 = Model(name="LG v10")
        lgv10.brand = Brand(name="LG", location="Seoul, South Korea")
        lgv10.os = OS(name="Android", developer="Google")
        lgv10.carriers = [Carrier(name="Verizon")]
        lgv10.release_date = "10/02/2015"
        lgv10.hardware_designer = "LG"
        lgv10.market_countries = "South Korea"
        lgv10.market_regions = "Asia"

        session.add(lgv10)
        session.commit()

        self.db = Database(self.engine)
Example #5
0
File: main.py Project: fgj54jrt/idb
from flask import Flask, render_template, jsonify
from functools import lru_cache
import os

app = Flask(__name__)

from app.db_interface import Database

db = Database()


@app.route('/')
@lru_cache(maxsize=1)
def hello_world():
    return render_template('index.html')


@app.route('/vis')
@lru_cache(maxsize=1)
def visualize():
    return render_template('vis.html')


@app.route('/models', methods=['GET'])
@lru_cache(maxsize=1)
def models_get():
    return jsonify([model.serialize() for model in db.get_model_all()])


@app.route('/brands', methods=['GET'])
@lru_cache(maxsize=1)