Beispiel #1
0
 def setUp(self):
     """Define test variables and initialize app."""
     self.database_name = "trivia_test"
     self.database_path = "postgresql://*****:*****@localhost:54321/trivia_test"
     self.app = create_app({"SQLALCHEMY_DATABASE_URI": self.database_path})
     self.client = self.app.test_client
     self.app_context = self.app.app_context()
     self.app_context.push()
     setup_db(self.app)
     self.db = db
Beispiel #2
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.database_name = "trivia_test"
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = "postgresql://{}/{}".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()
Beispiel #3
0
    def setUp(self):
        """
        Setup db.
        :param self:
        """
        self.app = create_app()
        self.client = self.app.test_client

        setup_db(self.app)

        # 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()
Beispiel #4
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)
     self.question = {
         "question": "Whats the name of California's capitol",
         "answer": "Sacramento",
         "difficulty": 1,
         'category': 2
     }
     # 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()
Beispiel #5
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = 'trivia'
        self.database_path = \
            f'postgresql://localhost:5432/{self.database_name}'
        setup_db(self.app, self.database_path)

        self.sample_question = {
            'question': 'Who invented the personal computer?',
            'answer': 'Steve Wozniak',
            'category': 4,
            'difficulty': 2
        }

        # 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()
Beispiel #6
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)
        self.new_question = {
            'question': 'New Question',
            'answer': 'New answer',
            'difficulty': 5,
            'category': 1
        }

        self.search_question = {
            'question': 'Search Question',
            'answer': 'Search Answer',
            'difficulty': 1,
            'category': 1
        }

        setup_db(self.app, self.database_path)
        for i in range(1, NUM_TEST_CATEGORIES + 1):
            Category(f'Cat_{i}').insert()

        for i in range(NUM_TEST_QUESTIONS + 1):
            Question(question=f'question_{i}',
                     answer=f'answer_{i}',
                     category=i % NUM_TEST_CATEGORIES + 1,
                     difficulty=i % 5).insert()

        Question(**self.search_question).insert()
        # 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()
    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)

        self.new_question = {
            'category': '1',
            'question': 'Neil Gaiman',
            'answer': 'aaaaaaa',
            'difficulty': 5
        }
        self.new_category = {
            'id': '1',
            'type': 'test_type',
        }
        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy(self.app)
            self.db.init_app(self.app)
            self.db.create_all()


            # # create all tables

            # create all tables
            self.question = Question(difficulty=self.new_question['difficulty'],
                                     question=self.new_question['question'],
                                     answer=self.new_question['answer'], category=self.new_question['category'])
            self.question.insert()

            if Category.query.first() is None:
                category = Category(type=self.new_category['type'])
                category.insert()
Beispiel #8
0
from backend.flaskr import create_app

if __name__ == "__main__":
    app = create_app()
    app.run()