Ejemplo n.º 1
0
    def setUpClass(cls):
        cls.app = app
        cls.client = cls.app.test_client()

        cls.app.app_context().push()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False
Ejemplo n.º 2
0
def create_db_entries():

    print "Creating new DB"
    
    # recreate database structure
    db.drop_all()
    db.create_all()
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls.app = app

        cls.app.app_context().push()
        db.session.remove()
        db.drop_all()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False
Ejemplo n.º 4
0
 def setUpClass(cls):
     cls.app = new_app
     cls.app.app_context().push()
     db.create_all()
     shop = models.Shop(domain=cls.SHOP_DOMAIN)
     db.session.add(shop)
     db.session.commit()
     cls.SHOP_ID = shop.id
Ejemplo n.º 5
0
    def refresh_db(cls):
        db.session.remove()
        db.drop_all()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False

        db_dir = os.path.join(basedir, 'install', 'db', cls.app.config.get('MODE'))
        import_tables(db, db_dir)
Ejemplo n.º 6
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     db.create_all()
     # add an initial timestamp, address, and update count
     db.session.add_all([
         UpdateCheck(),
         Address(address="@test-address.com"),
         Counter(count=0)
         ])
     db.session.commit()
Ejemplo n.º 7
0
    def setUpClass(cls):
        cls.app = app
        cls.master_client = cls.app.test_client()

        cls.desktop_client = cls.app.test_client()
        cls.mobile_client = cls.app.test_client()

        def override_method(method, ua):
            def om_wrapper(*args, **kwargs):
                kwargs = common.inject_ua(ua, kwargs)
                return getattr(cls.master_client, method)(*args, **kwargs)

            return om_wrapper

        cls.desktop_client.get = override_method('get', Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.post = override_method('post', Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.put = override_method('put', Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.patch = override_method('patch', Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.delete = override_method('delete', Constants.DESKTOP_USER_AGENT)

        cls.mobile_client.get = override_method('get', Constants.MOBILE_USER_AGENT)
        cls.mobile_client.post = override_method('post', Constants.MOBILE_USER_AGENT)
        cls.mobile_client.put = override_method('put', Constants.MOBILE_USER_AGENT)
        cls.mobile_client.patch = override_method('patch', Constants.MOBILE_USER_AGENT)
        cls.mobile_client.delete = override_method('delete', Constants.MOBILE_USER_AGENT)

        cls.app.app_context().push()
        db.session.remove()
        db.drop_all()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False

        db_dir = os.path.join(basedir, 'install', 'db', cls.app.config.get('MODE'))
        import_tables(db, db_dir)

        admin_role = Role.query.filter_by(name=Constants.ADMIN_ROLE).first()
        cls.admin_user = User.query.filter_by(id=1).first()
        assert admin_role in cls.admin_user.roles
        cls.admin_password = sensitive.ADMIN_PASSWORD

        reviewer_role = Role.query.filter_by(name=Constants.REVIEWER_ROLE).first()
        cls.reviewer_user = User.query.filter_by(id=2).first()
        assert cls.reviewer_user.has_role(reviewer_role)
        cls.reviewer_password = sensitive.TEST_REVIEWER_PASSWORD

        shop_owner_role = Role.query.filter_by(name=Constants.SHOP_OWNER_ROLE).first()
        cls.shop_owner_user = User.query.filter_by(id=3).first()
        assert cls.shop_owner_user.has_role(shop_owner_role)
        cls.shop_owner_password = sensitive.TEST_SHOP_OWNER_PASSWORD

        cls.vserver = VirtualServerManager()
        cls.vserver.start()

        common.verify_initialization()
Ejemplo n.º 8
0
 def setUpClass(cls):
     cls.app = new_app
     cls.app.app_context().push()
     db.create_all()
     cls.SHOP_OWNER_USER = models.User()
     shop = models.Shop(owner=cls.SHOP_OWNER_USER)
     shop_not_owned = models.Shop()
     db.session.add(shop)
     db.session.add(shop_not_owned)
     db.session.commit()
     cls.SHOP_ID = shop.id
     cls.SHOP_NOT_OWNED_ID = shop_not_owned.id
Ejemplo n.º 9
0
    def setUp(self):
        self.app = app.test_client()
        self.app_context = app.app_context()
        self.app_context.__enter__()
        db.drop_all()
        db.create_all()

        self.user1 = User('user1', '123456')
        self.user2 = User('user2', '123456')
        db.session.add(self.user1)
        db.session.add(self.user2)
        db.session.commit()
Ejemplo n.º 10
0
def create_user(email, password, admin=False):
    """ Create a test user """
    db.create_all()
    user = user_datastore.create_user(email=email, password=password)
    db.session.commit()
    print "User created."
    if admin:
        admin_role = Role.query.filter_by(name='admin').first()
        if admin_role is None:
            admin_role = Role(name='admin', description='Administrators')
            db.session.add(admin_role)
        admin_role.users.append(user)
        db.session.commit()
Ejemplo n.º 11
0
	def action(ip=('i', default_ip)):
		"""
		Installs a new database configuration for the appliance.
		"""

		# create all tables
		db.create_all()
		
		if not Appliance.get():
			# initialize the appliance object
			appliance = Appliance()
			appliance.initialize(ip)

		# sync flavors from pool (openstack sync comes later when we have a user)
		flavors = Flavors().sync()

		# configure output
		configure_blurb()
Ejemplo n.º 12
0
    def setUpClass(cls):
        cls.app = new_app
        cls.client = cls.app.test_client()
        cls.app.app_context().push()
        db.create_all()
        # create db fixtures
        r = cls.register(cls.REVIEW_USER_EMAIL, cls.REVIEW_USER_PWD)
        cls.REVIEW_USER = models.User.query.first()
        db.session.add(cls.REVIEW_USER)

        review = models.Review.create_from_import(user=cls.REVIEW_USER)
        not_your_review = models.Review()

        db.session.add(review)
        db.session.add(not_your_review)
        db.session.commit()

        cls.REVIEW_ID = review.id
        cls.NOT_YOUR_REVIEW_ID = not_your_review.id
Ejemplo n.º 13
0
    def refresh_db(cls):
        db.session.remove()
        db.drop_all()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False
        cls.basedir = os.path.abspath(os.path.dirname(__file__))

        shop_owner_role = Role(name=Constants.SHOP_OWNER_ROLE, description="Shop owner")
        cls.shop_owner = User(email=testing_constants.NEW_USER_EMAIL,
                              name=testing_constants.NEW_USER_NAME,
                              password=testing_constants.NEW_USER_PWD,
                              roles=[shop_owner_role], is_shop_owner=True,
                              confirmed_at = datetime.datetime.utcnow()
                              )
        cls.shopify_shop = Shop(name=testing_constants.SHOPIFY_SHOP_NAME, owner=cls.shop_owner)
        cls.yotpo_shop = Shop(name=testing_constants.YOTPO_SHOP_NAME, owner=cls.shop_owner)
        db.session.add(cls.shop_owner)
        db.session.add(cls.shopify_shop)
        db.session.add(cls.yotpo_shop)
        db.session.commit()
        cls.shopify_importer = import_shopify.ShopifyImpoter(shop_id=cls.shopify_shop.id)
        cls.yotpo_importer = import_yotpo.YotpoImpoter(shop_id=cls.yotpo_shop.id)
Ejemplo n.º 14
0
	def action(ip=('i', default_ip)):
		"""
		Restores the appliance to factory default settings.
		"""
		try:
			if ip == default_ip:
				print "Please enter the appliance's IP address."
				print "Usage: ./manage.py reset -i x.x.x.x"
				return action

			# double check they want to do this	
			if query_yes_no("Are you sure you want to reset the appliance?"):

				# initialize database
				path = os.path.dirname(os.path.abspath(__file__))
				os.system('cp "%s/utterio.db" "%s/utterio_backup.db"' % (path, path))

				# delete, then create all tables
				db.drop_all()
				db.create_all()

				# initialize the appliance object
				appliance = Appliance()
				appliance.initialize(ip)

				# sync with pool database
				flavors = Flavors().sync()

				if flavors['response'] != "success":
					print flavors['result']
				else:
					print "The database has been cleared and a new API token has been generated."
					configure_blurb()

		except ValueError as ex:
			print ex
Ejemplo n.º 15
0
 def setUp(self):
     self.in_string = "Salut GrandPy ! Est-ce que tu connais l'adresse d'Openclassrooms à Paris ?"
     db.create_all()
     for key in app.config["DATA_LOAD_CONFIG"].keys():
         FiletoDbHandler(db, key)()
Ejemplo n.º 16
0
def create_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
Ejemplo n.º 17
0
 def refresh_db(self):
     db.session.remove()
     db.drop_all()
     db.create_all()
     db.engine.dialect.supports_sane_multi_rowcount = False
Ejemplo n.º 18
0
def init_db():
	db.create_all()
Ejemplo n.º 19
0
 def setUp(self):
     self.app = create_app(TestingConfig)
     db.create_all()
Ejemplo n.º 20
0
def createdb():
    """ Creates a database with all of the tables defined in
        your Alchemy models
    """

    db.create_all()
Ejemplo n.º 21
0
def init():
    db.create_all()
Ejemplo n.º 22
0
from webapp import db, create_app

db.drop_all(app=create_app())
db.create_all(app=create_app())
Ejemplo n.º 23
0
    cancer = db.Column(db.String(100)) # db.ForeignKey('cancer.id')
    intervention = db.Column(db.String(100)) #db.ForeignKey('intervention.id')
    association_id = db.Column(db.Integer, db.ForeignKey('association.id'))

    def __repr__(self):
        return f"Article('{self.pmid}', '{self.title}')"

#
# class Article_Has_Association(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     article_id = db.Column(db.Integer, db.ForeignKey('article.id'))
#     cancer_id = db.Column(db.Integer, db.ForeignKey('cancer.id'))
#     intervention_id = db.Column(db.Integer, db.ForeignKey('intervention.id'))
#     therapeutic_association_id = db.Column(db.Integer, db.ForeignKey('therapeutic_association.id')

db.create_all()

c_df = pd.read_csv("webapp/cancers.csv", header=None)
#import pdb; pdb.set_trace()
cancers = c_df[0].values
for c in cancers:
    not_exists = db.session.query(
    Cancer.cancer_type
    ).filter_by(cancer_type=c).scalar() is None
    if not_exists:
        new_c = Cancer(cancer_type=c)
        db.session.add(new_c)

d_df = pd.read_csv("webapp/drugs.csv", header=None)
#import pdb; pdb.set_trace()
drugs = d_df[0].values
Ejemplo n.º 24
0
 def refresh_db(self):
     db.session.remove()
     db.drop_all()
     db.create_all()
     db.engine.dialect.supports_sane_multi_rowcount = False
Ejemplo n.º 25
0
def init_db():
    try:
        db.create_all()
        return json.dumps({'success': 'Init success'})
    except Exception as e:
        return json.dumps({'error': str(e), 'repr': repr(e)})
Ejemplo n.º 26
0
    def setUpClass(cls):
        cls.app = app
        cls.master_client = cls.app.test_client()

        cls.desktop_client = cls.app.test_client()
        cls.mobile_client = cls.app.test_client()

        def override_method(method, ua):
            def om_wrapper(*args, **kwargs):
                kwargs = common.inject_ua(ua, kwargs)
                return getattr(cls.master_client, method)(*args, **kwargs)

            return om_wrapper

        cls.desktop_client.get = override_method('get',
                                                 Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.post = override_method('post',
                                                  Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.put = override_method('put',
                                                 Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.patch = override_method(
            'patch', Constants.DESKTOP_USER_AGENT)
        cls.desktop_client.delete = override_method(
            'delete', Constants.DESKTOP_USER_AGENT)

        cls.mobile_client.get = override_method('get',
                                                Constants.MOBILE_USER_AGENT)
        cls.mobile_client.post = override_method('post',
                                                 Constants.MOBILE_USER_AGENT)
        cls.mobile_client.put = override_method('put',
                                                Constants.MOBILE_USER_AGENT)
        cls.mobile_client.patch = override_method('patch',
                                                  Constants.MOBILE_USER_AGENT)
        cls.mobile_client.delete = override_method('delete',
                                                   Constants.MOBILE_USER_AGENT)

        cls.app.app_context().push()
        db.session.remove()
        db.drop_all()
        db.create_all()
        db.engine.dialect.supports_sane_multi_rowcount = False

        db_dir = os.path.join(basedir, 'install', 'db',
                              cls.app.config.get('MODE'))
        import_tables(db, db_dir)

        admin_role = Role.query.filter_by(name=Constants.ADMIN_ROLE).first()
        cls.admin_user = User.query.filter_by(id=1).first()
        assert admin_role in cls.admin_user.roles
        cls.admin_password = sensitive.ADMIN_PASSWORD

        reviewer_role = Role.query.filter_by(
            name=Constants.REVIEWER_ROLE).first()
        cls.reviewer_user = User.query.filter_by(id=2).first()
        assert cls.reviewer_user.has_role(reviewer_role)
        cls.reviewer_password = sensitive.TEST_REVIEWER_PASSWORD

        shop_owner_role = Role.query.filter_by(
            name=Constants.SHOP_OWNER_ROLE).first()
        cls.shop_owner_user = User.query.filter_by(id=3).first()
        assert cls.shop_owner_user.has_role(shop_owner_role)
        cls.shop_owner_password = sensitive.TEST_SHOP_OWNER_PASSWORD

        cls.vserver = VirtualServerManager()
        cls.vserver.start()

        common.verify_initialization()
Ejemplo n.º 27
0
 def setUp(self):
     self.app = app.test_client()
     db.create_all()
Ejemplo n.º 28
0
def initdb(clean=False):
    """ Creates db schema """
    if clean:
        clean_index()
    db.create_all()
    print "DB inited."
Ejemplo n.º 29
0
from webapp import db, create_app

db.create_all(app=create_app())  # прошу db создать ВСЕ модели для этого приложения
Ejemplo n.º 30
0
def create_all():
    db.create_all()
Ejemplo n.º 31
0
def calculate_contrib_area():
    db.create_all()
    ContribState.fill()
    ContribDistrict.fill()
Ejemplo n.º 32
0
def setup_module():
    app.config['SQLALCHEMY_DATABASE_URI'] = HEROKU_POSTGRESQL_CHARCOAL_URL
    app.config['WTF_CSRF_ENABLED'] = False
    db.create_all()
Ejemplo n.º 33
0
 def setUp(self):
     self.app = app.test_client()
     db.create_all()
Ejemplo n.º 34
0
from webapp import db, create_app

db.create_all(app=create_app())  # создаем базу данных
Ejemplo n.º 35
0
"""
Create the Team Accolade database.
"""

from webapp import db

# Create the database based on the model.
db.create_all()
def setup_module():
    app.config['SQLALCHEMY_DATABASE_URI'] = HEROKU_POSTGRESQL_CHARCOAL_URL
    db.create_all()
Ejemplo n.º 37
0
from webapp import db, app
db.create_all(app=app)
Ejemplo n.º 38
0
def start_test_server():
    with app.app_context():
        db.drop_all()
        db.create_all()
    server.start()
Ejemplo n.º 39
0
    __bind_key__ = 'sample_bind'
    __tablename__ = "my_table"

    id = Column(Integer, primary_key=True)
    versions = Column(String(255))
    name = Column(String(255))


try:
    os.remove("webapp/sample.db")
except:
    pass

app = create_app("config.Config")

with app.app_context():

    db.create_all(bind=['sample_bind'], app=app)

    row1 = MyTable()
    row1.versions = "1"
    row1.name = "The First Version"

    row2 = MyTable()
    row2.versions = "1.1"
    row2.name = "The First Version With Lots Of BugFix"

    db.session.add(row1)
    db.session.add(row2)
    db.session.commit()
Ejemplo n.º 40
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
     db.create_all()
Ejemplo n.º 41
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Ejemplo n.º 42
0
def init_db():
    try:
        db.create_all()
        return json.dumps({'success': 'Init success'})
    except Exception as e:
        return json.dumps({'error': str(e), 'repr': repr(e)})