Ejemplo n.º 1
0
def create_db_entries():

    print "Creating new DB"
    
    # recreate database structure
    db.drop_all()
    db.create_all()
Ejemplo n.º 2
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.º 3
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.º 4
0
def db_reset(create=False, pr=False):
    db.drop_all()
    db.create_all()

    if create:
        create_user(pr)
        create_board(pr)
        create_card(pr)
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
0
def app():
    test_app = create_app(env='testing')

    with test_app.app_context():
        db.create_all()

        yield test_app

        db.session.remove()
        db.drop_all()
Ejemplo n.º 9
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.º 10
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.º 11
0
 def setUp(self):
     db.drop_all()
     db.create_all()
     db.session.add(Tag(name="green"))
     db.session.add(Tag(name="red"))
     db.session.add(Tag(name="blue"))
     db.session.add(Tag(name="yellow"))
     db.session.add(Tag(name="white"))
     db.session.add(Data(tags=get_tagList(["green", "red"]), value="test"))
     db.session.add(Data(tags=get_tagList(["red", "blue"]), value="test"))
     db.session.add(
         Data(tags=get_tagList(["blue", "yellow", "red"]), value="test"))
     db.session.add(Data(tags=get_tagList(["white"]), value="test"))
     db.session.commit()
Ejemplo n.º 12
0
def session(app):
    """Creates a new database session for a test."""
    db.app = app
    db.create_all()

    with db.engine.connect() as connection:
        with connection.begin() as transaction:
            options = dict(bind=connection, binds={})
            session = db.create_scoped_session(options=options)
            db.session = session
            prepare_data(session)

        yield session

        transaction.rollback()
        db.drop_all()
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 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.º 16
0
def create_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
Ejemplo n.º 17
0
def drop_db():
    """Drops the db tables."""
    db.drop_all()
Ejemplo n.º 18
0
from idlelib.macosxSupport import hideTkConsole

__author__ = 'ramessne'

from webapp import db
db.drop_all()
db.create_all()

from webapp.model.user import User
from webapp.model.playbook import Playbook
from webapp.model.history import History

guest = User('guest','*****@*****.**')
guest2 = User('admin','admin2')
playbook = Playbook('test')
history = History()
history.playbook = playbook
history.user = guest
history2 = History()
history2.playbook = playbook
history2.user = guest
db.session.add(guest)
db.session.add(guest2)
db.session.add(playbook)
db.session.add(history)
db.session.add(history2)
db.session.commit()

tmp = playbook.executions

for assoc in tmp:
def teardown_module():
    db.session.remove()
    db.drop_all()
Ejemplo n.º 20
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
     cls.vserver.stop()
Ejemplo n.º 21
0
def drop_db():
    db.drop_all()
Ejemplo n.º 22
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 23
0
from webapp import db, create_app

db.drop_all(app=create_app())
db.create_all(app=create_app())
Ejemplo n.º 24
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.º 25
0
 def teardown():
     ctx.pop()
     db.drop_all()
     pass
Ejemplo n.º 26
0

def inserPosition():
    for k in EPosition._member_names_:
        p1 = Position(symbol=k, name=EPosition.__getitem__(k).value)
        db.session.add(p1)


def insertypegoals():
    for k in ETypeGoal._member_names_:
        p1 = TypeGoals(name=k, value=ETypeGoal.__getitem__(k).value)
        db.session.add(p1)


if __name__ == '__main__':
    db.drop_all()
    db.create_all()
    # ==========insert data============#
    inserPosition()
    insertypegoals()

    config = Config(amountForeignPlayer=3, minAgePlayer=18, maxAgePlayer=20, diem=1,tongBanThang=2,hieuSo=3,doiKhang=4, loseScore=1,
                    winScore=3,
                    tieScore=2, thoiDiemGhiBanToiDa=96, maxPlayer=18, minPlayer=12)
    admin = Team(id=uuid.uuid4(), name="Admin",
                 email='*****@*****.**',
                 role=Role.admin,
                 username='******',
                 invalid=True,
                 password='******')
    team1 = Team(id=uuid.uuid4(),
Ejemplo n.º 27
0
def start_test_server():
    with app.app_context():
        db.drop_all()
        db.create_all()
    server.start()
Ejemplo n.º 28
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 29
0
    def tearDown(self):

        db.session.remove()
        db.drop_all()
Ejemplo n.º 30
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
     cls.vserver.stop()
Ejemplo n.º 31
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Ejemplo n.º 32
0
 def refresh_db(self):
     db.session.remove()
     db.drop_all()
     db.create_all()
     db.engine.dialect.supports_sane_multi_rowcount = False
Ejemplo n.º 33
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 34
0
 def refresh_db(self):
     db.session.remove()
     db.drop_all()
     db.create_all()
     db.engine.dialect.supports_sane_multi_rowcount = False