-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_watch_anime_model.py
48 lines (33 loc) · 1.11 KB
/
test_watch_anime_model.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
36
37
38
39
40
41
42
43
44
45
46
47
48
from unittest import TestCase
from sqlalchemy import exc
from models import db, User, WatchAnime
from app import app
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///anime_platform_test'
class WatchAnimeModelTestCase(TestCase):
"""Test user models."""
def setUp(self):
"""Create test client, add sample data."""
db.drop_all()
db.create_all()
User.query.delete()
WatchAnime.query.delete()
u1 = User.signup("test1", "[email protected]", "password")
u1.id = 1111
db.session.commit()
u1 = User.query.get(u1.id)
self.u1 = u1
self.client = app.test_client()
def tearDown(self):
""" Clear any foul transactions. """
db.session.rollback()
def test_watch_anime_model(self):
"""Does basic model work?"""
wa = WatchAnime(
user_id=self.u1.id,
anime_id=1
)
db.session.add(wa)
db.session.commit()
u1 = User.query.get(self.u1.id)
# User should have one anime in their relationship.
self.assertEqual(len(u1.watchList), 1)