Merge lp:~cboylan/boots/boots_tests into lp:boots

Proposed by Clark Boylan
Status: Merged
Approved by: Max Goodhart
Approved revision: not available
Merge reported by: Max Goodhart
Merged at revision: not available
Proposed branch: lp:~cboylan/boots/boots_tests
Merge into: lp:boots
Diff against target: 171 lines (+142/-0)
2 files modified
tests/boots/api/api_tests.py (+118/-0)
tests/boots/tests.py (+24/-0)
To merge this branch: bzr merge lp:~cboylan/boots/boots_tests
Reviewer Review Type Date Requested Status
Max Goodhart Approve
Review via email: mp+17807@code.launchpad.net

Commit message

Merge clarkb's unit tests.

To post a comment you must log in.
Revision history for this message
Max Goodhart (chromakode) wrote :

Thanks for putting this together! Let's clean up the main tests.py code a bit this week.

review: Approve
lp:~cboylan/boots/boots_tests updated
24. By Max Goodhart

Merge clarkb's unit tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'tests'
2=== added directory 'tests/boots'
3=== added file 'tests/boots/__init__.py'
4=== added directory 'tests/boots/api'
5=== added file 'tests/boots/api/__init__.py'
6=== added file 'tests/boots/api/api_tests.py'
7--- tests/boots/api/api_tests.py 1970-01-01 00:00:00 +0000
8+++ tests/boots/api/api_tests.py 2010-01-21 08:05:20 +0000
9@@ -0,0 +1,118 @@
10+import unittest
11+from boots.api import api
12+
13+class TestServerConnections(unittest.TestCase):
14+ def test_valid_connect_fqdn(self):
15+ server = api.Server("capstonedd.cs.pdx.edu", 9306, {})
16+ server.connect()
17+ self.assert_(server.is_connected)
18+
19+ def test_valid_connect_partial1(self):
20+ server = api.Server("capstonedd.cs", 9306, {})
21+ server.connect()
22+ self.assert_(server.is_connected)
23+
24+ def test_valid_connect_partial2(self):
25+ server = api.Server("capstonedd", 9306, {})
26+ server.connect()
27+ self.assert_(server.is_connected)
28+
29+ def test_valid_connect_ip(self):
30+ server = api.Server("131.252.214.178", 9306, {})
31+ server.connect()
32+ self.assert_(server.is_connected)
33+
34+ def test_valid_connect_fqdn_with_db(self):
35+ server = api.Server("capstonedd.cs.pdx.edu", 9306, {"database": "world"})
36+ server.connect()
37+ self.assert_(server.is_connected)
38+
39+ def test_invalid_connect(self):
40+ server = api.Server("kororaa.cs.pdx.edu", 9306, {})
41+ server.connect()
42+ self.assert_(not server.is_connected)
43+
44+ def test_valid_disconnect(self):
45+ server = api.Server("capstonedd.cs.pdx.edu", 9306, {})
46+ server.connect()
47+ server.disconnect()
48+ self.assert_(not server.is_connected)
49+
50+ def test_invalid_disconnect(self):
51+ # Todo this should probably be set up to assert an exception.
52+ server = api.Server("kororaa.cs.pdx.edu", 9306, {})
53+ server.connect()
54+ server.disconnect()
55+ self.assert_(not server.is_connected)
56+
57+class TestServerExecute(unittest.TestCase):
58+ def setUp(self):
59+ self.server = api.Server("capstonedd.cs.pdx.edu", 9306, {"database": "world"})
60+ self.server.connect()
61+
62+ def tearDown(self):
63+ self.server.disconnect()
64+
65+ def test_query_length_0(self):
66+ result = list(self.server.execute(" SELECT * FROM countrylanguage WHERE Language = 'foobar';"))
67+ self.assertEqual(len(result), 0)
68+
69+ def test_query_length_1(self):
70+ result = list(self.server.execute("SELECT * FROM country WHERE name = 'Micronesia, Federated States of';"))
71+ self.assertEqual(len(result), 1)
72+
73+ def test_query_length_247(self):
74+ result = list(self.server.execute("SELECT * FROM city WHERE CountryCode = 'USA';"))
75+ self.assertEqual(len(result), 274)
76+
77+ def test_query_length_4081(self):
78+ result = list(self.server.execute("SELECT * FROM city;"))
79+ self.assertEqual(len(result), 4081)
80+
81+ def test_query_length_975359(self):
82+ result = list(self.server.execute("SELECT * FROM city,country;"))
83+ self.assertEqual(len(result), 975359)
84+
85+ def test_query_values_country(self):
86+ result = list(self.server.execute("SELECT * FROM country WHERE name = 'Micronesia, Federated States of';"))
87+ self.assertEqual(result[0],
88+ {"Code": "FSM",
89+ "Name": "Micronesia, Federated States of",
90+ "Continent": "Oceania",
91+ "Region": "Micronesia",
92+ "SurfaceArea": "702.00",
93+ "IndepYear": "1990",
94+ "Population": "119000",
95+ "LifeExpectancy": "68.6",
96+ "GNP": "212.00",
97+ "GNPOld": None,
98+ "LocalName": "Micronesia",
99+ "GovernmentForm": "Federal Republic",
100+ "HeadOfState": "Leo A. Falcam",
101+ "Capital": "2689",
102+ "Code2": "FM"})
103+
104+ def test_query_values_city(self):
105+ result = list(self.server.execute("SELECT * FROM city WHERE Name = 'Palikir';"))
106+ self.assertEqual(result[0],
107+ {"ID": "2689",
108+ "Name": "Palikir",
109+ "CountryCode": "FSM",
110+ "District": "Pohnpei",
111+ "Population": "8600"})
112+
113+ def test_query_identity_same_q(self):
114+ result1 = list(self.server.execute("SELECT * FROM country;"))
115+ result2 = list(self.server.execute("SELECT * FROM country;"))
116+ self.assertEqual(result1, result2)
117+
118+ def test_query_identity_equiv_q(self):
119+ result1 = list(self.server.execute("SELECT * FROM city;"))
120+ result2 = list(self.server.execute("SELECT ID, Name, CountryCode, District, Population FROM city;"))
121+ self.assertEqual(result1, result2)
122+
123+if __name__ == "__main__":
124+ suite = unittest.TestLoader().loadTestsFromTestCase(TestServerConnections)
125+ unittest.TextTestRunner(verbosity=2).run(suite)
126+ suite = unittest.TestLoader().loadTestsFromTestCase(TestServerExecute)
127+ unittest.TextTestRunner(verbosity=2).run(suite)
128
129=== added directory 'tests/boots/api/nodes'
130=== added file 'tests/boots/api/nodes/__init__.py'
131=== added file 'tests/boots/api/nodes/node_tests.py'
132=== added directory 'tests/boots/app'
133=== added file 'tests/boots/app/__init__.py'
134=== added file 'tests/boots/app/app_tests.py'
135=== added directory 'tests/boots/lib'
136=== added file 'tests/boots/lib/__init__.py'
137=== added file 'tests/boots/lib/console_tests.py'
138=== added directory 'tests/boots/lib/lingos'
139=== added file 'tests/boots/lib/lingos/__init__.py'
140=== added file 'tests/boots/lib/lingos/lingo_tests.py'
141=== added directory 'tests/boots/lib/ui'
142=== added file 'tests/boots/lib/ui/__init__.py'
143=== added file 'tests/boots/lib/ui/ui_tests.py'
144=== added file 'tests/boots/tests.py'
145--- tests/boots/tests.py 1970-01-01 00:00:00 +0000
146+++ tests/boots/tests.py 2010-01-21 08:05:20 +0000
147@@ -0,0 +1,24 @@
148+import unittest
149+import sys
150+sys.path.append("../../src/")
151+from api import api_tests
152+from api.nodes import node_tests
153+from app import app_tests
154+from lib import console_tests
155+from lib.lingos import lingo_tests
156+from lib.ui import ui_tests
157+
158+if __name__ == "__main__":
159+ suite = unittest.TestLoader().loadTestsFromModule(api_tests)
160+ unittest.TextTestRunner(verbosity=2).run(suite)
161+ suite = unittest.TestLoader().loadTestsFromModule(node_tests)
162+ unittest.TextTestRunner(verbosity=2).run(suite)
163+ suite = unittest.TestLoader().loadTestsFromModule(app_tests)
164+ unittest.TextTestRunner(verbosity=2).run(suite)
165+ suite = unittest.TestLoader().loadTestsFromModule(console_tests)
166+ unittest.TextTestRunner(verbosity=2).run(suite)
167+ suite = unittest.TestLoader().loadTestsFromModule(lingo_tests)
168+ unittest.TextTestRunner(verbosity=2).run(suite)
169+ suite = unittest.TestLoader().loadTestsFromModule(ui_tests)
170+ unittest.TextTestRunner(verbosity=2).run(suite)
171+

Subscribers

People subscribed via source and target branches

to status/vote changes: