Exemplo n.º 1
0
 def setUp(self):
     db.create_all()
     self.user = User(email="*****@*****.**", password="******")
     self.user.api_key = '9dff2e6aeb1c4ec7b5e2d6d65fd569ef'
     self.user.secret_access_key = '2f4c80fd51ea488e8c6cfcacbc073696'
     db.session.add(self.user)
     db.session.commit()
Exemplo n.º 2
0
 def setUp(self):
     db.create_all()
     self.user = User(email="*****@*****.**", password="******")
     self.user.api_key = '9dff2e6aeb1c4ec7b5e2d6d65fd569ef'
     self.user.secret_access_key = '2f4c80fd51ea488e8c6cfcacbc073696'
     db.session.add(self.user)
     db.session.commit()
Exemplo n.º 3
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client()

        self.user = User(email='*****@*****.**',
                         first_name='joshua',
                         last_name='carey')
        self.user.insert()

        self.contact_payload = {
            'first_name': 'darrel',
            'last_name': 'wadsworth',
            'group': 'friend',
            'phone_number': '999-999-9999',
            'street_address': '45321 example way',
            'city': 'Denver',
            'state': 'Colorado',
            'zipcode': '80000'
        }

        self.contact = Contact(self.user, self.contact_payload)
        self.contact.insert()
Exemplo n.º 4
0
 def setUp(self):
     db.create_all()
     company = Company(name="TestCompany")
     db.session.add(company)
     for params in group_gen():
         db.session.add(Group(**params))
     db.session.commit()
Exemplo n.º 5
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     seed_data(db)
     self.client = self.app.test_client()
Exemplo n.º 6
0
def seed():
    db.drop_all()
    db.create_all()

    jk = Author(name='JK Rowling')
    jr = Author(name='J. R. R. Tolkein')
    db.session.add(jk)
    db.session.add(jr)
    db.session.commit()

    book1 = Book(id=1, name='Harry Potter and the Chamber of Secrets')
    book1.author = jk
    book2 = Book(id=2, name='Harry Potter and the Prisoner of Azkaban')
    book2.author = jk
    book3 = Book(id=3, name='Harry Potter and the Gobblet of Fire')
    book3.author = jk

    book4 = Book(id=4, name='The Fellowship of the Ring')
    book4.author = jr
    book5 = Book(id=5, name='The Two Towers')
    book5.author = jr

    db.session.add(book1)
    db.session.add(book2)
    db.session.add(book3)
    db.session.add(book4)
    db.session.add(book5)

    db.session.commit()
Exemplo n.º 7
0
 def setUp(self):
     # binds the app to the current context
     app = self.create_app()
     with app.app_context():
         # create all database tables
         db.create_all()
         db.session.commit()
Exemplo n.º 8
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client()

        self.payload = {
            "data": {
                "userID":
                1,
                "tripDetails": {
                    "title": "Vice City",
                    "destination": "Miami",
                    "duration": 2
                },
                "items": [{
                    "is_checked": True,
                    "item_id": 1,
                    "quantity": 1
                }, {
                    "is_checked": True,
                    "item_id": 2,
                    "quantity": 15
                }]
            }
        }
 def setUp(self):
     """Runs before every test"""
     # creates a test client
     self.app = create_app('testing')
     self.client = self.app.test_client()
     with self.app.app_context():
         db.create_all()
     self.user_data = json.dumps({
         'name': 'Tapiwa',
         'email': '*****@*****.**',
         'password': '******'
     })
     self.user_data2 = json.dumps({
         'name': 'Password',
         'email': '*****@*****.**',
         'password': '******'
     })
     self.wrong_user = json.dumps({
         'email': '*****@*****.**',
         'password': '******'
     })
     self.admin = json.dumps({
         'email': '*****@*****.**',
         'password': '******'
     })
     self.client.post('/api/v1/auth/register', data=self.user_data2)
Exemplo n.º 10
0
def load_data():
    db.drop_all()
    db.create_all()
    db.session.commit()
    load_admin1_codes()
    load_admin2_codes()
    load_geonames()
Exemplo n.º 11
0
 def setUp(self):
     # binds the app to the current context
     self.client = app.test_client()
     self.blog = {'title': 'my journey', 'blog': 'To Andela'}
     with app.app_context():
         # create all database tables
         db.create_all()
Exemplo n.º 12
0
    def setUp(self):

        db.drop_all()
        db.create_all()
        resp_register = register_user(self, '*****@*****.**', '123456')
        res = json.loads(resp_register.data.decode())
        resp_login = login_user(self, '*****@*****.**', '123456')
Exemplo n.º 13
0
def signup_admin():
    # let's inicizlize db
    db.init_app(app)
    # let's create db
    with app.app_context():
        db.create_all()

        name = 'admin'
        password = '******'
        user = User.query.filter_by(name=name).first(
        )  # if this returns a user, then the email already exists in database

        if user:  # if a user is found, we want to redirect back to signup page so user can try again
            # return redirect(url_for('auth.signup'))
            return 'it is ALREADY exists ADMIN'
        # create new user with the form data. Hash the password so plaintext version isn't saved.
        new_user = User(public_id=str(uuid.uuid4()),
                        name=name,
                        password=generate_password_hash(password,
                                                        method='sha256'),
                        admin=True)

        # add the new user to the database
        db.session.add(new_user)
        db.session.commit()
Exemplo n.º 14
0
def app():
    app = create_app("testing")
    with app.app_context():
        db.create_all()

    yield app
    app.config["DB_FILE_PATH"].unlink()
Exemplo n.º 15
0
def create_test_data():
    # Reset the database to original state
    db.create_all()
    Task.query.delete()

    for task in tasks:
        Task.add_task(task)
def db_seed():
    db_drop_everything(db)
    db.create_all()
    drink_1 = Drink(
        'blue water',
        [{
            "name": "Blue Water",
            "color": "blue",
            "parts": 1
        }],
    )
    drink_1.insert()

    drink_2 = Drink(
        'green water',
        [{
            "name": "Blue Water",
            "color": "blue",
            "parts": 2
        }, {
            "name": "Yellow Water",
            "color": "yellow",
            "parts": 2
        }],
    )
    drink_2.insert()
    db.session.commit()
    print(f'Drink count: {len(db.session.query(Drink).all())}')
Exemplo n.º 17
0
 def setUp(self):
     db.create_all()
     company = Company(name="test company")
     user = User(username='******',
                 email='*****@*****.**',
                 rank='Admin', company_id=1)
     db.session.add(company)
     db.session.add(user)
Exemplo n.º 18
0
    def setUp(self):
        app.config.from_object(application_config['TestingEnv'])
        self.client = app.test_client()

        # Binds the app to current context
        with app.app_context():
            # Create all tables
            db.create_all()
Exemplo n.º 19
0
 def setUp(self):
     self.app = app
     self.app.config.update({
         'SQLALCHEMY_DATABASE_URI': Config.TEST_DATABASE_URI
     })
     self.client = self.app.test_client()
     with self.app.app_context():
         db.create_all()
Exemplo n.º 20
0
 def get(self):
     db.create_all()
     emp = Employee(lastName='Jones', firstName='Bob', extension='x5555')
     db.session.add(emp)
     emp = Employee(lastName='Parker', firstName='Alice', extension='x6666')
     db.session.add(emp)
     db.session.commit()
     return {'hello': 'world'}
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     self.client = self.app.test_client()
     self.user_1 = Users(username='******')
     self.user_1.insert()
Exemplo n.º 22
0
def app():
    app = create_app(TestingConfig)
    with app.app_context():
        db.create_all()
        print("create db")
        yield app
        print("delete db")
        db.drop_all()
Exemplo n.º 23
0
    def setUp(self):

        # Create all tables
        with app.app_context():
            db.create_all()

        self.app = app.test_client
        self.app_context = app.app_context
Exemplo n.º 24
0
def recreate_db():
    """
    Recreates a local database. You probably should not use this on
    production.
    """
    db.drop_all()
    db.create_all()
    db.session.commit()
Exemplo n.º 25
0
    def setUp(self):
        self.app = app
        self.app_context = self.app.app_context()
        self.app_context.push()
        self.test_client = app.test_client
        self.app.config.from_object(configs.get("testing"))
        db.create_all()

        # data to use when testing user registration and login
        self.expired_token = "ZXlKaGJHY2lPaUpJVXpJMU5pSXNJbWxoZENJNk1UVXhNVEE1Tk\
        RjMU1Dd2laWGh3SWpveE5URXhNRGs0TXpVd2ZRLmV5SnBaQ0k2TVgwLnQ1aEdhMmNON0RZU0\
        VEYUxkSGljNHZXR1kzR1dzZF9wOEgyNTlka2o5YTQ"

        self.user_details1 = {
            "firstname": "Jjagwe",
            "lastname": "Dennis",
            "email": "*****@*****.**",
            "password": "******",
            "c_password": "******"
        }
        self.user_details2 = {
            "firstname": "King",
            "lastname": "Dennis",
            "email": "*****@*****.**",
            "password": "******",
            "c_password": "******"
        }
        self.login_details1 = {
            "username": "******",
            "password": "******"
        }
        self.login_details2 = {
            "username": "******",
            "password": "******"
        }

        self.sample_categories = [{
            "cat_name": "Break Fast"
        }, {
            "cat_name": "Lunch and supper"
        }, {
            "cat_name": "Evening Meals"
        }]
        self.sample_recipes = [{
            "name": "Banana Crumbs",
            "steps": "1.Peal Matooke 2.Cook 3.Eat",
            "ingredients": "Matooke, Tomatoes",
            "category": "1"
        }, {
            "name": "Bread n Butter",
            "steps":
            "1.Open butter, 2.Open Bread 3.Spread butter on bread and eat",
            "ingredients": "Butter, Bread",
            "category": "1"
        }]

        self.kwargs = {"content_type": 'application/json'}
Exemplo n.º 26
0
def database():
    db.create_all()

    yield db
    """
    TESTS RUN HERE
    """

    db.drop_all()
Exemplo n.º 27
0
def job():
    print("Start task...")
    start = time.time()
    scrapper = Scrapper()
    db.drop_all()
    db.create_all()
    scrapper.add_countries()
    end = time.time()
    print("Ending Tasks...{}".format(end-start))
Exemplo n.º 28
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     for test_user in TEST_USERS:
         user = User.from_json(test_user)
         db.session.add(user)
     db.session.commit()
Exemplo n.º 29
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client()

        self.user_1 = User(username='******', email='e1')
        self.user_1.insert()
Exemplo n.º 30
0
    def setUp(self):
        """ Création d'une base de données avant le test"""
        warnings.filterwarnings('ignore', category=DeprecationWarning)

        db.create_all()
        user = User(username="******")
        user.hash_password("admin")
        db.session.add(user)
        db.session.commit()
Exemplo n.º 31
0
def app():
    """Create app instance for tests."""
    app = create_app(TestConfig)

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

    yield app
Exemplo n.º 32
0
    def setUp(self):
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
        app.config['TESTING'] = True
        self.client = app.test_client()
        db.create_all()

        global satshabad
        global fateh
        satshabad = fixtures.make_user("satshabad")
        fateh = fixtures.make_user("fateh")
Exemplo n.º 33
0
    def setUp(self):
        # cria o objeto flask
        self.current_api = create_api('config')
        with self.current_api.app_context():

            # remove todas as tabelas do banco
            db.drop_all()

            # (re)cria o banco de dados
            db.create_all()
Exemplo n.º 34
0
 def setUp(self):
     db.create_all()
     group = Group(name="Test group",
                   created=datetime.utcnow(),
                   description="test 1 2 3")
     task = Task(title="Go to store",
                 body="Get eggs and milk.",
                 group_id=1, createdOn=datetime.utcnow())
     db.session.add(group)
     db.session.add(task)
Exemplo n.º 35
0
 def setUp(self):
     # binds the app to the current context
     self.client = app.test_client()
     self.user = {
         'username': '******',
         'email': '*****@*****.**',
         'password': '******'}
     with app.app_context():
         # create all database tables
         db.create_all()
Exemplo n.º 36
0
 def setUp(self):
     self.app = app
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()
     db.create_all()
     u = User(username=self.default_username)
     u.set_password(self.default_password)
     db.session.add(u)
     db.session.commit()
     self.client = TestClient(self.app, u.generate_auth_token(), '')
Exemplo n.º 37
0
 def setUp(self):
     db.create_all()
     company = Company(name="TestCompany")
     db.session.add(company)
     #just for fun:
     # [db.session.add(Group(**group)) for group in group_gen()]
     # map(lambda params: db.session.add(Group(**params)), group_gen())
     # filter(lambda params: db.session.add(Group(**params)), group_gen())
     for params in group_gen():
         db.session.add(Group(**params))
     db.session.commit()
    def setUp(self):
        db.create_all()

        for i in range(randint(1000, 2000)):
            artist = Artist(
                name="Test name{}".format(i),
                birth_year=1000,
                death_year=2000,
                country="Test Country",
                genre="Test genre",
            )
            db.session.add(artist)
        db.session.commit()
Exemplo n.º 39
0
Arquivo: test.py Projeto: ahmb/blogapp
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
     self.app = app
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()
     db.create_all()
     u = User(username=self.default_username)
     u.set_password(self.default_password)
     db.session.add(u)
     db.session.commit()
     self.client = TestClient(self.app, u.generate_auth_token(), '')
Exemplo n.º 40
0
    def setUp(self):

        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()

        db.create_all()

        user = User(
            username="******",
            email="*****@*****.**",
            password_hash="chiditheboss"
        )
        db.session.add(user)
        db.session.commit()

        self.client = self.app.test_client()
Exemplo n.º 41
0
    def setUp(self):

        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()

        db.drop_all()
        db.create_all()

        user = User(
            username="******",
            email="*****@*****.**",
        )
        user.hash_password("chiditheboss")
        db.session.add(user)
        db.session.commit()
        g.user = user

        self.client = self.app.test_client()
Exemplo n.º 42
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app.config['TESTING'] = True
     self.app = app.test_client()
     db.create_all()
     tmpzsh = Shell(name='zsh', path='/usr/bin/zsh')
     db.session.add(tmpzsh)
     db.session.commit()
     tmpbash = Shell(name='bash', path='/bin/bash')
     db.session.add(tmpbash)
     db.session.commit()
     tmpAdmin = Access(name='admin', description='Grant SuperUser privileges on host')
     db.session.add(tmpAdmin)
     db.session.commit()
     tmpUser = Access(name='user', description='Normal User Access to host')
     db.session.add(tmpUser)
     db.session.commit()
     tmpGroup = Group(name='WebServers')
     db.session.add(tmpGroup)
     db.session.commit()
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()

        db.create_all()

        user = User(
            username="******",
            email="*****@*****.**",
            password_hash="chiditheboss"
        )
        user.hash_password("chiditheboss")
        db.session.add(user)
        db.session.commit()
        g.user = user

        bucketlist = Bucketlist(name="Awesome Bucketlist", created_by=g.user.id)
        bucketlist.save()

        self.client = self.app.test_client()
Exemplo n.º 44
0
def reset_db():
    if isfile('yoked.db'):
        unlink('yoked.db')
    if isfile('yoked.log'):
        unlink('yoked.log')
    db.create_all()
    # Now Setup some basic values in the DB
    access_admin = Access(name='admin',
                          description='Full Admin Access')
    access_user = Access(name='user',
                         description='Regular User Access')
    db.session.add(access_admin)
    db.session.commit()
    db.session.add(access_user)
    db.session.commit()

    shell_zsh = Shell(name='zsh',
                      path='/usr/bin/zsh')
    shell_bash = Shell(name='bash',
                       path='/bin/bash')
    db.session.add(shell_zsh)
    db.session.commit()
    db.session.add(shell_bash)
    db.session.commit()
 def setUp(self):
     db.create_all()
Exemplo n.º 46
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Exemplo n.º 47
0
from api import db, app
# from api.models import Report, Puf, Cancer
import project

engine = db.engine

# Remove spontaneous quoting of column name
db.engine.dialect.identifier_preparer.initial_quote = ''
db.engine.dialect.identifier_preparer.final_quote = ''

#Create database and tablesfab vagrant bo
db.create_all()
print "Table(s) schema created, inserting data..."

# Insert Data -- Bulk insert of DataFrame
## Insert Report CSV -- Report Table
df_report = project.readCSV()
for elem in df_report:
    elem.to_sql('report', engine, if_exists='append', index=False)
    db.session.commit()
    print count
## Insert PUF CSV -- Puf Table
df_puf = project.readPUF()
for elem in df_puf:
    elem.to_sql('puf', engine, if_exists='append', index=False)
    db.session.commit()
## Insert BCHC CSV -- Cancer Table
df_can = project.readBCH()
df_can.to_sql('cancer', engine, if_exists='append', index=False)

Exemplo n.º 48
0
def reset_db():
	db.drop_all()
	db.create_all()
Exemplo n.º 49
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
     self.app = app.test_client()
     db.create_all()
     self.load_data()
Exemplo n.º 50
0
 def setUp(self):
     db.create_all()
     company = Company(name="skynet",
                       website="www.cyberdyne.net")
     db.session.add(company)
Exemplo n.º 51
0
def create_db():
    """Creates database and necessary tables"""
    db.create_all()
Exemplo n.º 52
0
def app():
    from api import app, db
    app.config['TESTING'] = True
    db.create_all()

    return app
Exemplo n.º 53
0
def clear_dbs():
    db.drop_all()
    db.create_all()