Exemplo n.º 1
0
    def setUp(self):
        """ Executed before each test.
        
        It defines the test variables, initializing the app,
        and setting up any other context that maybe needed (e.g. databases) """

        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = 'books_db_test'
        self.database_path = 'postgres://{}/{}'.format('localhost:5432',
                                                       self.database_name)
        setup_db(self.app, self.database_path)

        # Inserting a book
        self.new_book = {
            'author': 'Neil Gaiman',
            'title': 'Anansi Boys',
            'rating': 5
        }

        # Binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Exemplo n.º 2
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "trivia_test"
        self.database_path = 'postgres://{}:{}@{}/{}'.format(
            'postgres', 'postgres', 'localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Exemplo n.º 3
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "trivia_test"
        self.database_path = "postgres://{}/{}".format('localhost:5432',
                                                       self.database_name)
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Exemplo n.º 4
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app(config_file=config.TestConfig)
        self.client = self.app.test_client
        self.database_name = "trivia_test"
        setup_db(self.app)

        self.new_question = {
            'question': 'Is automation the next big thing?',
            'answer': 'Most likely',
            'category': 1,
            'difficulty': 1,
            'rating': 1
        }

        self.new_category = {'type': "test"}

        self.new_user = {
            'username': "******",
            'password': "******",
            'repeat_password': "******"
        }

        self.login_user = {
            'username': "******",
            'password': "******",
        }

        self.new_search = {'searchTerm': 'giaconda'}

        self.quiz = {
            'previous_questions': [],
            'quiz_category': {
                "type": "",
                "id": 0
            }
        }

        self.save_score = {"user": {"username": "******"}, "num_correct": 1}

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)

            # create all tables
            self.db.create_all()