forked from deepakbhimavarapu/WP_Mentor_training_2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_book_details.py
35 lines (28 loc) · 1.02 KB
/
test_book_details.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import unittest
from book_details import *
from application import app
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import create_engine, or_
from models import Base, User, Book
class BasicTests(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['DEBUG'] = False
# Check for environment variable
if not os.getenv("DATABASE_URL"):
raise RuntimeError("DATABASE_URL is not set")
Base.query = db_session.query_property()
self.app = app.test_client()
# Disable sending emails during unit testing
self.assertEqual(app.debug, False)
# executed after each test
def tearDown(self):
pass
def test_get_book_by_isbn(self):
book1 = get_book_by_isbn("0399153942")
book2 = db_session.query(Book).filter_by(isbn="0399153942")
self.assertEqual(book1[0], book2[0])
if __name__ == "__main__":
unittest.main()