-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest.py
151 lines (133 loc) · 5.03 KB
/
autotest.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import unittest2
import httplib
import inpho.corpus.sep as sep
from inpho.model import *
import sqlalchemy
__all__ = ["Autotest"]
class Autotest(unittest2.TestCase):
def getPassedTests(self):
return passed
def setUp(self):
self.conn = httplib.HTTPConnection("inphodev.cogs.indiana.edu:8087")
def test_sep_crossRef(self):
"""
SEP Cross-References
Verify that SEP Cross-Reference at http://plato.stanford.edu/~inpho/crossref.php
still works
"""
self.conn = httplib.HTTPConnection("plato.stanford.edu")
self.conn.request("GET", "/~inpho/crossref.php")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 200)
def test_entity_json(self):
"""
Entity JSON
Verify that https://inpho.cogs.indiana.edu/entity.json returns HTTP 200
"""
self.conn.request("GET", "/entity")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 400)
def test_idea_json(self):
"""
Idea JSON
Verify that https://inpho.cogs.indiana.edu/idea.json returns HTTP 200
"""
self.conn.request("GET", "/idea")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 400)
def test_thinker_json(self):
"""
Thinker JSON
Verify that https://inpho.cogs.indiana.edu/thinker.json returns HTTP 200
"""
self.conn.request("GET", "/thinker")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 400)
def test_journal_json(self):
"""
Journal JSON
Verify that https://inpho.cogs.indiana.edu/journal.json returns HTTP 200
"""
self.conn.request("GET", "/journal")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 400)
def test_taxonomy_json(self):
"""
Taxonomy JSON
Verify that https://inpho.cogs.indiana.edu/taxonomy.json returns HTTP 200
"""
self.conn.request("GET", "/taxonomy")
result = self.conn.getresponse()
self.assertLessEqual(result.status, 400)
def test_search_box(self):
"""
Search Box
Verify autocomplete works. Easy test: "time"
"""
self.conn.request("GET", "/entity.json?q=time")
result = self.conn.getresponse()
data = result.read()
# blank result returns data with length 84
# checks to see if the search returns at least one result
self.assertGreater(len(data), 84)
def test_owl(self):
"""
OWL
Verify log-generating script works
"""
#OWL script
node_q = Session.query(Node)
thinker_q = Session.query(Thinker)
profession_q = Session.query(Profession)
nationality_q = Session.query(Nationality)
nodes = node_q.all()
thinkers = thinker_q.all()
professions = profession_q.all()
nationalities = nationality_q.all()
# Compare length of lists to expected lengths
self.assertGreaterEqual(len(nodes), 275)
self.assertGreaterEqual(len(thinkers), 1758)
self.assertGreaterEqual(len(professions), 906)
self.assertGreaterEqual(len(nationalities), 86)
def test_ui_eval(self):
"""
Evaluation UI
Verify user is able to Enable evaluations, choose an item, choose a setting,
and submit an evaluation.
"""
#make user eval using POST
#look for develper tools (use google chrome or new firefox)
self.conn.request("POST", "/idea/1488/relatedness/1793")
r_result = self.conn.getresponse()
self.conn.request("POST", "/idea/1488/generality/1793")
g_result = self.conn.getresponse()
self.assertLessEqual(r_result.status, 400)
self.assertLessEqual(g_result.status, 400)
def test_database_eval(self):
"""
Evaluation Database
Verify evaluation submissions append to database
"""
#being able to delete user eval
self.conn.request("GET", "/idea/1488/relatedness/1793?_method=DELETE")
r_result = self.conn.getresponse()
self.conn.request("GET", "/idea/1488/generality/1793?_method=DELETE")
g_result = self.conn.getresponse()
#FAILING because both status variables return 302 'FOUND', NOT 400
self.assertLessEqual(r_result.status, 400)
self.assertLessEqual(g_result.status, 400)
def test_sep_publishing_list(self):
"""
SEP Publishing list
Verify items are not already in database. Check sep_dir fields.
"""
new = sep.new_entries()
entries_in_db = 0
for entry in new:
if(len(Session.query(Entity).filter(Entity.sep_dir == entry).all()) > 0):
entries_in_db += 1
print entry
self.assertEqual(entries_in_db, 0)
if __name__ == '__main__':
suite = unittest2.TestLoader().loadTestsFromTestCase(Autotest)
unittest2.TextTestRunner(verbosity=2).run(suite)