Beispiel #1
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config[
            'SQLALCHEMY_DATABASE_URI'] = DataBaseConfig.generate_database_uri()
        app.register_blueprint(authentication)
        app.register_blueprint(admin)

        app.register_blueprint(index_route)

        app.register_blueprint(business_owner)
        app.register_blueprint(authentication)
        app.register_blueprint(car_owner)
        app.register_blueprint(choose_service_grade)

        self.app = app.test_client()
        if self._testMethodName == "test_no_db":
            db.drop_all()

        # db.drop_all()
        # db.create_all()
        else:
            # pass
            init_db()
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config[
            'SQLALCHEMY_DATABASE_URI'] = DataBaseConfig.generate_database_uri(
            )
        app.register_blueprint(index_route)
        app.register_blueprint(business_owner)

        self.app = app.test_client()
        init_db()
Beispiel #3
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config[
            'SQLALCHEMY_DATABASE_URI'] = DataBaseConfig.generate_database_uri(
            )
        app.register_blueprint(index_route)
        app.register_blueprint(business_owner)

        self.app = app.test_client()

        if self._testMethodName == "test_no_db":
            db.drop_all()
        elif self._testMethodName == "test_wrong_status_type":
            pass
        elif self._testMethodName == "test_overlap_in_starting_job":
            data = [
                {
                    "service_type": 3,
                    "service_grade": 1
                },
                {
                    "service_type": 4,
                    "service_grade": 1
                },
            ]
            car_problems = []
            for car_problem in data:
                c_p = CarProblem(consumable_item_id=1,
                                 services_definition_id=1)
                car_problems.append(c_p)
            status = Status.query.filter(
                Status.name == Keys.STATUS_START).first()
            job = AutoServiceJob(business_owner_id=1,
                                 car_owner_id=1,
                                 car_id=2,
                                 status_=status,
                                 start_schedule="2019-01-05 16:29:45",
                                 finish_schedule="2019-01-07 16:43",
                                 price=1236)

            job.car_problems.extend(car_problems)
            db.session.add(job)
            db.session.commit()

        else:
            init_db()
Beispiel #4
0
from persistence.database.entity.question_set import QuestionSet
from persistence.database.entity.question_to_question_set import QuestionToQuestionSet
from persistence.database.entity.comany.insurance_company import Company, InsuranceCompany
from persistence.database.entity.job_.job import Job
from persistence.database.entity.job_.autoservice_job import AutoServiceJob
from persistence.database.entity.job_.third_party import ThirdPart
from persistence.database.entity.payment_.installment import InstallPayment
from persistence.database.entity.payment_.installments import Installment
from persistence.database.entity.service_definition import ServicesDefinition, ServiceCategoryEnum, ServiceGradeEnum
from persistence.database.entity.service_grade import ServiceGrade
from persistence.database.entity.service_type import ServiceType
from persistence.database.entity.stauts import Status
from persistence.database.entity.payment_type import PaymentType
from persistence.database.entity.user.insurance import InsuranceBusinessOwner

app.config['SQLALCHEMY_DATABASE_URI'] = DataBaseConfig.generate_database_uri()


##########
# new fill db
def init_auto_model():
    auto1 = AutoModel(name="bilibilak1.1", auto_types_id=1)
    auto2 = AutoModel(name='bilbilak1.2', auto_types_id=1)
    db.session.add(auto1)
    db.session.add(auto2)
    db.session.commit()


def init_color():
    auto1 = CarColor(name="red")
    auto2 = CarColor(name="green")
Beispiel #5
0
from sqlalchemy import create_engine

from config import DataBaseConfig

if __name__ == "__main__":
    engine = create_engine(DataBaseConfig.generate_engine_uri())
    conn = engine.connect()
    conn.execute("commit")
    conn.execute('DROP DATABASE IF EXISTS "' + DataBaseConfig.DATABASE_NAME +
                 '"')
    conn.execute("commit")
    print "Database '" + DataBaseConfig.DATABASE_NAME + "' dropped ..."
    conn.execute('CREATE DATABASE "' + DataBaseConfig.DATABASE_NAME + '"'
                 """
        WITH 
        OWNER = postgres
        ENCODING = 'UTF8'
        CONNECTION LIMIT = -1;
    """)
    conn.close()
    print "New database created ..."

    database = create_engine(DataBaseConfig.generate_database_uri())
    conn = database.connect()
    conn.execute("commit")
    conn.execute("""
        CREATE EXTENSION postgis;
    """)
    conn.close()
    print "extension postgis created."