示例#1
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = 'finaltest'
        self.database_path = "postgresql://{}:{}@{}/{}".format(
            'postgres', 'postgres', 'localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()

        # Load initial data into database
        seed()

        self.new_movie = {
            'title': 'TEST TITLE',
            'release_date': '2020-04-20'
        }
        self.new_actor = {
            'name': 'TEST NAME',
            'age': 25,
            'gender': 'M'
        }
        self.update_movie = {
            'title': 'UPDATED TITLE',
            'release_date': '2015-04-20'
        }
        self.update_actor = {
            'name': 'UPDATED NAME',
            'age': 21,
            'gender': 'F'
        }
        self.bad_movie = {
            'bad-title': 'TEST TITLE',
            'release_date': '2020-04-20'
        }
        self.bad_actor = {
            'bad-name': 'TEST NAME',
            'age': 25,
            'gender': 'M'
        }
        self.unprocessable_movie = {
            'title': None,
            'release_date': '2020-04-20'
        }
        self.unprocessable_actor = {
            'name': None,
            'age': 25,
            'gender': 'M'
        }
示例#2
0
from user_roles import (is_super_admin, is_admin, is_user)
import sys
import os
from os.path import dirname, join, expanduser, normpath, realpath
from graphene.test import Client
from flask_bcrypt import Bcrypt

import pytest

# This is the only way I could get imports to work for unit testing.
PACKAGE_PARENT = '..'
SCRIPT_DIR = dirname(realpath(join(os.getcwd(), expanduser(__file__))))
sys.path.append(normpath(join(SCRIPT_DIR, PACKAGE_PARENT)))

from manage import seed, remove_seed
seed()
from db import db
from app import app
from queries import schema
from models import Users
from functions.error_messages import error_not_an_admin
remove_seed()


@pytest.fixture(scope='class')
def user_role_test_db_init():
    db.init_app(app)
    bcrypt = Bcrypt(app)

    with app.app_context():
        test_user = Users (
示例#3
0
 def setUp(self):
     with app.app_context():
         upgrade()
         if len(User.query.all()) < 1:
             manage.seed()