Repository navigation
Expand file tree
/
Copy pathtest_analysis.py
More file actions
74 lines (50 loc) · 1.77 KB
/
Copy pathtest_analysis.py
File metadata and controls
74 lines (50 loc) · 1.77 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Should I create and destroy the db before/after each test?
difficult to stabilize data while testing.
"""
import analysis
import unittest
import os
from model import (User, Movie, Comic, MovieRating, ComicRec,
connect_to_db, db)
from sqlalchemy.pool import NullPool
class flix2comixTest(unittest.TestCase):
def test_get_profile_user3(self):
"""
"""
profile3 = analysis.get_profile(3)
self.assertEqual(profile3["linear"], -1)
self.assertEqual(profile3["mature"], 0)
def test_get_user_match3(self):
"""
"""
profile3 = analysis.get_profile(3)
comic = analysis.get_user_match(profile3, 3)
self.assertEqual(comic.title, "Why I Hate Saturn")
# def test_process_user_rating(self):
# """
# """
# analysis.process_user_rating(10, 10, 2)
# r = MovieRating.query.filter(user_id=10, movie_id=10).one()
# assertEqual(r.rating, 2)
def setUp(self):
"""connect to db? createdb???"""
# Connect to test database
# Create tables and add sample data
# os.system("dropdb testdb")
# engine = create_engine(
# 'postgresql+psycopg2://scott:tiger@localhost/test',
# poolclass=NullPool)
os.system("createdb testdb")
os.system("psql testdb < BACKUPflix2comix")
connect_to_db(app, "postgresql:///testdb")
print "connected to testdb"
def tearDown(self):
"""Do at end of every test."""
db.session.close()
# db.engine.dispose() -- didn't work :(
os.system("dropdb testdb")
if __name__ == '__main__':
from server import app
# connect_to_db(app, "MOCKflix2comix")
# print "Connected to DB!"
unittest.main()