Merge lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-more-unittests into lp:ubuntu-accomplishments-daemon

Proposed by Matt Fischer
Status: Merged
Merged at revision: 103
Proposed branch: lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-more-unittests
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 518 lines (+232/-104)
9 files modified
accomplishments/daemon/api.py (+1/-1)
accomplishments/daemon/tests/accomps/first.accomplishment (+2/-1)
accomplishments/daemon/tests/accomps/second.accomplishment (+1/-0)
accomplishments/daemon/tests/accomps/third.accomplishment (+1/-0)
accomplishments/daemon/tests/extrainformation/info (+9/-0)
accomplishments/daemon/tests/extrainformation/info2 (+23/-0)
accomplishments/daemon/tests/tests.py (+188/-101)
debian/control (+1/-0)
debian/rules (+6/-1)
To merge this branch: bzr merge lp:~mfisch/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon-more-unittests
Reviewer Review Type Date Requested Status
Rafał Cieślak Pending
Review via email: mp+114960@code.launchpad.net

Description of the change

This has more unit tests, some clean-up of how I was testing exceptions and fixes a bug in the API that cielak found:

Basically if the value is not set (is ''), when you call get_extra_information() it returns an empty label too.

<cielak> which causes that if - in get_extra_info - value is '', then label will be empty too
<cielak> api.py, line 837
<mfisch> whats the fix?
<cielak> api.py, line 837 is now:
<cielak> final = [{item : "", "label" : ""}]
<cielak> should be:
<cielak> final = [{item : "", "label" : label}]

To post a comment you must log in.
104. By Matt Fischer

run tests during build

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'accomplishments/daemon/api.py'
--- accomplishments/daemon/api.py 2012-07-13 20:01:07 +0000
+++ accomplishments/daemon/api.py 2012-07-14 02:21:18 +0000
@@ -834,7 +834,7 @@
834 final = [{item : data, "label" : label}]834 final = [{item : data, "label" : label}]
835 except IOError as e:835 except IOError as e:
836 #print "No data."836 #print "No data."
837 final = [{item : "", "label" : ""}]837 final = [{item : "", "label" : label}]
838 return final838 return final
839 839
840 # =================================================================840 # =================================================================
841841
=== modified file 'accomplishments/daemon/tests/accomps/first.accomplishment'
--- accomplishments/daemon/tests/accomps/first.accomplishment 2012-07-12 21:10:53 +0000
+++ accomplishments/daemon/tests/accomps/first.accomplishment 2012-07-14 02:21:18 +0000
@@ -2,5 +2,6 @@
2title=My First Accomplishment2title=My First Accomplishment
3icon=first.jpg3icon=first.jpg
4description=An example accomplishment for the test suite4description=An example accomplishment for the test suite
5needs-information=info,more info5needs-information=info,info2
6collection = testaccomp6collection = testaccomp
7author = Tester <tester@tester>
78
=== modified file 'accomplishments/daemon/tests/accomps/second.accomplishment'
--- accomplishments/daemon/tests/accomps/second.accomplishment 2012-07-12 21:10:53 +0000
+++ accomplishments/daemon/tests/accomps/second.accomplishment 2012-07-14 02:21:18 +0000
@@ -5,3 +5,4 @@
5depends=testaccomp/first5depends=testaccomp/first
6needs-signing=True6needs-signing=True
7collection=testaccomp7collection=testaccomp
8author = Tester <tester@tester>
89
=== modified file 'accomplishments/daemon/tests/accomps/third.accomplishment'
--- accomplishments/daemon/tests/accomps/third.accomplishment 2012-07-12 21:10:53 +0000
+++ accomplishments/daemon/tests/accomps/third.accomplishment 2012-07-14 02:21:18 +0000
@@ -7,3 +7,4 @@
7category=testing, unit test7category=testing, unit test
8# comment should be ignored8# comment should be ignored
9# comment9# comment
10author = Someone
1011
=== added directory 'accomplishments/daemon/tests/extrainformation'
=== added file 'accomplishments/daemon/tests/extrainformation/info'
--- accomplishments/daemon/tests/extrainformation/info 1970-01-01 00:00:00 +0000
+++ accomplishments/daemon/tests/extrainformation/info 2012-07-14 02:21:18 +0000
@@ -0,0 +1,9 @@
1[label]
2en = Some info
3
4[description]
5en = Some description
6# a comment
7
8[example]
9en = Some example
010
=== added file 'accomplishments/daemon/tests/extrainformation/info2'
--- accomplishments/daemon/tests/extrainformation/info2 1970-01-01 00:00:00 +0000
+++ accomplishments/daemon/tests/extrainformation/info2 2012-07-14 02:21:18 +0000
@@ -0,0 +1,23 @@
1# a comment
2
3
4
5
6
7
8
9
10
11[label]
12en = More info
13
14[description]
15en = More description
16
17####
18
19#
20##
21
22[example]
23en = More example
024
=== modified file 'accomplishments/daemon/tests/tests.py'
--- accomplishments/daemon/tests/tests.py 2012-07-13 19:36:06 +0000
+++ accomplishments/daemon/tests/tests.py 2012-07-14 02:21:18 +0000
@@ -11,40 +11,41 @@
11sys.path.insert(0, os.path.join(os.path.split(__file__)[0], "../../.."))11sys.path.insert(0, os.path.join(os.path.split(__file__)[0], "../../.."))
12from accomplishments.daemon import app, api12from accomplishments.daemon import app, api
1313
14# future tests14# future tests:
15# create extra information files - marked for removal in the code
15# get_acc_date_completed - needs accomplish() to work to be useful16# get_acc_date_completed - needs accomplish() to work to be useful
16# get all extra information
17# get all extra information required
18# create extra information files
19# invalidate extra information
20# get extra information
21# get trophy path
22# get trophy data17# get trophy data
23# get collection name
24# get collection exists
25# get collection authors
26# get collection categories
27# get collection data
28# list trophies18# list trophies
29# list opportunities19# list opportunities
30# list depending on20# list depending on
31# list unlocked21# list unlocked
32# list unlocked not completed22# list unlocked not completed
33# list collections
34# run scripts/runscript23# run scripts/runscript
35# build viewer database
36# get published status24# get published status
25# invalidate extra information
3726
38# These tests will modify the user's envrionment, outside of the test27# These tests will modify the user's envrionment, outside of the test
39# dir and so are not written/skipped:28# dir and so are not written/skipped:
40# - set daemon session start29# - set daemon session start
41# - set block u1 notification bubbles30# - set block u1 notification bubbles
4231
32# Debugging:
33# To debug tests, the following changes are recommended:
34# 1) comment out the shutil.rmtree in tearDown()
35# 2) in setUp, set self.td to a known place, like /tmp/foo (you will need
36# to create this directory as well)
37
43class TestDaemon(unittest.TestCase):38class TestDaemon(unittest.TestCase):
4439
45 ACCOMP_SET = "testaccomp"40 ACCOMP_SET = "testaccomp"
46 LANG = "en"41 LANG = "en"
4742
43 def util_copy_extrainfo(self, extrainfo_dir, extrainfo_name):
44 testdir = os.path.dirname(__file__)
45 src = os.path.join(testdir, "extrainformation", extrainfo_name)
46 dest = os.path.join(extrainfo_dir, extrainfo_name)
47 shutil.copyfile(src, dest)
48
48 def util_copy_accomp(self, accomp_dir, accomp_name):49 def util_copy_accomp(self, accomp_dir, accomp_name):
49 testdir = os.path.dirname(__file__)50 testdir = os.path.dirname(__file__)
50 src = os.path.join(testdir, "accomps",51 src = os.path.join(testdir, "accomps",
@@ -52,6 +53,10 @@
52 dest = os.path.join(accomp_dir, "%s.accomplishment" % accomp_name)53 dest = os.path.join(accomp_dir, "%s.accomplishment" % accomp_name)
53 shutil.copyfile(src, dest)54 shutil.copyfile(src, dest)
5455
56 # This function is not really needed because when tearDown runs it
57 # removes the entire tree, but when debugging tests it's useful to comment
58 # out the rmtree in tearDown, so then this is critical to make the tests
59 # work.
55 def util_remove_all_accomps(self, accomp_dir):60 def util_remove_all_accomps(self, accomp_dir):
56 for f in os.listdir(accomp_dir):61 for f in os.listdir(accomp_dir):
57 os.remove(os.path.join(self.accomp_dir, f))62 os.remove(os.path.join(self.accomp_dir, f))
@@ -119,9 +124,9 @@
119 if not os.path.exists(self.script_root):124 if not os.path.exists(self.script_root):
120 os.makedirs(self.script_root)125 os.makedirs(self.script_root)
121126
122 # XXX - not sure this is correct or needed127 # /tmp/foo/accomplishments/.local/share/accomplishments/trophies
123 # /tmp/foo/accomplishments/accomplishments/testaccomp/trophies128 self.trophy_dir = os.path.join(self.td, "accomplishments", ".local",
124 self.trophy_dir = os.path.join(self.td, "trophies")129 "share", "accomplishments", "trophies")
125 if not os.path.exists(self.trophy_dir):130 if not os.path.exists(self.trophy_dir):
126 os.makedirs(self.trophy_dir)131 os.makedirs(self.trophy_dir)
127132
@@ -171,14 +176,7 @@
171 "My Second Accomplishment")176 "My Second Accomplishment")
172 self.assertEquals(a.get_acc_title("%s/third" % self.ACCOMP_SET),177 self.assertEquals(a.get_acc_title("%s/third" % self.ACCOMP_SET),
173 "My Third Accomplishment")178 "My Third Accomplishment")
174179 self.assertRaises(KeyError, a.get_acc_title, "wrong")
175 # XXX - assertRaises isn't working here the way I think it
176 # should, this is a substitute
177 try:
178 a.get_acc_title("wrong")
179 self.assertTrue(False)
180 except KeyError:
181 self.assertTrue(True)
182180
183 # get_acc_description181 # get_acc_description
184 self.assertTrue("example" in a.get_acc_description("%s/first" %182 self.assertTrue("example" in a.get_acc_description("%s/first" %
@@ -187,27 +185,13 @@
187 self.ACCOMP_SET))185 self.ACCOMP_SET))
188 self.assertTrue("example" in a.get_acc_description("%s/third" %186 self.assertTrue("example" in a.get_acc_description("%s/third" %
189 self.ACCOMP_SET))187 self.ACCOMP_SET))
190188 self.assertRaises(KeyError, a.get_acc_description, "wrong")
191 # XXX - assertRaises isn't working here the way I think it
192 # should, this is a substitute
193 try:
194 a.get_acc_description("wrong")
195 self.assertTrue(False)
196 except KeyError:
197 self.assertTrue(True)
198189
199 # get_acc_needs_signing190 # get_acc_needs_signing
200 self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))191 self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))
201 self.assertTrue(a.get_acc_needs_signing("%s/second" % self.ACCOMP_SET))192 self.assertTrue(a.get_acc_needs_signing("%s/second" % self.ACCOMP_SET))
202 self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))193 self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))
203194 self.assertRaises(KeyError, a.get_acc_needs_signing, "wrong")
204 # XXX - assertRaises isn't working here the way I think it
205 # should, this is a substitute
206 try:
207 a.get_acc_needs_signing("wrong")
208 self.assertTrue(False)
209 except KeyError:
210 self.assertTrue(True)
211195
212 # get_acc_depends196 # get_acc_depends
213 self.assertTrue(a.get_acc_depends("%s/first" % self.ACCOMP_SET) == [])197 self.assertTrue(a.get_acc_depends("%s/first" % self.ACCOMP_SET) == [])
@@ -215,27 +199,13 @@
215 self.assertEquals(len(deps), 1)199 self.assertEquals(len(deps), 1)
216 self.assertTrue(deps[0] == "%s/first" % self.ACCOMP_SET)200 self.assertTrue(deps[0] == "%s/first" % self.ACCOMP_SET)
217 self.assertTrue(a.get_acc_depends("%s/third" % self.ACCOMP_SET) == [])201 self.assertTrue(a.get_acc_depends("%s/third" % self.ACCOMP_SET) == [])
218202 self.assertRaises(KeyError, a.get_acc_depends, "wrong")
219 # XXX - assertRaises isn't working here the way I think it
220 # should, this is a substitute
221 try:
222 a.get_acc_depends("wrong")
223 self.assertTrue(False)
224 except KeyError:
225 self.assertTrue(True)
226203
227 # get_acc_is_unlocked204 # get_acc_is_unlocked
228 self.assertTrue(a.get_acc_is_unlocked("%s/first" % self.ACCOMP_SET))205 self.assertTrue(a.get_acc_is_unlocked("%s/first" % self.ACCOMP_SET))
229 self.assertFalse(a.get_acc_is_unlocked("%s/second" % self.ACCOMP_SET))206 self.assertFalse(a.get_acc_is_unlocked("%s/second" % self.ACCOMP_SET))
230 self.assertTrue(a.get_acc_is_unlocked("%s/third" % self.ACCOMP_SET))207 self.assertTrue(a.get_acc_is_unlocked("%s/third" % self.ACCOMP_SET))
231208 self.assertRaises(KeyError, a.get_acc_is_unlocked, "wrong")
232 # XXX - assertRaises isn't working here the way I think it
233 # should, this is a substitute
234 try:
235 a.get_acc_is_unlocked("wrong")
236 self.assertTrue(False)
237 except KeyError:
238 self.assertTrue(True)
239209
240 # get_acc_is_completed210 # get_acc_is_completed
241 # XXX - when we get the accomplish() code working, make some of these211 # XXX - when we get the accomplish() code working, make some of these
@@ -243,14 +213,7 @@
243 self.assertFalse(a.get_acc_is_completed("%s/first" % self.ACCOMP_SET))213 self.assertFalse(a.get_acc_is_completed("%s/first" % self.ACCOMP_SET))
244 self.assertFalse(a.get_acc_is_completed("%s/second" % self.ACCOMP_SET))214 self.assertFalse(a.get_acc_is_completed("%s/second" % self.ACCOMP_SET))
245 self.assertFalse(a.get_acc_is_completed("%s/third" % self.ACCOMP_SET))215 self.assertFalse(a.get_acc_is_completed("%s/third" % self.ACCOMP_SET))
246216 self.assertRaises(KeyError, a.get_acc_is_completed, "wrong")
247 # XXX - assertRaises isn't working here the way I think it
248 # should, this is a substitute
249 try:
250 a.get_acc_is_completed("wrong")
251 self.assertTrue(False)
252 except KeyError:
253 self.assertTrue(True)
254217
255 # get_acc_script_path218 # get_acc_script_path
256 self.assertEqual(a.get_acc_script_path("%s/first" % self.ACCOMP_SET),219 self.assertEqual(a.get_acc_script_path("%s/first" % self.ACCOMP_SET),
@@ -260,30 +223,18 @@
260 self.util_write_file(self.script_root, "third.py", "print 'hello'")223 self.util_write_file(self.script_root, "third.py", "print 'hello'")
261 sp = a.get_acc_script_path("%s/third" % self.ACCOMP_SET)224 sp = a.get_acc_script_path("%s/third" % self.ACCOMP_SET)
262 self.assertTrue(sp.endswith("third.py"))225 self.assertTrue(sp.endswith("third.py"))
263226 self.assertRaises(KeyError, a.get_acc_script_path, "wrong")
264 try:
265 a.get_acc_script_path("wrong")
266 self.assertTrue(False)
267 except KeyError:
268 self.assertTrue(True)
269227
270 # get_acc_needs_info228 # get_acc_needs_info
271 info = a.get_acc_needs_info("%s/first" % self.ACCOMP_SET)229 info = a.get_acc_needs_info("%s/first" % self.ACCOMP_SET)
272 self.assertEqual(len(info),2)230 self.assertEqual(len(info),2)
273 self.assertEqual(info[0], "info")231 for i in info:
274 self.assertEqual(info[1], "more info")232 self.assertTrue(i in ["info", "info2"])
275 self.assertEqual(a.get_acc_needs_info("%s/second" % self.ACCOMP_SET),233 self.assertEqual(a.get_acc_needs_info("%s/second" % self.ACCOMP_SET),
276 [])234 [])
277 self.assertEqual(a.get_acc_needs_info("%s/third" % self.ACCOMP_SET),235 self.assertEqual(a.get_acc_needs_info("%s/third" % self.ACCOMP_SET),
278 [])236 [])
279237 self.assertRaises(KeyError, a.get_acc_needs_info, "wrong")
280 # XXX - assertRaises isn't working here the way I think it
281 # should, this is a substitute
282 try:
283 a.get_acc_needs_info("wrong")
284 self.assertTrue(False)
285 except KeyError:
286 self.assertTrue(True)
287238
288 # get_acc_collection239 # get_acc_collection
289 self.assertEqual(a.get_acc_collection("%s/first" % self.ACCOMP_SET),240 self.assertEqual(a.get_acc_collection("%s/first" % self.ACCOMP_SET),
@@ -292,32 +243,17 @@
292 self.ACCOMP_SET)243 self.ACCOMP_SET)
293 self.assertEqual(a.get_acc_collection("%s/third" % self.ACCOMP_SET),244 self.assertEqual(a.get_acc_collection("%s/third" % self.ACCOMP_SET),
294 self.ACCOMP_SET)245 self.ACCOMP_SET)
295246 self.assertRaises(KeyError, a.get_acc_collection, "wrong")
296 # XXX - assertRaises isn't working here the way I think it
297 # should, this is a substitute
298 try:
299 a.get_acc_collection("wrong")
300 self.assertTrue(False)
301 except KeyError:
302 self.assertTrue(True)
303247
304 # get_acc_categories248 # get_acc_categories
305 self.assertEqual(a.get_acc_categories("%s/first" % self.ACCOMP_SET), [])249 self.assertEqual(a.get_acc_categories("%s/first" % self.ACCOMP_SET), [])
306 self.assertEqual(a.get_acc_categories("%s/second" % self.ACCOMP_SET),250 self.assertEqual(a.get_acc_categories("%s/second" % self.ACCOMP_SET),
307 [])251 [])
308 info = a.get_acc_categories("%s/third" % self.ACCOMP_SET)252 categories = a.get_acc_categories("%s/third" % self.ACCOMP_SET)
309 self.assertEqual(len(info),2)253 self.assertEqual(len(info),2)
310 self.assertEqual(info[0], "testing")254 for category in categories:
311 self.assertEqual(info[1], "unit test")255 self.assertTrue(category in ["testing", "unit test"])
312256 self.assertRaises(KeyError, a.get_acc_categories, "wrong")
313 # XXX - assertRaises isn't working here the way I think it
314 # should, this is a substitute
315 try:
316 a.get_acc_categories("wrong")
317 self.assertTrue(False)
318 except KeyError:
319 self.assertTrue(True)
320
321257
322 def test_get_block_ubuntuone_notification_bubbles(self):258 def test_get_block_ubuntuone_notification_bubbles(self):
323 a = api.Accomplishments(None)259 a = api.Accomplishments(None)
@@ -489,5 +425,156 @@
489 self.util_write_config_file(self.config_dir)425 self.util_write_config_file(self.config_dir)
490 return426 return
491427
428 # this tests the get_collection_* functions and list_collections():
429 def test_get_collection_all_funcs(self):
430 self.util_remove_all_accomps(self.accomp_dir)
431 self.util_copy_accomp(self.accomp_dir, "first")
432 self.util_copy_accomp(self.accomp_dir, "second")
433 self.util_copy_accomp(self.accomp_dir, "third")
434 a = api.Accomplishments(None)
435
436 # list_collections
437 collections = a.list_collections()
438 self.assertEqual(len(collections), 1)
439 self.assertEqual(collections[0], self.ACCOMP_SET)
440
441 # get_collection_name
442 self.assertEqual(a.get_collection_name(collections[0]),
443 "Test Collection")
444 self.assertRaises(KeyError, a.get_collection_name, "wrong")
445
446 # get_collection_exists
447 self.assertTrue(a.get_collection_exists(collections[0]))
448 self.assertFalse(a.get_collection_exists("wrong"))
449 self.assertFalse(a.get_collection_exists(""))
450 self.assertFalse(a.get_collection_exists(None))
451
452 # get_collection_authors
453 authors = a.get_collection_authors(collections[0])
454 # we have only 2 authors because dupes are removed
455 self.assertEqual(len(authors), 2)
456 for author in authors:
457 self.assertTrue(author in ["Someone", "Tester <tester@tester>"])
458 self.assertRaises(KeyError, a.get_collection_authors, "wrong")
459
460 # get_collection_categories
461 categories = a.get_collection_categories(collections[0])
462 self.assertEqual(len(categories), 2)
463 for category in categories:
464 self.assertTrue(category in ["testing", "unit test"])
465 self.assertRaises(KeyError, a.get_collection_categories, "wrong")
466
467 # get_collection_data
468 data = a.get_collection_data(collections[0])
469 self.assertTrue(isinstance(data, dict))
470 self.assertNotEquals(data['authors'], None)
471 self.assertNotEquals(data['name'], None)
472 self.assertNotEquals(data['categories'], None)
473 self.assertRaises(KeyError, a.get_collection_data, "wrong")
474
475 # get trophy path
476 def test_get_trophy_path(self):
477 self.util_remove_all_accomps(self.accomp_dir)
478 self.util_copy_accomp(self.accomp_dir, "first")
479 self.util_copy_accomp(self.accomp_dir, "second")
480 self.util_copy_accomp(self.accomp_dir, "third")
481 a = api.Accomplishments(None)
482
483 self.assertTrue(a.get_trophy_path("%s/first" %
484 self.ACCOMP_SET).endswith("first.trophy"))
485 self.assertTrue(a.get_trophy_path("%s/second" %
486 self.ACCOMP_SET).endswith("second.trophy"))
487 self.assertTrue(a.get_trophy_path("%s/third" %
488 self.ACCOMP_SET).endswith("third.trophy"))
489
490 def test_write_extra_information_file(self):
491 a = api.Accomplishments(None)
492
493 # write extra information will make the directory for us if needed,
494 # so lets remove it (if present and force it to)
495 extrainfo_path = os.path.join(a.trophies_path, ".extrainformation")
496 if os.path.exists(extrainfo_path):
497 shutil.rmtree(extrainfo_path)
498
499 a.write_extra_information_file("whatever", "abcdefg")
500 path = os.path.join(extrainfo_path, "whatever")
501 self.assertTrue(os.path.exists(path))
502
503 # write extra info will remove a file if you don't pass in data
504 a.write_extra_information_file("whatever", None)
505 self.assertFalse(os.path.exists(path))
506
507 # tests:
508 # get_extra_information()
509 # get_all_extra_information()
510 # get_all_extra_information_required()
511 def test_get_extra_information_all_funcs(self):
512 a = api.Accomplishments(None)
513 self.util_copy_extrainfo(self.extrainfo_dir, "info")
514 self.util_copy_extrainfo(self.extrainfo_dir, "info2")
515 self.util_copy_accomp(self.accomp_dir, "first")
516
517 # get extra information
518 # these won't show up until we reload
519 self.assertRaises(KeyError, a.get_extra_information, self.ACCOMP_SET,
520 "info")
521
522 # should return None when the collection doesn't exist
523 self.assertEqual(a.get_extra_information("wrong", "info"), None)
524
525 # reloading should make them show up
526 a.reload_accom_database()
527
528 # will throw a KeyError if collection is right, but extrainfo is
529 # wrong
530 self.assertRaises(KeyError, a.get_extra_information, self.ACCOMP_SET,
531 "wrong")
532
533 ei = a.get_extra_information(self.ACCOMP_SET, "info")
534 self.assertTrue(isinstance(ei, list))
535 self.assertTrue(len(ei) == 1)
536 self.assertEqual(ei[0]['info'], '')
537 self.assertEqual(ei[0]['label'], 'Some info')
538 ei = a.get_extra_information(self.ACCOMP_SET, "info2")
539 self.assertTrue(isinstance(ei, list))
540 self.assertTrue(len(ei) == 1)
541 self.assertEqual(ei[0]['info2'], '')
542 self.assertEqual(ei[0]['label'], 'More info')
543
544 # write some data out and reload the DB
545 a.write_extra_information_file("info", "whatever")
546 ei = a.get_extra_information(self.ACCOMP_SET, "info")
547 self.assertEqual(ei[0]['info'], 'whatever')
548 a.write_extra_information_file("info2", "whatever2")
549 ei = a.get_extra_information(self.ACCOMP_SET, "info2")
550 self.assertEqual(ei[0]['info2'], 'whatever2')
551
552 # get all extra information
553 all_extra_info = a.get_all_extra_information()
554 self.assertTrue(isinstance(all_extra_info, list))
555 self.assertTrue(len(all_extra_info) == 2)
556 for ei in all_extra_info:
557 self.assertTrue(isinstance(ei, dict))
558 self.assertEquals(ei['collection'], self.ACCOMP_SET)
559 self.assertTrue(ei['description'] is not None)
560 self.assertTrue(ei['example'] is not None)
561 self.assertTrue(ei['needs-information'] is not None)
562 self.assertTrue(ei['regex'] is '')
563
564 # get all extra information required
565 # clear out the extra info files, so everything is required
566 a.write_extra_information_file("info", None)
567 a.write_extra_information_file("info2", None)
568 all_extra_info_required = a.get_all_extra_information_required()
569 self.assertTrue(isinstance(all_extra_info, list))
570 self.assertTrue(len(all_extra_info) == 2)
571
572 # now mark fill them in with info
573 a.write_extra_information_file("info", "whatever")
574 a.write_extra_information_file("info2", "whatever2")
575 all_extra_info_required = a.get_all_extra_information_required()
576 self.assertTrue(isinstance(all_extra_info_required, list))
577 self.assertTrue(len(all_extra_info_required) == 0)
578
492if __name__ == "__main__":579if __name__ == "__main__":
493 unittest.main()580 unittest.main()
494581
=== modified file 'debian/control'
--- debian/control 2012-05-29 18:37:07 +0000
+++ debian/control 2012-07-14 02:21:18 +0000
@@ -4,6 +4,7 @@
4Build-Depends: cdbs (>= 0.4.43),4Build-Depends: cdbs (>= 0.4.43),
5 debhelper (>= 6),5 debhelper (>= 6),
6 python (>= 2.6.6-3~),6 python (>= 2.6.6-3~),
7 python-nose,
7 python-distutils-extra (>= 2.10)8 python-distutils-extra (>= 2.10)
8Maintainer: Jono Bacon <jono@ubuntu.com>9Maintainer: Jono Bacon <jono@ubuntu.com>
9Standards-Version: 3.9.310Standards-Version: 3.9.3
1011
=== modified file 'debian/rules'
--- debian/rules 2012-04-12 00:23:38 +0000
+++ debian/rules 2012-07-14 02:21:18 +0000
@@ -6,4 +6,9 @@
6 dh $@ --with python26 dh $@ --with python2
7endif7endif
88
99override_dh_auto_test:
10ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
11 set -ex; for python in $(shell pyversions -r) ; do \
12 $$python /usr/bin/nosetests -v ; \
13 done
14endif

Subscribers

People subscribed via source and target branches