Merge lp:~bmastell/ubuntu-accomplishments-daemon/fix-for-1024015 into lp:ubuntu-accomplishments-daemon

Proposed by Brian Mastell
Status: Merged
Merge reported by: Jono Bacon
Merged at revision: not available
Proposed branch: lp:~bmastell/ubuntu-accomplishments-daemon/fix-for-1024015
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 1920 lines (+453/-453)
9 files modified
accomplishments/daemon/api.py (+158/-158)
accomplishments/daemon/dbusapi.py (+51/-51)
tests/accomps/first.accomplishment (+0/-7)
tests/accomps/second.accomplishment (+0/-8)
tests/accomps/third.accomplishment (+0/-10)
tests/accoms/first.accomplishment (+7/-0)
tests/accoms/second.accomplishment (+8/-0)
tests/accoms/third.accomplishment (+10/-0)
tests/tests.py (+219/-219)
To merge this branch: bzr merge lp:~bmastell/ubuntu-accomplishments-daemon/fix-for-1024015
Reviewer Review Type Date Requested Status
Rafał Cieślak Approve
Matt Fischer Approve
Review via email: mp+118819@code.launchpad.net

Description of the change

fix for #1024015

To post a comment you must log in.
Revision history for this message
Matt Fischer (mfisch) wrote :

You removed the 3 accomplishment files that we need to run tests. All the unit tests fail now.

review: Needs Fixing
129. By Brian Mastell

Fixed lack of 'adding' tests/accomps/ --> tests/accoms/ name change in commit.

Revision history for this message
Matt Fischer (mfisch) wrote :

Looks good. Rafal and Jono will also want to comment.

review: Approve
Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

This looks all good. Of course the viewer and lens will need to be updated to these changes too.

Thanks for this awesome work Brian!

review: Approve
Revision history for this message
Jono Bacon (jonobacon) wrote :

Absolutely wonderful work, Brian! Many thanks, and I am merging this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accomplishments/daemon/api.py'
2--- accomplishments/daemon/api.py 2012-08-06 20:53:32 +0000
3+++ accomplishments/daemon/api.py 2012-08-08 22:24:17 +0000
4@@ -271,12 +271,12 @@
5 # It happens that the .asc file is present, but we miss the
6 # signal it triggers - so here we can re-check if it is not
7 # present.
8- if self.parent._check_if_acc_is_completed(accomID):
9+ if self.parent._check_if_accom_is_completed(accomID):
10 self.parent.accomplish(accomID)
11 else:
12 # Okay, this one hasn't been yet completed.
13- # Run the acc script and determine exit code.
14- scriptpath = self.parent.get_acc_script_path(accomID)
15+ # Run the accom script and determine exit code.
16+ scriptpath = self.parent.get_accom_script_path(accomID)
17 if scriptpath is None:
18 log.msg("...No script for this accomplishment, skipping")
19 elif not self.parent._is_all_extra_information_available(accomID):
20@@ -324,7 +324,7 @@
21 No D-Bus required, so that it can be used for testing.
22 """
23 def __init__(self, service, show_notifications=None, test_mode=False):
24- self.accomplishments_installpaths = None
25+ self.accoms_installpaths = None
26 self.trophies_path = None
27 self.has_u1 = False
28 self.has_verif = None
29@@ -378,7 +378,7 @@
30
31 self._load_config_file()
32
33- print str("Accomplishments install paths: " + self.accomplishments_installpaths)
34+ print str("Accomplishments install paths: " + self.accoms_installpaths)
35 print str("Trophies path: " + self.trophies_path)
36
37 self.show_notifications = show_notifications
38@@ -420,7 +420,7 @@
39 cols = self.list_collections()
40
41 for col in cols:
42- col_imagespath = os.path.join(self.accDB[col]['base-path'],"trophyimages")
43+ col_imagespath = os.path.join(self.accomDB[col]['base-path'],"trophyimages")
44 cache_trophyimagespath = os.path.join(
45 self.dir_cache, "trophyimages", col)
46 lock_image_path = os.path.join(media_dir, "lock.png")
47@@ -537,7 +537,7 @@
48
49 config.set('config', 'has_u1', self.has_u1)
50 config.set('config', 'has_verif', self.has_verif)
51- config.set('config', 'accompath', self.accomplishments_installpaths)
52+ config.set('config', 'accompath', self.accoms_installpaths)
53 config.set('config', 'trophypath', self.trophies_path)
54
55 with open(cfile, 'wb') as configfile:
56@@ -558,10 +558,10 @@
57 if config.read(cfile):
58 log.msg("Loading configuration file: " + cfile)
59 if config.get('config', 'accompath'):
60- self.accomplishments_installpaths = config.get('config', 'accompath')
61+ self.accoms_installpaths = config.get('config', 'accompath')
62 log.msg(
63 "...setting accomplishments install paths to: "
64- + self.accomplishments_installpaths)
65+ + self.accoms_installpaths)
66 if config.get('config', 'trophypath'):
67 log.msg(
68 "...setting trophies path to: "
69@@ -583,10 +583,10 @@
70 log.msg("Configuration file not found...creating it!")
71
72 self.has_verif = False
73- self.accomplishments_installpaths = accompath
74+ self.accoms_installpaths = accompath
75 log.msg(
76 "...setting accomplishments install paths to: "
77- + self.accomplishments_installpaths)
78+ + self.accoms_installpaths)
79 log.msg("You can set this to different locations in your config file.")
80 self.trophies_path = os.path.join(self.dir_data, "trophies")
81 log.msg("...setting trophies path to: " + self.trophies_path)
82@@ -667,7 +667,7 @@
83 {"collection" : "ubuntu-community", "needs-information" : "askubuntu-user-url", "label" : "AskUbuntu user profile URL", "description" : "The URL of your AskUbuntu usr profile page", "example" : "http://askubuntu.com/users/42/nick", "regex" : "", "value" : ""}]
84 """
85 # get a list of all accomplishments
86- accomplishments = self.list_accomplishments()
87+ accoms = self.list_accoms()
88
89 infoneeded = []
90 # and prepend the path to the directory, where all extra-information
91@@ -681,30 +681,30 @@
92 os.makedirs(trophyextrainfo)
93
94 # now, for each accomplishment file that is available...
95- for acc in accomplishments:
96+ for accom in accoms:
97 # get the path to the directory of accomplishments set's
98 # "extrainformation" dir - it is useful, because it contains
99 # translated labels and descriptions
100- accomextrainfo = os.path.join(self.accDB[acc]['base-path']
101+ accomextrainfo = os.path.join(self.accomDB[accom]['base-path']
102 , "extrainformation")
103
104 # a temporary variable, representing a single entry of the list this function returns
105 d = {}
106
107 # Get collection name from accomOD
108- collection = self._coll_from_accomID(acc)
109+ collection = self._coll_from_accomID(accom)
110
111- ei = self.get_acc_needs_info(acc)
112+ ei = self.get_accom_needs_info(accom)
113 if len(ei) is not 0:
114
115 # For each needed piece of information:
116 for i in ei:
117- label = self.accDB[collection]['extra-information'][i]['label']
118- desc = self.accDB[collection]['extra-information'][i]['description']
119- example = self.accDB[collection]['extra-information'][i].get('example')
120+ label = self.accomDB[collection]['extra-information'][i]['label']
121+ desc = self.accomDB[collection]['extra-information'][i]['description']
122+ example = self.accomDB[collection]['extra-information'][i].get('example')
123 if example is None:
124 example = ''
125- regex = self.accDB[collection]['extra-information'][i].get('regex')
126+ regex = self.accomDB[collection]['extra-information'][i].get('regex')
127 if regex is None:
128 regex = ''
129 # we also need to know whether user has already set this item's value.
130@@ -829,7 +829,7 @@
131 # Returns True if all extra information is available for an accom,
132 # False otherwise
133 def _is_all_extra_information_available(self, accomID):
134- info_reqd = self.get_acc_needs_info(accomID)
135+ info_reqd = self.get_accom_needs_info(accomID)
136 if len(info_reqd) == 0:
137 return True
138
139@@ -889,7 +889,7 @@
140 log.msg("No such collection:" + coll)
141 return None
142
143- label = self.accDB[coll]['extra-information'][item]['label']
144+ label = self.accomDB[coll]['extra-information'][item]['label']
145
146 try:
147 f = open(authfile, "r")
148@@ -904,13 +904,13 @@
149
150 def reload_accom_database(self):
151 """
152- This is the function that builds up the *accDB* accomplishments database. It scans all accomplishment installation directories (as set in the config file), looks for all installed collections, and caches all accomplishments' data in memory. If a translated .accomplishment file is available, it's contents are loaded instead.
153+ This is the function that builds up the *accomDB* accomplishments database. It scans all accomplishment installation directories (as set in the config file), looks for all installed collections, and caches all accomplishments' data in memory. If a translated .accomplishment file is available, it's contents are loaded instead.
154
155 It also groups collection categories, authors, finds accomplishment script paths, and counts accomplishments in collections.
156
157- All results are stored in an internal variable, *self.accDB*. They can be accessed afterwards using get_acc_* functions.
158+ All results are stored in an internal variable, *self.accomDB*. They can be accessed afterwards using get_acc_* functions.
159
160- Running this function also calls _update_all_locked_and_completed_statuses(), which completes initialising the *accDB*, as it fills in it's "completed" and "locked" fields.
161+ Running this function also calls _update_all_locked_and_completed_statuses(), which completes initialising the *accomDB*, as it fills in it's "completed" and "locked" fields.
162
163 .. note::
164 There is no need for clients to run this method manually when the daemon is started - this function is called by this class' __init__.
165@@ -923,10 +923,10 @@
166
167 """
168 # First, clear the database.
169- self.accDB = {}
170+ self.accomDB = {}
171 # Get the list of all paths where accomplishments may be
172 # installed...
173- installpaths = self.accomplishments_installpaths.split(":")
174+ installpaths = self.accoms_installpaths.split(":")
175 for installpath in installpaths:
176 # Look for all accomplishment collections in this path
177 path = os.path.join(installpath,'accomplishments')
178@@ -936,7 +936,7 @@
179 collections = os.listdir(path)
180 for collection in collections:
181 # For each collection...
182- if collection in self.accDB:
183+ if collection in self.accomDB:
184 # This collection has already been loaded from another install path!
185 continue
186
187@@ -1019,13 +1019,13 @@
188 del accomdata['category']
189 else:
190 accomdata['categories'] = []
191- self.accDB[accomID] = accomdata
192+ self.accomDB[accomID] = accomdata
193 accno = accno + 1
194 else:
195 # this is indeed a set!
196 setID = collection + ":" + accomset
197 setdata = {'type':"set",'name':accomset}
198- self.accDB[setID] = setdata
199+ self.accomDB[setID] = setdata
200 setdir = os.path.join(langdefaultpath,accomset)
201 accomfiles = os.listdir(setdir)
202 for accomfile in accomfiles:
203@@ -1086,7 +1086,7 @@
204 del accomdata['category']
205 else:
206 accomdata['categories'] = []
207- self.accDB[accomID] = accomdata
208+ self.accomDB[accomID] = accomdata
209 accno = accno + 1
210
211 # Look for extrainformation dir
212@@ -1135,23 +1135,23 @@
213
214 # Store data about this colection
215 collectiondata = {'langdefault':langdefault,'name':collectionname, 'acc_num':accno, 'type':"collection", 'base-path': collpath, 'categories' : collcategories, 'extra-information': extrainfo, 'authors':collauthors}
216- self.accDB[collection] = collectiondata
217+ self.accomDB[collection] = collectiondata
218
219 self._update_all_locked_and_completed_statuses()
220
221 if not self.test_mode:
222- self.service.accomplishments_collections_reloaded()
223+ self.service.accoms_collections_reloaded()
224 # Uncomment following for debugging
225- # print self.accDB\
226+ # print self.accomDB\
227
228 # ======= Access functions =======
229
230- def get_acc_data(self,accomID):
231- return self.accDB[accomID]
232+ def get_accom_data(self,accomID):
233+ return self.accomDB[accomID]
234
235- def get_acc_exists(self,accomID):
236+ def get_accom_exists(self,accomID):
237 """
238- Returns False if given accomplishmentID is not valid, or such accomplishment is not installed on the system.
239+ Returns False if given **accomID** is not valid, or such accomplishment is not installed on the system.
240
241 Args:
242 * **accomID** - (str) The accomplishmentID.
243@@ -1160,33 +1160,33 @@
244 * **(bool)** - True if this accomplishmentID is valid AND available for this installation.
245
246 Example:
247- >>> acc.get_acc_exists("blah")
248- False
249- >>> acc.get_acc_exists("ubuntu-community")
250- False
251- >>> acc.get_acc_exists("ubuntu-community/no-such-accomplishment")
252- False
253- >>> acc.get_acc_exists("ubuntu-community/registered-on-launchpad")
254+ >>> acc.get_accom_exists("blah")
255+ False
256+ >>> acc.get_accom_exists("ubuntu-community")
257+ False
258+ >>> acc.get_accom_exists("ubuntu-community/no-such-accomplishment")
259+ False
260+ >>> acc.get_accom_exists("ubuntu-community/registered-on-launchpad")
261 True
262 """
263
264- if not accomID in self.accDB:
265+ if not accomID in self.accomDB:
266 return False
267
268- if self.accDB[accomID]['type'] is "accomplishment":
269+ if self.accomDB[accomID]['type'] is "accomplishment":
270 return True
271 else:
272 return False
273
274- def get_acc_title(self,accomID):
275- return self.accDB[accomID]['title']
276-
277- def get_acc_description(self,accomID):
278- return self.accDB[accomID]['description']
279-
280- def get_acc_needs_signing(self,accomID):
281+ def get_accom_title(self,accomID):
282+ return self.accomDB[accomID]['title']
283+
284+ def get_accom_description(self,accomID):
285+ return self.accomDB[accomID]['description']
286+
287+ def get_accom_needs_signing(self,accomID):
288 """
289- This function states whether an accomplishment needs verification by external server. It does not state, hoewver, whether this trophy has been already signed or not, use get_acc_is_completed instead.
290+ This function states whether an accomplishment needs verification by external server. It does not state, hoewver, whether this trophy has been already signed or not, use get_accom_is_completed instead.
291
292 Args:
293 * **accomID** - (str) The accomplishmentID.
294@@ -1195,19 +1195,19 @@
295 * **(bool)** - True if the accomplishment needs signing.
296
297 Example:
298- >>> acc.get_acc_needs_signing("ubuntu-community/registered-on-launchpad")
299+ >>> acc.get_accom_needs_signing("ubuntu-community/registered-on-launchpad")
300 True
301- >>> acc.get_acc_needs_signing("ubuntu-desktop/gwibber-twitter")
302+ >>> acc.get_accom_needs_signing("ubuntu-desktop/gwibber-twitter")
303 False
304 """
305- if not 'needs-signing' in self.accDB[accomID]:
306+ if not 'needs-signing' in self.accomDB[accomID]:
307 return False
308- elif (self.accDB[accomID]['needs-signing'] == "false" or self.accDB[accomID]['needs-signing'] == "False" or self.accDB[accomID]['needs-signing'] == "no"):
309+ elif (self.accomDB[accomID]['needs-signing'] == "false" or self.accomDB[accomID]['needs-signing'] == "False" or self.accomDB[accomID]['needs-signing'] == "no"):
310 return False
311 else:
312 return True
313
314- def get_acc_depends(self,accomID):
315+ def get_accom_depends(self,accomID):
316 """
317 Returns a list of accomplishments a chosen accomplishment depends on (meaning: they all need to be completed in order to unlock the given one).
318
319@@ -1218,19 +1218,19 @@
320 * **(list[str])** - List of accomplishmentIDs of accomplishments that need to be completed before this one is unlocked.
321
322 Example:
323- >>> acc.get_acc_depends("ubuntu-community/registered-on-launchpad")
324+ >>> acc.get_accom_depends("ubuntu-community/registered-on-launchpad")
325 []
326- >>> acc.get_acc_depends("ubuntu-community/ubuntu-member")
327+ >>> acc.get_accom_depends("ubuntu-community/ubuntu-member")
328 ["ubuntu-community/registered-on-launchpad", "ubuntu-community/signed-ubuntu-code-of-conduct"]
329- >>> acc.get_acc_depends("ubuntu-desktop/gnomine_small-5-times")
330+ >>> acc.get_accom_depends("ubuntu-desktop/gnomine_small-5-times")
331 ["ubuntu-desktop/gnomine_win-small"]
332 """
333- if 'depends' in self.accDB[accomID]:
334- return [a.rstrip().lstrip() for a in self.accDB[accomID]['depends'].split(",")]
335+ if 'depends' in self.accomDB[accomID]:
336+ return [a.rstrip().lstrip() for a in self.accomDB[accomID]['depends'].split(",")]
337 else:
338 return []
339
340- def get_acc_is_unlocked(self,accomID):
341+ def get_accom_is_unlocked(self,accomID):
342 """
343 Returns True if this accomplishment is unlocked (ready to be achieved), False otherwise.
344
345@@ -1241,23 +1241,23 @@
346 * **(bool)** - Whether this accomplishment is unlocked.
347
348 Example:
349- >>> acc.get_acc_is_unlocked("ubuntu-community/askubuntu-teacher")
350+ >>> acc.get_accom_is_unlocked("ubuntu-community/askubuntu-teacher")
351 False
352- >>> acc.get_acc_depends("ubuntu-community/askubuntu-teacher")
353+ >>> acc.get_accom_depends("ubuntu-community/askubuntu-teacher")
354 ["ubuntu-community/registered-on-askubuntu"]
355- >>> acc.get_acc_is_completed("ubuntu-community/registered-on-askubuntu")
356+ >>> acc.get_accom_is_completed("ubuntu-community/registered-on-askubuntu")
357 False
358 >>> acc.accomplish("ubuntu-community/registered-on-askubuntu")
359- >>> acc.get_acc_is_completed("ubuntu-community/registered-on-askubuntu")
360+ >>> acc.get_accom_is_completed("ubuntu-community/registered-on-askubuntu")
361 True
362- >>> acc.get_acc_is_unlocked("ubuntu-community/askubuntu-teacher")
363+ >>> acc.get_accom_is_unlocked("ubuntu-community/askubuntu-teacher")
364 True
365 """
366- return not self.accDB[accomID]['locked']
367+ return not self.accomDB[accomID]['locked']
368
369 def get_trophy_path(self,accomID):
370 """
371- This function returns a path to the .trophy file related to given **accomplishmentID**. The trophy file may or may not exist.
372+ This function returns a path to the .trophy file related to given **accomID**. The trophy file may or may not exist.
373
374 Args:
375 * **accomID** - (str) The accomplishmentID.
376@@ -1269,13 +1269,13 @@
377 >>> acc.get_trophy_path("ubuntu-community/registered-on-launchpad")
378 /home/cielak/.local/share/accomplishments/trophies/ubuntu-community/registered-on-launchpad.trophy
379 """
380- if not self.get_acc_exists(accomID):
381+ if not self.get_accom_exists(accomID):
382 # hopefully an empty path will break something...
383 return ""
384 else:
385 return os.path.join(self.trophies_path,accomID + ".trophy")
386
387- def get_acc_is_completed(self,accomID):
388+ def get_accom_is_completed(self,accomID):
389 """
390 Returns whether this accomplishment is completed (if it needs to be verified by the external server, this will return False if the .asc signature is not present)
391
392@@ -1286,46 +1286,46 @@
393 * **(bool)** - Whether this accomplishment is completed.
394
395 Example:
396- >>> acc.get_acc_is_completed("ubuntu-community/registered-on-askubuntu")
397+ >>> acc.get_accom_is_completed("ubuntu-community/registered-on-askubuntu")
398 False
399 >>> acc.accomplish("ubuntu-community/registered-on-askubuntu")
400- >>> acc.get_acc_is_completed("ubuntu-community/registered-on-askubuntu")
401+ >>> acc.get_accom_is_completed("ubuntu-community/registered-on-askubuntu")
402 True
403 """
404- return self.accDB[accomID]['completed']
405+ return self.accomDB[accomID]['completed']
406
407- def get_acc_script_path(self,accomID):
408- res = self.accDB[accomID]['script-path']
409+ def get_accom_script_path(self,accomID):
410+ res = self.accomDB[accomID]['script-path']
411 if not os.path.exists(res):
412 return None
413 else:
414 return res
415
416- def get_acc_icon(self,accomID):
417- return self.accDB[accomID]['icon']
418+ def get_accom_icon(self,accomID):
419+ return self.accomDB[accomID]['icon']
420
421- def get_acc_icon_path(self,accomID):
422+ def get_accom_icon_path(self,accomID):
423 imagesdir = os.path.join(self.dir_cache,'trophyimages')
424- imagesdir = os.path.join(imagesdir,self.get_acc_collection(accomID))
425- iconfile = self.get_acc_icon(accomID)
426+ imagesdir = os.path.join(imagesdir,self.get_accom_collection(accomID))
427+ iconfile = self.get_accom_icon(accomID)
428 iconfilename, iconfileext = os.path.splitext(iconfile)
429
430 # safely handle files without extensions
431 if not iconfileext:
432 iconfileext = ""
433- if not self.get_acc_is_unlocked(accomID):
434+ if not self.get_accom_is_unlocked(accomID):
435 iconfilename = iconfilename + '-locked'
436- elif not self.get_acc_is_completed(accomID):
437+ elif not self.get_accom_is_completed(accomID):
438 iconfilename = iconfilename + '-opportunity'
439 iconfile = iconfilename + iconfileext
440 return os.path.join(imagesdir,iconfile)
441
442- def get_acc_needs_info(self,accomID):
443- if not 'needs-information' in self.accDB[accomID]:
444+ def get_accom_needs_info(self,accomID):
445+ if not 'needs-information' in self.accomDB[accomID]:
446 return []
447- return [a.rstrip().lstrip() for a in self.accDB[accomID]['needs-information'].split(",")]
448+ return [a.rstrip().lstrip() for a in self.accomDB[accomID]['needs-information'].split(",")]
449
450- def get_acc_collection(self,accomID):
451+ def get_accom_collection(self,accomID):
452 """
453 Returns the name of the collection this accomplishment orginates from.
454
455@@ -1334,12 +1334,12 @@
456 Returns:
457 * **str** - Collection name.
458 Example:
459- >>> acc.get_acc_collection("ubuntu-community/signed-code-of-conduct")
460+ >>> acc.get_accom_collection("ubuntu-community/signed-code-of-conduct")
461 ubuntu-community
462 """
463- return self.accDB[accomID]['collection']
464+ return self.accomDB[accomID]['collection']
465
466- def get_acc_categories(self,accomID):
467+ def get_accom_categories(self,accomID):
468 """
469 Returns a list of categories for a given accomplishment. This can
470 include sub-categories (which are formatted like 'category:subcategory'
471@@ -1350,15 +1350,15 @@
472 Returns:
473 * **list(str)** The list of categories.
474 Example:
475- >>> obj.get_acc_categories("ubuntu-community/registered-on-launchpad")
476+ >>> obj.get_accom_categories("ubuntu-community/registered-on-launchpad")
477 ["Launchpad"]
478- >>> obj.get_acc_categories("some_other_collection/another-accomplishment")
479+ >>> obj.get_accom_categories("some_other_collection/another-accomplishment")
480 ["Category One", "Category Two:Subcategory"]
481 """
482
483- return self.accDB[accomID]['categories']
484+ return self.accomDB[accomID]['categories']
485
486- def get_acc_date_completed(self,accomID):
487+ def get_accom_date_completed(self,accomID):
488 """
489 Returns the date that the accomplishment specified by 'accomID' was
490 completed.
491@@ -1368,11 +1368,11 @@
492 Returns:
493 (string) The completed date
494 Example:
495- >>> obj.get_acc_date_completed("ubuntu-community/registered-on-launchpad")
496+ >>> obj.get_accom_date_completed("ubuntu-community/registered-on-launchpad")
497 "2012-06-15 12:32"
498 """
499
500- return self.accDB[accomID]['date-completed']
501+ return self.accomDB[accomID]['date-completed']
502
503 def get_trophy_data(self,accomID):
504 """
505@@ -1388,7 +1388,7 @@
506 >>> acc.get_trophy_data("ubuntu-community/registered-on-launchpad")
507 {'needs-signing': 'true', 'date-accomplished': '1990-04-12 02:22', 'needs-information': 'launchpad-email', 'version': '0.2', '__name__': 'trophy', 'launchpad-email': 'launchpaduser@ubuntu.com', 'id': 'ubuntu-community/registered-on-launchpad'}
508 """
509- if not self.get_acc_is_completed(accomID):
510+ if not self.get_accom_is_completed(accomID):
511 return None
512 else:
513 cfg = ConfigParser.RawConfigParser()
514@@ -1407,7 +1407,7 @@
515 >>> acc.get_collection_name("ubuntu-desktop")
516 Ubuntu Desktop
517 """
518- return self.accDB[collection]['name']
519+ return self.accomDB[collection]['name']
520
521 def get_collection_exists(self,collection):
522 """
523@@ -1437,7 +1437,7 @@
524 >>> acc.get_collection_authors("ubuntu-community")
525 set(['Surgemcgee <RobertSteckroth@gmail.com>', 'Silver Fox <silver-fox@ubuntu.com>', 'Hernando Torque <sirius@sonnenkinder.org>', 'Nathan Osman <admin@quickmediasolutions.com>', 'Rafa\xc5\x82 Cie\xc5\x9blak <rafalcieslak256@ubuntu.com>', 'Michael Hall <mhall119@ubuntu.com>', 'Angelo Compagnucci <angelo.compagnucci@gmail.com>', 'Matt Fischer <matthew.fischer@canonical.com>', 'Bruno Girin <brunogirin@gmail.com>', 'Jorge O. Castro <jorge@ubuntu.com>', 'Andrea Grandi <a.grandi@gmail.com>', 'Marco Ceppi <marco@ceppi.net>', 'Agmenor <agmenor@laposte.net>', 'Christopher Kyle Horton <christhehorton@gmail.com>', 'Jos\xc3\xa9 Antonio Rey <joseeantonior@ubuntu-pe.org>', 's.fox <silver-fox@ubuntu.com>', 'Jono Bacon <jono@ubuntu.com>'])
526 """
527- return self.accDB[collection]['authors']
528+ return self.accomDB[collection]['authors']
529
530 def get_collection_categories(self,collection):
531 """
532@@ -1462,11 +1462,11 @@
533 'Forums': [],
534 'Events': [] }
535 """
536- return self.accDB[collection]['categories']
537+ return self.accomDB[collection]['categories']
538
539 def get_collection_data(self,collection):
540 """
541- This function returns all data stored in accDB for a given collection. It may be only useful if you need to access any data that don't have their own get_collection_* function.
542+ This function returns all data stored in accomDB for a given collection. It may be only useful if you need to access any data that don't have their own get_collection_* function.
543
544 Args:
545 * **collection** - (str) Sellected collection name (e.g. "ubuntu-community")
546@@ -1481,35 +1481,35 @@
547 * *extra-information* - dict(str:dict(str:str)) list of all extra-information used with it's medatada, use get_extra_information or get_all_extra_information instead
548 * *categories* - dict(str:list(str)) list of all categories and subcategories, use get_collection_categories instead
549 """
550- return self.accDB[collection]
551+ return self.accomDB[collection]
552
553 # ====== Listing functions ======
554
555- def list_accomplishments(self):
556- return [acc for acc in self.accomslist()]
557+ def list_accoms(self):
558+ return [accom for accom in self.accomslist()]
559
560 def list_trophies(self):
561- return [acc for acc in self.accomslist() if self.get_acc_is_completed(acc)]
562+ return [accom for accom in self.accomslist() if self.get_accom_is_completed(accom)]
563
564 def list_opportunitues(self):
565- return [acc for acc in self.accomslist() if not self.get_acc_is_completed(acc)]
566+ return [accom for accom in self.accomslist() if not self.get_accom_is_completed(accom)]
567
568 def list_depending_on(self,accomID):
569- return [acc for acc in self.accomslist() if accomID in self.get_acc_depends(acc)]
570+ return [accom for accom in self.accomslist() if accomID in self.get_accom_depends(accom)]
571
572 def list_unlocked(self):
573- return [acc for acc in self.accomslist() if self.get_acc_is_unlocked(acc)]
574+ return [accom for accom in self.accomslist() if self.get_accom_is_unlocked(accom)]
575
576 def list_unlocked_not_completed(self):
577- return [acc for acc in self.accomslist() if self.get_acc_is_unlocked(acc) and not self.get_acc_is_completed(acc)]
578+ return [accom for accom in self.accomslist() if self.get_accom_is_unlocked(accom) and not self.get_accom_is_completed(accom)]
579
580 def list_collections(self):
581- return [col for col in self.accDB if self.accDB[col]['type'] == 'collection']
582+ return [col for col in self.accomDB if self.accomDB[col]['type'] == 'collection']
583
584 # ====== Scriptrunner functions ======
585
586 def run_script(self,accomID):
587- if not self.get_acc_exists(accomID):
588+ if not self.get_accom_exists(accomID):
589 return
590 self.run_scripts([accomID])
591
592@@ -1536,20 +1536,20 @@
593 # ====== Viewer-specific functions ======
594
595 def build_viewer_database(self):
596- accs = self.list_accomplishments()
597+ accoms = self.list_accoms()
598 db = []
599- for acc in accs:
600+ for accom in accoms:
601 db.append({
602- 'title' : self.get_acc_title(acc),
603- 'accomplished' : self.get_acc_is_completed(acc),
604- 'locked' : not self.get_acc_is_unlocked(acc),
605- 'date-completed' : self.get_acc_date_completed(acc),
606- 'iconpath' : self.get_acc_icon_path(acc),
607- 'collection' : self.get_acc_collection(acc),
608+ 'title' : self.get_accom_title(accom),
609+ 'accomplished' : self.get_accom_is_completed(accom),
610+ 'locked' : not self.get_accom_is_unlocked(accom),
611+ 'date-completed' : self.get_accom_date_completed(accom),
612+ 'iconpath' : self.get_accom_icon_path(accom),
613+ 'collection' : self.get_accom_collection(accom),
614 'collection-human' :self.get_collection_name(
615- self.get_acc_collection(acc) ),
616- 'categories' : self.get_acc_categories(acc),
617- 'id' : acc
618+ self.get_accom_collection(accom) ),
619+ 'categories' : self.get_accom_categories(accom),
620+ 'id' : accom
621 })
622 return db
623
624@@ -1568,32 +1568,32 @@
625
626 def accomplish(self,accomID):
627 log.msg("Accomplishing: %s" % accomID)
628- if not self.get_acc_exists(accomID):
629+ if not self.get_accom_exists(accomID):
630 log.msg("There is no such accomplishment.")
631 return False #failure
632
633 # Check if is hasn't been already completed
634- if self.get_acc_is_completed(accomID):
635+ if self.get_accom_is_completed(accomID):
636 log.msg("Not accomplishing " + accomID + ", it has already been completed.")
637 return True #success
638
639 # Check if this accomplishment is unlocked
640- if not self.get_acc_is_unlocked(accomID):
641+ if not self.get_accom_is_unlocked(accomID):
642 log.msg("This accomplishment cannot be completed; it's locked.")
643 return False
644
645 coll = self._coll_from_accomID(accomID)
646- accdata = self.get_acc_data(accomID)
647+ accdata = self.get_accom_data(accomID)
648
649 # Prepare extra-info
650- needsinformation = self.get_acc_needs_info(accomID)
651+ needsinformation = self.get_accom_needs_info(accomID)
652 for i in needsinformation:
653 accdata[i] = self.get_extra_information(coll,i)[0][i]
654
655 # Create .trophy file
656 self._create_trophy_file(accdata, accomID)
657
658- if not self.get_acc_needs_signing(accomID):
659+ if not self.get_accom_needs_signing(accomID):
660 # The accomplishment does not need signing!
661 if not self.test_mode:
662 self.service.trophy_received(accomID)
663@@ -1718,8 +1718,8 @@
664 Notify.is_initted() or Notify.init("icon-summary-body")):
665 n = Notify.Notification.new(
666 _("You have accomplished something!"),
667- self.get_acc_title(accomID),
668- self.get_acc_icon_path(accomID) )
669+ self.get_accom_title(accomID),
670+ self.get_accom_icon_path(accomID) )
671 n.set_hint_string('append', 'allowed')
672 n.show()
673
674@@ -1735,8 +1735,8 @@
675 n.show()
676
677 def accomslist(self):
678- for k in self.accDB:
679- if self.accDB[k]['type'] is "accomplishment":
680+ for k in self.accomDB:
681+ if self.accomDB[k]['type'] is "accomplishment":
682 yield k
683
684 def _get_is_asc_correct(self,filepath):
685@@ -1766,12 +1766,12 @@
686 log.msg("Cannot check if signature is correct, because file %s does not exist" % filepath)
687 return False
688
689- def _check_if_acc_is_completed(self,accomID):
690+ def _check_if_accom_is_completed(self,accomID):
691 trophypath = self.get_trophy_path(accomID)
692 if not os.path.exists(trophypath):
693 # There is no trophy file
694 return False
695- if not self.get_acc_needs_signing(accomID):
696+ if not self.get_accom_needs_signing(accomID):
697 # The trophy does not need a signature
698 return True
699 else:
700@@ -1782,29 +1782,29 @@
701 else:
702 return self._get_is_asc_correct(ascpath)
703
704- def _check_if_acc_is_locked(self,accomID):
705- dep = self.get_acc_depends(accomID)
706+ def _check_if_accom_is_locked(self,accomID):
707+ dep = self.get_accom_depends(accomID)
708 if not dep:
709 return False
710 else:
711 locked = False
712 for d in dep:
713 # If at least one dependency is not completed...
714- if not self.get_acc_is_completed(d):
715+ if not self.get_accom_is_completed(d):
716 locked = True
717 break
718 return locked
719
720 def _update_all_locked_and_completed_statuses(self):
721- accs = self.list_accomplishments()
722- for acc in accs:
723- self.accDB[acc]['completed'] = self._check_if_acc_is_completed(acc)
724- if self.accDB[acc]['completed'] == True:
725- self.accDB[acc]['date-completed'] = self._get_trophy_date_completed(acc)
726+ accoms = self.list_accoms()
727+ for accom in accoms:
728+ self.accomDB[accom]['completed'] = self._check_if_accom_is_completed(accom)
729+ if self.accomDB[accom]['completed'] == True:
730+ self.accomDB[accom]['date-completed'] = self._get_trophy_date_completed(accom)
731 else:
732- self.accDB[acc]['date-completed'] = "None"
733- for acc in accs:
734- self.accDB[acc]['locked'] = self._check_if_acc_is_locked(acc)
735+ self.accomDB[accom]['date-completed'] = "None"
736+ for accom in accoms:
737+ self.accomDB[accom]['locked'] = self._check_if_accom_is_locked(accom)
738
739 def _get_trophy_date_completed(self, accomID):
740 trophypath = self.get_trophy_path(accomID)
741@@ -1820,18 +1820,18 @@
742 return config.get("trophy", "date-accomplished")
743
744 def _mark_as_completed(self,accomID):
745- # Marks accomplishments as completed int the accDB, and returns a list
746+ # Marks accomplishments as completed int the accomDB, and returns a list
747 # of accomIDs that just got unlocked.
748- self.accDB[accomID]['completed'] = True
749- self.accDB[accomID]['date-completed'] = self._get_trophy_date_completed(accomID)
750- accs = self.list_depending_on(accomID)
751+ self.accomDB[accomID]['completed'] = True
752+ self.accomDB[accomID]['date-completed'] = self._get_trophy_date_completed(accomID)
753+ accoms = self.list_depending_on(accomID)
754 res = []
755- for acc in accs:
756- before = self.accDB[acc]['locked']
757- self.accDB[acc]['locked'] = self._check_if_acc_is_locked(acc)
758+ for accom in accoms:
759+ before = self.accomDB[accom]['locked']
760+ self.accomDB[accom]['locked'] = self._check_if_accom_is_locked(accom)
761 # If it just got unlocked...
762- if (before == True and self.accDB[acc]['locked'] == False):
763- res.append(acc)
764+ if (before == True and self.accomDB[accom]['locked'] == False):
765+ res.append(accom)
766 return res
767
768 #Other significant system functions
769
770=== modified file 'accomplishments/daemon/dbusapi.py'
771--- accomplishments/daemon/dbusapi.py 2012-08-06 12:06:10 +0000
772+++ accomplishments/daemon/dbusapi.py 2012-08-08 22:24:17 +0000
773@@ -290,7 +290,7 @@
774
775 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
776 in_signature="s", out_signature="a{sv}")
777- def get_acc_data(self,accomID):
778+ def get_accom_data(self,accomID):
779 """
780 Returns a database of accomplishment information on the system.
781
782@@ -310,11 +310,11 @@
783 >>> obj.build_viewer_database()
784 { dbus.String(u'lang'): dbus.String(u'en', variant_level=1), dbus.String(u'needs-signing'): dbus.String(u'true', variant_level=1), dbus.String(u'date-completed'): dbus.String(u'2012-06-12 22:12', variant_level=1), dbus.String(u'set'): dbus.String(u'infrastructure', variant_level=1), dbus.String(u'locked'): dbus.Boolean(False, variant_level=1), dbus.String(u'help'): dbus.String(u'#launchpad on Freenode', variant_level=1), dbus.String(u'links'): dbus.String(u'http://www.launchpad.net', variant_level=1), dbus.String(u'title'): dbus.String(u'Registered on Launchpad', variant_level=1), dbus.String(u'script-path'): dbus.String(u'/home/jono/source/ubuntu-community-accomplishments/scripts/ubuntu-community/infrastructure/registered-on-launchpad.py', variant_level=1), dbus.String(u'base-path'): dbus.String(u'/home/jono/source/ubuntu-community-accomplishments/accomplishments/ubuntu-community', variant_level=1), dbus.String(u'completed'): dbus.Boolean(True, variant_level=1), dbus.String(u'author'): dbus.String(u'Jono Bacon <jono@ubuntu.com>', variant_level=1), dbus.String(u'collection'): dbus.String(u'ubuntu-community', variant_level=1), dbus.String(u'summary'): dbus.String(u'Launchpad is a website in which we do much of our work in Ubuntu. There we build packages, file and fix bugs, perform translations, manage code, and other activities.\\nYou will need to register an account with Launchpad to participate in much of the Ubuntu community. Fortunately, registering is simple, safe, and free.', variant_level=1), dbus.String(u'needs-information'): dbus.String(u'launchpad-email', variant_level=1), dbus.String(u'steps'): dbus.String(u'Load a web browser on your computer.\\nIn your web browser go to <tt>http://www.launchpad.net</tt>.\\nClick the <i>Register</i> link in the corner of the screen to register.', variant_level=1), dbus.String(u'icon'): dbus.String(u'default.png', variant_level=1), dbus.String(u'type'): dbus.String(u'accomplishment', variant_level=1), dbus.String(u'categories'): dbus.Array([dbus.String(u'Launchpad')], signature=dbus.Signature('s'), variant_level=1), dbus.String(u'description'): dbus.String(u'Registered a Launchpad account', variant_level=1) }
785 """
786- return self.api.get_acc_data(accomID)
787+ return self.api.get_accom_data(accomID)
788
789 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
790 in_signature="s", out_signature="b")
791- def get_acc_exists(self,accomID):
792+ def get_accom_exists(self,accomID):
793 """
794 Returns whether the specified accomplishment is recognized on the system.
795
796@@ -328,15 +328,15 @@
797 Returns:
798 * **(bool)** - returns `True` is the accomplishment exists, and `False` if not.
799 Example:
800- >>> obj.get_acc_exists("ubuntu-community/registered-on-launchpad")
801+ >>> obj.get_accom_exists("ubuntu-community/registered-on-launchpad")
802 True
803 """
804
805- return self.api.get_acc_exists(accomID)
806+ return self.api.get_accom_exists(accomID)
807
808 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
809 in_signature="s", out_signature="s")
810- def get_acc_title(self,accomID):
811+ def get_accom_title(self,accomID):
812 """
813 Returns the title name of the specified accomplishment.
814
815@@ -350,20 +350,20 @@
816 Returns:
817 * **(str)** - the title of the accomplishment.
818 Example:
819- >>> obj.get_acc_exists("ubuntu-community/registered-on-launchpad")
820+ >>> obj.get_accom_exists("ubuntu-community/registered-on-launchpad")
821 'Registered on Launchpad'
822 """
823
824- return self.api.get_acc_title(accomID)
825-
826- @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
827- in_signature="s", out_signature="s")
828- def get_acc_description(self,accomID):
829- return self.api.get_acc_description(accomID)
830-
831- @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
832- in_signature="s", out_signature="s")
833- def get_acc_collection(self,accomID):
834+ return self.api.get_accom_title(accomID)
835+
836+ @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
837+ in_signature="s", out_signature="s")
838+ def get_accom_description(self,accomID):
839+ return self.api.get_accom_description(accomID)
840+
841+ @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
842+ in_signature="s", out_signature="s")
843+ def get_accom_collection(self,accomID):
844 """
845 Returns the collection that a given accomplishment is part of.
846
847@@ -379,15 +379,15 @@
848 Returns:
849 * **(str)** - the collection name.
850 Example:
851- >>> obj.get_acc_collection("ubuntu-community/registered-on-launchpad")
852+ >>> obj.get_accom_collection("ubuntu-community/registered-on-launchpad")
853 ubuntu-community
854 """
855
856- return self.api.get_acc_collection(accomID)
857+ return self.api.get_accom_collection(accomID)
858
859 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
860 in_signature="s", out_signature="as")
861- def get_acc_categories(self,accomID):
862+ def get_accom_categories(self,accomID):
863 """
864 Returns a list of categories that the specified accomplishment is part of.
865
866@@ -404,14 +404,14 @@
867 Returns:
868 * **(list)** - the list of categories.
869 Example:
870- >>> obj.get_acc_categories("ubuntu-community/registered-on-launchpad")
871+ >>> obj.get_accom_categories("ubuntu-community/registered-on-launchpad")
872 ["Launchpad"]
873 """
874- return self.api.get_acc_categories(accomID)
875+ return self.api.get_accom_categories(accomID)
876
877 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
878 in_signature="s", out_signature="b")
879- def get_acc_needs_signing(self,accomID):
880+ def get_accom_needs_signing(self,accomID):
881 """
882 Returns whether the specified accomplishment needs to be signed (verified) or not.
883
884@@ -431,15 +431,15 @@
885 Returns:
886 * **(bool)** - `True` if the accomplishment needs signing, `False` if not.
887 Example:
888- >>> obj.get_acc_categories("ubuntu-community/registered-on-launchpad")
889+ >>> obj.get_accom_categories("ubuntu-community/registered-on-launchpad")
890 True
891 """
892
893- return self.api.get_acc_needs_signing(accomID)
894+ return self.api.get_accom_needs_signing(accomID)
895
896 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
897 in_signature="s", out_signature="as")
898- def get_acc_depends(self,accomID):
899+ def get_accom_depends(self,accomID):
900 """
901 Returns a list of accomplishments that the accomplishment you pass depends on.
902
903@@ -460,15 +460,15 @@
904 Returns:
905 * **(list)** - the list of dependencies for the accomplishment.
906 Example:
907- >>> obj.get_acc_depends("ubuntu-community/ubuntu-member")
908+ >>> obj.get_accom_depends("ubuntu-community/ubuntu-member")
909 ["ubuntu-community/registered-on-launchpad"]
910 """
911
912- return self.api.get_acc_depends(accomID)
913+ return self.api.get_accom_depends(accomID)
914
915 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
916 in_signature="s", out_signature="b")
917- def get_acc_is_unlocked(self,accomID):
918+ def get_accom_is_unlocked(self,accomID):
919 """
920 Returns whether the specified accomplishment is unlocked or not (whether it's dependencies have been satisfied or not).
921
922@@ -486,11 +486,11 @@
923 Returns:
924 * **(bool)** - `True` if the dependencies have been completed, `False` if not.
925 Example:
926- >>> obj.get_acc_is_unlocked("ubuntu-community/registered-on-launchpad")
927+ >>> obj.get_accom_is_unlocked("ubuntu-community/registered-on-launchpad")
928 True
929 """
930
931- return self.api.get_acc_is_unlocked(accomID)
932+ return self.api.get_accom_is_unlocked(accomID)
933
934 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
935 in_signature="s", out_signature="s")
936@@ -499,7 +499,7 @@
937
938 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
939 in_signature="s", out_signature="b")
940- def get_acc_is_completed(self,accomID):
941+ def get_accom_is_completed(self,accomID):
942 """
943 Returns whether the specified accomplishment is accomplished or not.
944
945@@ -513,11 +513,11 @@
946 Returns:
947 * **(bool)** - `True` if the accomplishment has been completed, `False` if not.
948 Example:
949- >>> obj.get_acc_is_completed("ubuntu-community/registered-on-launchpad")
950+ >>> obj.get_accom_is_completed("ubuntu-community/registered-on-launchpad")
951 True
952 """
953
954- return self.api.get_acc_is_completed(accomID)
955+ return self.api.get_accom_is_completed(accomID)
956
957 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
958 in_signature="", out_signature="b")
959@@ -538,7 +538,7 @@
960
961 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
962 in_signature="s", out_signature="s")
963- def get_acc_script_path(self,accomID):
964+ def get_accom_script_path(self,accomID):
965 """
966 Returns the corrosponsing script for the accomplishment.
967
968@@ -555,15 +555,15 @@
969 Returns:
970 * **(str)** - the full path to the script.
971 Example:
972- >>> obj.get_acc_script_path("ubuntu-community/registered-on-launchpad")
973+ >>> obj.get_accom_script_path("ubuntu-community/registered-on-launchpad")
974 /usr/share/accomplishments/scripts/ubuntu-community/infrastructure/registered-on-launchpad.py
975 """
976
977- return self.api.get_acc_script_path(accomID)
978+ return self.api.get_accom_script_path(accomID)
979
980 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
981 in_signature="s", out_signature="s")
982- def get_acc_icon(self,accomID):
983+ def get_accom_icon(self,accomID):
984 """
985 Returns the icon name for the specified accomplishment.
986
987@@ -573,21 +573,21 @@
988 `Accomplishment ID` as it's parameter.
989
990 Note: this function only passes the icon name and not the full path to the icon. If you need this you should use
991- `get_acc_icon_path()`.
992+ `get_accom_icon_path()`.
993
994 Args:
995 * **accomID** - (str) the `Accomplishment ID` for a given accomplishment (e.g. `ubuntu-community/registered-on-launchpad`).
996 Returns:
997 * **(str)** - the name of the icon.
998 Example:
999- >>> obj.get_acc_icon("ubuntu-community/registered-on-launchpad")
1000+ >>> obj.get_accom_icon("ubuntu-community/registered-on-launchpad")
1001 default.png
1002 """
1003- return self.api.get_acc_icon(accomID)
1004+ return self.api.get_accom_icon(accomID)
1005
1006 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
1007 in_signature="s", out_signature="s")
1008- def get_acc_icon_path(self,accomID):
1009+ def get_accom_icon_path(self,accomID):
1010 """
1011 Returns the icon name for the specified accomplishment.
1012
1013@@ -596,23 +596,23 @@
1014 accomplishment has an accomplishment ID of `ubuntu-community/registered-on-launchpad`). You pass this function this
1015 `Accomplishment ID` as it's parameter.
1016
1017- If you don't need the full path and just need the icon name, use `get_acc_icon()`.
1018+ If you don't need the full path and just need the icon name, use `get_accom_icon()`.
1019
1020 Args:
1021 * **accomID** - (str) the `Accomplishment ID` for a given accomplishment (e.g. `ubuntu-community/registered-on-launchpad`).
1022 Returns:
1023 * **(str)** - the full path to the icon.
1024 Example:
1025- >>> obj.get_acc_icon_path("ubuntu-community/registered-on-launchpad")
1026+ >>> obj.get_accom_icon_path("ubuntu-community/registered-on-launchpad")
1027 /home/jono/.cache/accomplishments/trophyimages/ubuntu-community/default.png
1028 """
1029- return self.api.get_acc_icon_path(accomID)
1030+ return self.api.get_accom_icon_path(accomID)
1031
1032 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
1033 in_signature="s", out_signature="v")
1034- def get_acc_needs_info(self,accomID):
1035+ def get_accom_needs_info(self,accomID):
1036 """DOCS NEEDED"""
1037- return self.api.get_acc_needs_info(self,accomID)
1038+ return self.api.get_accom_needs_info(self,accomID)
1039
1040 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
1041 in_signature="s", out_signature="a{sv}")
1042@@ -719,7 +719,7 @@
1043
1044 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
1045 in_signature="", out_signature="as")
1046- def list_accomplishments(self):
1047+ def list_accoms(self):
1048 """
1049 Returns a list of accomplishment IDs for the all available accomplishments. This includes all accomplishment IDs
1050 from all collections.
1051@@ -729,11 +729,11 @@
1052 Returns:
1053 * **(list)** - the list of accomplishment IDs.
1054 Example:
1055- >>> obj.list_accomplishments()
1056+ >>> obj.list_accoms()
1057 ["ubuntu-community/registered-on-launchpad", "ubuntu-community/ubuntu-member", . . .]
1058 """
1059
1060- return self.api.list_accomplishments()
1061+ return self.api.list_accoms()
1062
1063 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
1064 in_signature="", out_signature="as")
1065@@ -928,6 +928,6 @@
1066 pass
1067
1068 @dbus.service.signal(dbus_interface='org.ubuntu.accomplishments')
1069- def accomplishments_collections_reloaded(self):
1070+ def accoms_collections_reloaded(self):
1071 pass
1072
1073
1074=== removed directory 'tests/accomps'
1075=== removed file 'tests/accomps/first.accomplishment'
1076--- tests/accomps/first.accomplishment 2012-07-13 23:00:12 +0000
1077+++ tests/accomps/first.accomplishment 1970-01-01 00:00:00 +0000
1078@@ -1,7 +0,0 @@
1079-[accomplishment]
1080-title=My First Accomplishment
1081-icon=first.jpg
1082-description=An example accomplishment for the test suite
1083-needs-information=info,info2
1084-collection = testaccomp
1085-author = Tester <tester@tester>
1086
1087=== removed file 'tests/accomps/second.accomplishment'
1088--- tests/accomps/second.accomplishment 2012-07-19 19:47:52 +0000
1089+++ tests/accomps/second.accomplishment 1970-01-01 00:00:00 +0000
1090@@ -1,8 +0,0 @@
1091-[accomplishment]
1092-title=My Second Accomplishment
1093-icon=second
1094-description=An example accomplishment for the test suite, with dependency
1095-depends=testaccomp/first
1096-needs-signing=True
1097-collection=testaccomp
1098-author = Tester <tester@tester>
1099
1100=== removed file 'tests/accomps/third.accomplishment'
1101--- tests/accomps/third.accomplishment 2012-07-13 23:00:12 +0000
1102+++ tests/accomps/third.accomplishment 1970-01-01 00:00:00 +0000
1103@@ -1,10 +0,0 @@
1104-[accomplishment]
1105-title=My Third Accomplishment
1106-icon=third.jpg
1107-description=An example accomplishment for the test suite, no dependency
1108-needs-signing=False
1109-collection=testaccomp
1110-category=testing, unit test
1111-# comment should be ignored
1112-# comment
1113-author = Someone
1114
1115=== added directory 'tests/accoms'
1116=== added file 'tests/accoms/first.accomplishment'
1117--- tests/accoms/first.accomplishment 1970-01-01 00:00:00 +0000
1118+++ tests/accoms/first.accomplishment 2012-08-08 22:24:17 +0000
1119@@ -0,0 +1,7 @@
1120+[accomplishment]
1121+title=My First Accomplishment
1122+icon=first.jpg
1123+description=An example accomplishment for the test suite
1124+needs-information=info,info2
1125+collection = testaccom
1126+author = Tester <tester@tester>
1127
1128=== added file 'tests/accoms/second.accomplishment'
1129--- tests/accoms/second.accomplishment 1970-01-01 00:00:00 +0000
1130+++ tests/accoms/second.accomplishment 2012-08-08 22:24:17 +0000
1131@@ -0,0 +1,8 @@
1132+[accomplishment]
1133+title=My Second Accomplishment
1134+icon=second
1135+description=An example accomplishment for the test suite, with dependency
1136+depends=testaccom/first
1137+needs-signing=True
1138+collection=testaccom
1139+author = Tester <tester@tester>
1140
1141=== added file 'tests/accoms/third.accomplishment'
1142--- tests/accoms/third.accomplishment 1970-01-01 00:00:00 +0000
1143+++ tests/accoms/third.accomplishment 2012-08-08 22:24:17 +0000
1144@@ -0,0 +1,10 @@
1145+[accomplishment]
1146+title=My Third Accomplishment
1147+icon=third.jpg
1148+description=An example accomplishment for the test suite, no dependency
1149+needs-signing=False
1150+collection=testaccom
1151+category=testing, unit test
1152+# comment should be ignored
1153+# comment
1154+author = Someone
1155
1156=== modified file 'tests/tests.py'
1157--- tests/tests.py 2012-08-01 22:07:39 +0000
1158+++ tests/tests.py 2012-08-08 22:24:17 +0000
1159@@ -33,7 +33,7 @@
1160
1161 class TestDaemon(unittest.TestCase):
1162
1163- ACCOMP_SET = "testaccomp"
1164+ ACCOM_SET = "testaccom"
1165 LANG = "en"
1166
1167 def util_copy_extrainfo(self, extrainfo_dir, extrainfo_name):
1168@@ -42,30 +42,30 @@
1169 dest = os.path.join(extrainfo_dir, extrainfo_name)
1170 shutil.copyfile(src, dest)
1171
1172- def util_copy_accomp(self, accomp_dir, accomp_name):
1173+ def util_copy_accom(self, accom_dir, accom_name):
1174 testdir = os.path.dirname(__file__)
1175- src = os.path.join(testdir, "accomps",
1176- "%s.accomplishment" % accomp_name)
1177- dest = os.path.join(accomp_dir, "%s.accomplishment" % accomp_name)
1178+ src = os.path.join(testdir, "accoms",
1179+ "%s.accomplishment" % accom_name)
1180+ dest = os.path.join(accom_dir, "%s.accomplishment" % accom_name)
1181 shutil.copyfile(src, dest)
1182
1183 # This function is not really needed because when tearDown runs it
1184 # removes the entire tree, but when debugging tests it's useful to comment
1185 # out the rmtree in tearDown, so then this is critical to make the tests
1186 # work.
1187- def util_remove_all_accomps(self, accomp_dir):
1188- for f in os.listdir(accomp_dir):
1189- os.remove(os.path.join(self.accomp_dir, f))
1190+ def util_remove_all_accoms(self, accom_dir):
1191+ for f in os.listdir(accom_dir):
1192+ os.remove(os.path.join(self.accom_dir, f))
1193
1194- def util_write_about_file(self, accomp_dir):
1195- fp = open(os.path.join(accomp_dir, "ABOUT"), "w")
1196+ def util_write_about_file(self, accom_dir):
1197+ fp = open(os.path.join(accom_dir, "ABOUT"), "w")
1198 fp.write("""[general]
1199 name = Test Collection
1200 langdefault=%s""" % self.LANG)
1201 fp.close()
1202
1203- def util_write_config_file(self, accomp_dir):
1204- fp = open(os.path.join(accomp_dir, ".accomplishments"), "w")
1205+ def util_write_config_file(self, accom_dir):
1206+ fp = open(os.path.join(accom_dir, ".accomplishments"), "w")
1207 fp.write("""[config]
1208 has_u1 = true
1209 has_verif = 1
1210@@ -75,8 +75,8 @@
1211 extrainfo_seen = 1""" % (self.td, self.td))
1212 fp.close()
1213
1214- def util_write_file(self, accomp_dir, name, content):
1215- fp = open(os.path.join(accomp_dir, name), "w")
1216+ def util_write_file(self, accom_dir, name, content):
1217+ fp = open(os.path.join(accom_dir, name), "w")
1218 fp.write(content)
1219 fp.close()
1220
1221@@ -84,10 +84,10 @@
1222 self.td = tempfile.mkdtemp()
1223
1224 # /tmp/foo/accomplishments
1225- self.accomps_root = os.path.join(self.td, "accomplishments",
1226+ self.accoms_root = os.path.join(self.td, "accomplishments",
1227 "accomplishments")
1228- if not os.path.exists(self.accomps_root):
1229- os.makedirs(self.accomps_root)
1230+ if not os.path.exists(self.accoms_root):
1231+ os.makedirs(self.accoms_root)
1232
1233 # /tmp/foo/accomplishments/accomplishments/.config
1234 self.config_dir = os.path.join(self.td, "accomplishments", ".config",
1235@@ -95,18 +95,18 @@
1236 if not os.path.exists(self.config_dir):
1237 os.makedirs(self.config_dir)
1238
1239- # /tmp/foo/accomplishments/accomplishments/testaccomp
1240- self.accomp_root = os.path.join(self.accomps_root, self.ACCOMP_SET)
1241- if not os.path.exists(self.accomp_root):
1242- os.makedirs(self.accomp_root)
1243-
1244- # /tmp/foo/accomplishments/accomplishments/testaccomp/en
1245- self.accomp_dir = os.path.join(self.accomp_root, self.LANG)
1246- if not os.path.exists(self.accomp_dir):
1247- os.makedirs(self.accomp_dir)
1248-
1249- # /tmp/foo/accomplishments/accomplishments/testaccomp/extrainformation
1250- self.extrainfo_dir = os.path.join(self.accomp_root, "extrainformation")
1251+ # /tmp/foo/accomplishments/accomplishments/testaccom
1252+ self.accom_root = os.path.join(self.accoms_root, self.ACCOM_SET)
1253+ if not os.path.exists(self.accom_root):
1254+ os.makedirs(self.accom_root)
1255+
1256+ # /tmp/foo/accomplishments/accomplishments/testaccom/en
1257+ self.accom_dir = os.path.join(self.accom_root, self.LANG)
1258+ if not os.path.exists(self.accom_dir):
1259+ os.makedirs(self.accom_dir)
1260+
1261+ # /tmp/foo/accomplishments/accomplishments/testaccom/extrainformation
1262+ self.extrainfo_dir = os.path.join(self.accom_root, "extrainformation")
1263 if not os.path.exists(self.extrainfo_dir):
1264 os.makedirs(self.extrainfo_dir)
1265
1266@@ -115,8 +115,8 @@
1267 if not os.path.exists(self.scripts_root):
1268 os.makedirs(self.scripts_root)
1269
1270- # /tmp/foo/accomplishments/accomplishments/scripts/testaccomp
1271- self.script_root = os.path.join(self.scripts_root, self.ACCOMP_SET)
1272+ # /tmp/foo/accomplishments/accomplishments/scripts/testaccom
1273+ self.script_root = os.path.join(self.scripts_root, self.ACCOM_SET)
1274 if not os.path.exists(self.script_root):
1275 os.makedirs(self.script_root)
1276
1277@@ -126,7 +126,7 @@
1278 if not os.path.exists(self.trophy_dir):
1279 os.makedirs(self.trophy_dir)
1280
1281- self.util_write_about_file(self.accomp_root)
1282+ self.util_write_about_file(self.accom_root)
1283
1284 self.util_write_config_file(self.config_dir)
1285
1286@@ -141,7 +141,7 @@
1287 # it will pop off the test, but in a pbuilder or build system
1288 # there will be no daemon, so we can just ensure that this
1289 # doesn't crash
1290- self.util_copy_accomp(self.accomp_dir, "third")
1291+ self.util_copy_accom(self.accom_dir, "third")
1292 a = api.Accomplishments(None, None, True)
1293
1294 # pass in None
1295@@ -151,45 +151,45 @@
1296 self.assertEqual(a.run_scripts(122), None)
1297
1298 # pass in a specific item
1299- self.assertEqual(a.run_scripts(["%s/third" % self.ACCOMP_SET]), None)
1300+ self.assertEqual(a.run_scripts(["%s/third" % self.ACCOM_SET]), None)
1301
1302 def test_run_script(self):
1303 # due to LP1030208, if the daemon is running (like on a dev box)
1304 # it will pop off the test, but in a pbuilder or build system
1305 # there will be no daemon, so we can just ensure that this
1306 # doesn't crash
1307- self.util_copy_accomp(self.accomp_dir, "third")
1308+ self.util_copy_accom(self.accom_dir, "third")
1309 a = api.Accomplishments(None, None, True)
1310- self.assertEqual(a.run_script("%s/wrong" % self.ACCOMP_SET), None)
1311+ self.assertEqual(a.run_script("%s/wrong" % self.ACCOM_SET), None)
1312 self.assertEqual(a.run_script("wrong"), None)
1313
1314- self.assertEqual(a.run_script("%s/third" % self.ACCOMP_SET), None)
1315+ self.assertEqual(a.run_script("%s/third" % self.ACCOM_SET), None)
1316
1317- def test_get_acc_date_completed(self):
1318- self.util_remove_all_accomps(self.accomp_dir)
1319- self.util_copy_accomp(self.accomp_dir, "first")
1320- self.util_copy_accomp(self.accomp_dir, "second")
1321- self.util_copy_accomp(self.accomp_dir, "third")
1322+ def test_get_accom_date_completed(self):
1323+ self.util_remove_all_accoms(self.accom_dir)
1324+ self.util_copy_accom(self.accom_dir, "first")
1325+ self.util_copy_accom(self.accom_dir, "second")
1326+ self.util_copy_accom(self.accom_dir, "third")
1327 self.util_copy_extrainfo(self.extrainfo_dir, "info")
1328 self.util_copy_extrainfo(self.extrainfo_dir, "info2")
1329 a = api.Accomplishments(None, None, True)
1330 a.write_extra_information_file("info", "whatever")
1331 a.write_extra_information_file("info2", "whatever2")
1332
1333- self.assertTrue(a.accomplish("%s/first" % self.ACCOMP_SET))
1334- self.assertTrue(a.accomplish("%s/second" % self.ACCOMP_SET))
1335- self.assertTrue(a.accomplish("%s/third" % self.ACCOMP_SET))
1336+ self.assertTrue(a.accomplish("%s/first" % self.ACCOM_SET))
1337+ self.assertTrue(a.accomplish("%s/second" % self.ACCOM_SET))
1338+ self.assertTrue(a.accomplish("%s/third" % self.ACCOM_SET))
1339
1340 trophies = a.list_trophies()
1341 # since "second" requires signing, it shouldn't be listed
1342 self.assertEqual(len(trophies), 2)
1343
1344- d1 = a.get_acc_date_completed("%s/first" % self.ACCOMP_SET)
1345+ d1 = a.get_accom_date_completed("%s/first" % self.ACCOM_SET)
1346 self.assertTrue(isinstance(d1, basestring))
1347 dt1 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M")
1348 self.assertTrue(dt1 is not None)
1349
1350- d3 = a.get_acc_date_completed("%s/third" % self.ACCOMP_SET)
1351+ d3 = a.get_accom_date_completed("%s/third" % self.ACCOM_SET)
1352 self.assertTrue(isinstance(d3, basestring))
1353 dt3 = datetime.datetime.strptime(d3, "%Y-%m-%d %H:%M")
1354 self.assertTrue(dt3 is not None)
1355@@ -202,206 +202,206 @@
1356 # list_unlocked_not_completed
1357 # get_trophy_data
1358 def test_accomplish(self):
1359- self.util_remove_all_accomps(self.accomp_dir)
1360- self.util_copy_accomp(self.accomp_dir, "first")
1361- self.util_copy_accomp(self.accomp_dir, "second")
1362- self.util_copy_accomp(self.accomp_dir, "third")
1363+ self.util_remove_all_accoms(self.accom_dir)
1364+ self.util_copy_accom(self.accom_dir, "first")
1365+ self.util_copy_accom(self.accom_dir, "second")
1366+ self.util_copy_accom(self.accom_dir, "third")
1367 a = api.Accomplishments(None, None, True)
1368
1369 # before accomplishing
1370 opps = a.list_opportunitues()
1371 self.assertEqual(len(opps), 3)
1372 for accom in opps:
1373- self.assertTrue(accom in ["%s/first" % self.ACCOMP_SET,
1374- "%s/second" % self.ACCOMP_SET, "%s/third" % self.ACCOMP_SET])
1375+ self.assertTrue(accom in ["%s/first" % self.ACCOM_SET,
1376+ "%s/second" % self.ACCOM_SET, "%s/third" % self.ACCOM_SET])
1377
1378 unlocked = a.list_unlocked()
1379 self.assertEqual(len(unlocked), 2)
1380 for accom in unlocked:
1381- self.assertTrue(accom in ["%s/first" % self.ACCOMP_SET,
1382- "%s/third" % self.ACCOMP_SET])
1383+ self.assertTrue(accom in ["%s/first" % self.ACCOM_SET,
1384+ "%s/third" % self.ACCOM_SET])
1385
1386 unlocked_nc = a.list_unlocked_not_completed()
1387 self.assertEqual(len(unlocked_nc), 2)
1388 for accom in unlocked_nc:
1389- self.assertTrue(accom in ["%s/first" % self.ACCOMP_SET,
1390- "%s/third" % self.ACCOMP_SET])
1391+ self.assertTrue(accom in ["%s/first" % self.ACCOM_SET,
1392+ "%s/third" % self.ACCOM_SET])
1393
1394 trophies = a.list_trophies()
1395 self.assertEqual(len(trophies), 0)
1396
1397- self.assertTrue(a.get_trophy_data("%s/first" % self.ACCOMP_SET) is None)
1398- self.assertTrue(a.get_trophy_data("%s/second" % self.ACCOMP_SET)
1399+ self.assertTrue(a.get_trophy_data("%s/first" % self.ACCOM_SET) is None)
1400+ self.assertTrue(a.get_trophy_data("%s/second" % self.ACCOM_SET)
1401 is None)
1402- self.assertTrue(a.get_trophy_data("%s/third" % self.ACCOMP_SET) is None)
1403+ self.assertTrue(a.get_trophy_data("%s/third" % self.ACCOM_SET) is None)
1404
1405 # now let's accomplish something, it should fail without extra info
1406- self.assertRaises(KeyError, a.accomplish, "%s/first" % self.ACCOMP_SET)
1407+ self.assertRaises(KeyError, a.accomplish, "%s/first" % self.ACCOM_SET)
1408
1409 # this time it will work
1410 self.util_copy_extrainfo(self.extrainfo_dir, "info")
1411 self.util_copy_extrainfo(self.extrainfo_dir, "info2")
1412 a.reload_accom_database()
1413- self.assertTrue(a.accomplish("%s/first" % self.ACCOMP_SET))
1414+ self.assertTrue(a.accomplish("%s/first" % self.ACCOM_SET))
1415
1416 opps = a.list_opportunitues()
1417 self.assertEqual(len(opps), 2)
1418 for accom in opps:
1419- self.assertTrue(accom in ["%s/second" % self.ACCOMP_SET,
1420- "%s/third" % self.ACCOMP_SET])
1421+ self.assertTrue(accom in ["%s/second" % self.ACCOM_SET,
1422+ "%s/third" % self.ACCOM_SET])
1423
1424 unlocked = a.list_unlocked()
1425 self.assertEqual(len(unlocked), 3)
1426 for accom in unlocked:
1427- self.assertTrue(accom in ["%s/first" % self.ACCOMP_SET,
1428- "%s/second" % self.ACCOMP_SET,
1429- "%s/third" % self.ACCOMP_SET])
1430+ self.assertTrue(accom in ["%s/first" % self.ACCOM_SET,
1431+ "%s/second" % self.ACCOM_SET,
1432+ "%s/third" % self.ACCOM_SET])
1433
1434 unlocked_nc = a.list_unlocked_not_completed()
1435 self.assertEqual(len(unlocked_nc), 2)
1436 for accom in unlocked_nc:
1437- self.assertTrue(accom in ["%s/second" % self.ACCOMP_SET,
1438- "%s/third" % self.ACCOMP_SET])
1439+ self.assertTrue(accom in ["%s/second" % self.ACCOM_SET,
1440+ "%s/third" % self.ACCOM_SET])
1441
1442 trophies = a.list_trophies()
1443 self.assertEqual(len(trophies), 1)
1444 for accom in trophies:
1445- self.assertTrue(accom in ["%s/first" % self.ACCOMP_SET])
1446+ self.assertTrue(accom in ["%s/first" % self.ACCOM_SET])
1447
1448- td = a.get_trophy_data("%s/first" % self.ACCOMP_SET)
1449+ td = a.get_trophy_data("%s/first" % self.ACCOM_SET)
1450 self.assertTrue(isinstance(td, dict))
1451
1452 self.assertTrue(td['date-accomplished'] is not None)
1453 self.assertTrue(td['version'] is not None)
1454 self.assertTrue(td['__name__'] == "trophy")
1455- self.assertTrue(td['id'] == "%s/first" % self.ACCOMP_SET)
1456+ self.assertTrue(td['id'] == "%s/first" % self.ACCOM_SET)
1457 self.assertTrue(td['needs-information'] is not None)
1458
1459 def test_list_depending_on(self):
1460- self.util_remove_all_accomps(self.accomp_dir)
1461- self.util_copy_accomp(self.accomp_dir, "first")
1462- self.util_copy_accomp(self.accomp_dir, "second")
1463- self.util_copy_accomp(self.accomp_dir, "third")
1464+ self.util_remove_all_accoms(self.accom_dir)
1465+ self.util_copy_accom(self.accom_dir, "first")
1466+ self.util_copy_accom(self.accom_dir, "second")
1467+ self.util_copy_accom(self.accom_dir, "third")
1468 a = api.Accomplishments(None, None, True)
1469
1470 self.assertEquals(len(a.list_depending_on("%s/first" %
1471- self.ACCOMP_SET)), 1)
1472+ self.ACCOM_SET)), 1)
1473 self.assertEquals(len(a.list_depending_on("%s/second" %
1474- self.ACCOMP_SET)), 0)
1475+ self.ACCOM_SET)), 0)
1476 self.assertEquals(len(a.list_depending_on("%s/third" %
1477- self.ACCOMP_SET)), 0)
1478+ self.ACCOM_SET)), 0)
1479
1480- # tests all the get_acc_* functions, except for:
1481- # get_acc_icon
1482- # get_acc_icon_path
1483+ # tests all the get_accom_* functions, except for:
1484+ # get_accom_icon
1485+ # get_accom_icon_path
1486 # get_date_completed
1487- def test_get_acc_all_funcs(self):
1488- self.util_remove_all_accomps(self.accomp_dir)
1489- self.util_copy_accomp(self.accomp_dir, "first")
1490- self.util_copy_accomp(self.accomp_dir, "second")
1491- self.util_copy_accomp(self.accomp_dir, "third")
1492+ def test_get_accom_all_funcs(self):
1493+ self.util_remove_all_accoms(self.accom_dir)
1494+ self.util_copy_accom(self.accom_dir, "first")
1495+ self.util_copy_accom(self.accom_dir, "second")
1496+ self.util_copy_accom(self.accom_dir, "third")
1497 a = api.Accomplishments(None, None, True)
1498
1499- # get_acc_data
1500- data = a.get_acc_data("%s/first" % self.ACCOMP_SET)
1501+ # get_accom_data
1502+ data = a.get_accom_data("%s/first" % self.ACCOM_SET)
1503 self.assertTrue(isinstance(data, dict))
1504 self.assertEquals(data['title'], "My First Accomplishment")
1505- data = a.get_acc_data("%s/third" % self.ACCOMP_SET)
1506+ data = a.get_accom_data("%s/third" % self.ACCOM_SET)
1507 self.assertTrue(isinstance(data, dict))
1508 self.assertEquals(data['title'], "My Third Accomplishment")
1509
1510- # get_acc_exists
1511- self.assertTrue(a.get_acc_exists("%s/first" % self.ACCOMP_SET))
1512- self.assertTrue(a.get_acc_exists("%s/second" % self.ACCOMP_SET))
1513- self.assertTrue(a.get_acc_exists("%s/third" % self.ACCOMP_SET))
1514- self.assertFalse(a.get_acc_exists("%s/something" % self.ACCOMP_SET))
1515- self.assertFalse(a.get_acc_exists("wrong/first"))
1516+ # get_accom_exists
1517+ self.assertTrue(a.get_accom_exists("%s/first" % self.ACCOM_SET))
1518+ self.assertTrue(a.get_accom_exists("%s/second" % self.ACCOM_SET))
1519+ self.assertTrue(a.get_accom_exists("%s/third" % self.ACCOM_SET))
1520+ self.assertFalse(a.get_accom_exists("%s/something" % self.ACCOM_SET))
1521+ self.assertFalse(a.get_accom_exists("wrong/first"))
1522
1523- # get_acc_title
1524- self.assertEquals(a.get_acc_title("%s/first" % self.ACCOMP_SET),
1525+ # get_accom_title
1526+ self.assertEquals(a.get_accom_title("%s/first" % self.ACCOM_SET),
1527 "My First Accomplishment")
1528- self.assertEquals(a.get_acc_title("%s/second" % self.ACCOMP_SET),
1529+ self.assertEquals(a.get_accom_title("%s/second" % self.ACCOM_SET),
1530 "My Second Accomplishment")
1531- self.assertEquals(a.get_acc_title("%s/third" % self.ACCOMP_SET),
1532+ self.assertEquals(a.get_accom_title("%s/third" % self.ACCOM_SET),
1533 "My Third Accomplishment")
1534- self.assertRaises(KeyError, a.get_acc_title, "wrong")
1535-
1536- # get_acc_description
1537- self.assertTrue("example" in a.get_acc_description("%s/first" %
1538- self.ACCOMP_SET))
1539- self.assertTrue("example" in a.get_acc_description("%s/second" %
1540- self.ACCOMP_SET))
1541- self.assertTrue("example" in a.get_acc_description("%s/third" %
1542- self.ACCOMP_SET))
1543- self.assertRaises(KeyError, a.get_acc_description, "wrong")
1544-
1545- # get_acc_needs_signing
1546- self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))
1547- self.assertTrue(a.get_acc_needs_signing("%s/second" % self.ACCOMP_SET))
1548- self.assertFalse(a.get_acc_needs_signing("%s/first" % self.ACCOMP_SET))
1549- self.assertRaises(KeyError, a.get_acc_needs_signing, "wrong")
1550-
1551- # get_acc_depends
1552- self.assertTrue(a.get_acc_depends("%s/first" % self.ACCOMP_SET) == [])
1553- deps = a.get_acc_depends("%s/second" % self.ACCOMP_SET)
1554+ self.assertRaises(KeyError, a.get_accom_title, "wrong")
1555+
1556+ # get_accom_description
1557+ self.assertTrue("example" in a.get_accom_description("%s/first" %
1558+ self.ACCOM_SET))
1559+ self.assertTrue("example" in a.get_accom_description("%s/second" %
1560+ self.ACCOM_SET))
1561+ self.assertTrue("example" in a.get_accom_description("%s/third" %
1562+ self.ACCOM_SET))
1563+ self.assertRaises(KeyError, a.get_accom_description, "wrong")
1564+
1565+ # get_accom_needs_signing
1566+ self.assertFalse(a.get_accom_needs_signing("%s/first" % self.ACCOM_SET))
1567+ self.assertTrue(a.get_accom_needs_signing("%s/second" % self.ACCOM_SET))
1568+ self.assertFalse(a.get_accom_needs_signing("%s/first" % self.ACCOM_SET))
1569+ self.assertRaises(KeyError, a.get_accom_needs_signing, "wrong")
1570+
1571+ # get_accom_depends
1572+ self.assertTrue(a.get_accom_depends("%s/first" % self.ACCOM_SET) == [])
1573+ deps = a.get_accom_depends("%s/second" % self.ACCOM_SET)
1574 self.assertEquals(len(deps), 1)
1575- self.assertTrue(deps[0] == "%s/first" % self.ACCOMP_SET)
1576- self.assertTrue(a.get_acc_depends("%s/third" % self.ACCOMP_SET) == [])
1577- self.assertRaises(KeyError, a.get_acc_depends, "wrong")
1578-
1579- # get_acc_is_unlocked
1580- self.assertTrue(a.get_acc_is_unlocked("%s/first" % self.ACCOMP_SET))
1581- self.assertFalse(a.get_acc_is_unlocked("%s/second" % self.ACCOMP_SET))
1582- self.assertTrue(a.get_acc_is_unlocked("%s/third" % self.ACCOMP_SET))
1583- self.assertRaises(KeyError, a.get_acc_is_unlocked, "wrong")
1584-
1585- # get_acc_is_completed
1586+ self.assertTrue(deps[0] == "%s/first" % self.ACCOM_SET)
1587+ self.assertTrue(a.get_accom_depends("%s/third" % self.ACCOM_SET) == [])
1588+ self.assertRaises(KeyError, a.get_accom_depends, "wrong")
1589+
1590+ # get_accom_is_unlocked
1591+ self.assertTrue(a.get_accom_is_unlocked("%s/first" % self.ACCOM_SET))
1592+ self.assertFalse(a.get_accom_is_unlocked("%s/second" % self.ACCOM_SET))
1593+ self.assertTrue(a.get_accom_is_unlocked("%s/third" % self.ACCOM_SET))
1594+ self.assertRaises(KeyError, a.get_accom_is_unlocked, "wrong")
1595+
1596+ # get_accom_is_completed
1597 # XXX - when we get the accomplish() code working, make some of these
1598 # true
1599- self.assertFalse(a.get_acc_is_completed("%s/first" % self.ACCOMP_SET))
1600- self.assertFalse(a.get_acc_is_completed("%s/second" % self.ACCOMP_SET))
1601- self.assertFalse(a.get_acc_is_completed("%s/third" % self.ACCOMP_SET))
1602- self.assertRaises(KeyError, a.get_acc_is_completed, "wrong")
1603+ self.assertFalse(a.get_accom_is_completed("%s/first" % self.ACCOM_SET))
1604+ self.assertFalse(a.get_accom_is_completed("%s/second" % self.ACCOM_SET))
1605+ self.assertFalse(a.get_accom_is_completed("%s/third" % self.ACCOM_SET))
1606+ self.assertRaises(KeyError, a.get_accom_is_completed, "wrong")
1607
1608- # get_acc_script_path
1609- self.assertEqual(a.get_acc_script_path("%s/first" % self.ACCOMP_SET),
1610+ # get_accom_script_path
1611+ self.assertEqual(a.get_accom_script_path("%s/first" % self.ACCOM_SET),
1612 None)
1613- self.assertEqual(a.get_acc_script_path("%s/second" % self.ACCOMP_SET),
1614+ self.assertEqual(a.get_accom_script_path("%s/second" % self.ACCOM_SET),
1615 None)
1616 self.util_write_file(self.script_root, "third.py", "print 'hello'")
1617- sp = a.get_acc_script_path("%s/third" % self.ACCOMP_SET)
1618+ sp = a.get_accom_script_path("%s/third" % self.ACCOM_SET)
1619 self.assertTrue(sp.endswith("third.py"))
1620- self.assertRaises(KeyError, a.get_acc_script_path, "wrong")
1621+ self.assertRaises(KeyError, a.get_accom_script_path, "wrong")
1622
1623- # get_acc_needs_info
1624- info = a.get_acc_needs_info("%s/first" % self.ACCOMP_SET)
1625+ # get_accom_needs_info
1626+ info = a.get_accom_needs_info("%s/first" % self.ACCOM_SET)
1627 self.assertEqual(len(info),2)
1628 for i in info:
1629 self.assertTrue(i in ["info", "info2"])
1630- self.assertEqual(a.get_acc_needs_info("%s/second" % self.ACCOMP_SET),
1631- [])
1632- self.assertEqual(a.get_acc_needs_info("%s/third" % self.ACCOMP_SET),
1633- [])
1634- self.assertRaises(KeyError, a.get_acc_needs_info, "wrong")
1635-
1636- # get_acc_collection
1637- self.assertEqual(a.get_acc_collection("%s/first" % self.ACCOMP_SET),
1638- self.ACCOMP_SET)
1639- self.assertEqual(a.get_acc_collection("%s/second" % self.ACCOMP_SET),
1640- self.ACCOMP_SET)
1641- self.assertEqual(a.get_acc_collection("%s/third" % self.ACCOMP_SET),
1642- self.ACCOMP_SET)
1643- self.assertRaises(KeyError, a.get_acc_collection, "wrong")
1644-
1645- # get_acc_categories
1646- self.assertEqual(a.get_acc_categories("%s/first" % self.ACCOMP_SET), [])
1647- self.assertEqual(a.get_acc_categories("%s/second" % self.ACCOMP_SET),
1648- [])
1649- categories = a.get_acc_categories("%s/third" % self.ACCOMP_SET)
1650+ self.assertEqual(a.get_accom_needs_info("%s/second" % self.ACCOM_SET),
1651+ [])
1652+ self.assertEqual(a.get_accom_needs_info("%s/third" % self.ACCOM_SET),
1653+ [])
1654+ self.assertRaises(KeyError, a.get_accom_needs_info, "wrong")
1655+
1656+ # get_accom_collection
1657+ self.assertEqual(a.get_accom_collection("%s/first" % self.ACCOM_SET),
1658+ self.ACCOM_SET)
1659+ self.assertEqual(a.get_accom_collection("%s/second" % self.ACCOM_SET),
1660+ self.ACCOM_SET)
1661+ self.assertEqual(a.get_accom_collection("%s/third" % self.ACCOM_SET),
1662+ self.ACCOM_SET)
1663+ self.assertRaises(KeyError, a.get_accom_collection, "wrong")
1664+
1665+ # get_accom_categories
1666+ self.assertEqual(a.get_accom_categories("%s/first" % self.ACCOM_SET), [])
1667+ self.assertEqual(a.get_accom_categories("%s/second" % self.ACCOM_SET),
1668+ [])
1669+ categories = a.get_accom_categories("%s/third" % self.ACCOM_SET)
1670 self.assertEqual(len(info),2)
1671 for category in categories:
1672 self.assertTrue(category in ["testing", "unit test"])
1673- self.assertRaises(KeyError, a.get_acc_categories, "wrong")
1674+ self.assertRaises(KeyError, a.get_accom_categories, "wrong")
1675
1676 def test_get_block_ubuntuone_notification_bubbles(self):
1677 a = api.Accomplishments(None, None, True)
1678@@ -442,26 +442,26 @@
1679 version = a.get_API_version()
1680 self.assertTrue(isinstance(version, basestring))
1681
1682- # also tests get_acc_icon_path
1683- def test_get_acc_icon(self):
1684- self.util_copy_accomp(self.accomp_dir, "first")
1685- self.util_copy_accomp(self.accomp_dir, "second")
1686+ # also tests get_accom_icon_path
1687+ def test_get_accom_icon(self):
1688+ self.util_copy_accom(self.accom_dir, "first")
1689+ self.util_copy_accom(self.accom_dir, "second")
1690 a = api.Accomplishments(None, None, True)
1691- self.assertEquals(a.get_acc_icon('%s/first' % self.ACCOMP_SET),
1692+ self.assertEquals(a.get_accom_icon('%s/first' % self.ACCOM_SET),
1693 'first.jpg')
1694- icon_path = a.get_acc_icon_path('%s/first' % self.ACCOMP_SET)
1695+ icon_path = a.get_accom_icon_path('%s/first' % self.ACCOM_SET)
1696 self.assertTrue(icon_path.endswith("first-opportunity.jpg"))
1697
1698 # LP 1024052 - make sure this works without a . in the filename
1699- self.assertEquals(a.get_acc_icon('%s/second' % self.ACCOMP_SET),
1700+ self.assertEquals(a.get_accom_icon('%s/second' % self.ACCOM_SET),
1701 'second')
1702- icon_path = a.get_acc_icon_path('%s/second' % self.ACCOMP_SET)
1703+ icon_path = a.get_accom_icon_path('%s/second' % self.ACCOM_SET)
1704 self.assertTrue(icon_path.endswith("second-locked"))
1705
1706 def test_build_viewer_database(self):
1707- self.util_remove_all_accomps(self.accomp_dir)
1708- self.util_copy_accomp(self.accomp_dir, "first")
1709- self.util_copy_accomp(self.accomp_dir, "second")
1710+ self.util_remove_all_accoms(self.accom_dir)
1711+ self.util_copy_accom(self.accom_dir, "first")
1712+ self.util_copy_accom(self.accom_dir, "second")
1713 a = api.Accomplishments(None, None, True)
1714 viewer_db = a.build_viewer_database()
1715 self.assertEquals(len(viewer_db), 2)
1716@@ -472,76 +472,76 @@
1717 self.assertEquals(viewer_db[1]['collection-human'],
1718 "Test Collection")
1719
1720- self.assertEquals(viewer_db[0]['collection'], "testaccomp")
1721- self.assertEquals(viewer_db[1]['collection'], "testaccomp")
1722+ self.assertEquals(viewer_db[0]['collection'], "testaccom")
1723+ self.assertEquals(viewer_db[1]['collection'], "testaccom")
1724
1725 # test a few random fields
1726 for item in viewer_db:
1727 if item['title'] == "My First Accomplishment":
1728 self.assertTrue("opportunity" in item['iconpath'])
1729- self.assertTrue(item['id'] == "%s/first" % self.ACCOMP_SET)
1730+ self.assertTrue(item['id'] == "%s/first" % self.ACCOM_SET)
1731 elif item['title'] == "My Second Accomplishment":
1732 self.assertTrue("locked" in item['iconpath'])
1733- self.assertTrue(item['id'] == "%s/second" % self.ACCOMP_SET)
1734+ self.assertTrue(item['id'] == "%s/second" % self.ACCOM_SET)
1735 # this shouldn't happen
1736 else:
1737 self.assertTrue(False)
1738
1739 # also tests reloading the database
1740 def test_list_all(self):
1741- self.util_remove_all_accomps(self.accomp_dir)
1742- self.util_copy_accomp(self.accomp_dir, "first")
1743- self.util_copy_accomp(self.accomp_dir, "second")
1744- self.util_copy_accomp(self.accomp_dir, "third")
1745+ self.util_remove_all_accoms(self.accom_dir)
1746+ self.util_copy_accom(self.accom_dir, "first")
1747+ self.util_copy_accom(self.accom_dir, "second")
1748+ self.util_copy_accom(self.accom_dir, "third")
1749
1750 a = api.Accomplishments(None, None, True)
1751- self.assertEqual(len(a.list_accomplishments()), 3)
1752+ self.assertEqual(len(a.list_accoms()), 3)
1753
1754 # add a new accomp
1755- self.util_write_file(self.accomp_dir, "fourth.accomplishment",
1756+ self.util_write_file(self.accom_dir, "fourth.accomplishment",
1757 "[accomplishment]\n"\
1758 "title=My Fourth Accomplishment\n"\
1759 "description=An example accomplishment for the test suite\n")
1760- self.assertEqual(len(a.list_accomplishments()), 3)
1761+ self.assertEqual(len(a.list_accoms()), 3)
1762 a.reload_accom_database()
1763- self.assertEqual(len(a.list_accomplishments()), 4)
1764+ self.assertEqual(len(a.list_accoms()), 4)
1765
1766 # remove the new accomp
1767- os.remove(os.path.join(self.accomp_dir, "fourth.accomplishment"))
1768+ os.remove(os.path.join(self.accom_dir, "fourth.accomplishment"))
1769 a.reload_accom_database()
1770- self.assertEqual(len(a.list_accomplishments()), 3)
1771+ self.assertEqual(len(a.list_accoms()), 3)
1772
1773- self.util_remove_all_accomps(self.accomp_dir)
1774+ self.util_remove_all_accoms(self.accom_dir)
1775
1776 def test_missing_about_file(self):
1777- os.remove(os.path.join(self.accomp_root, "ABOUT"))
1778+ os.remove(os.path.join(self.accom_root, "ABOUT"))
1779 self.assertRaises(LookupError, api.Accomplishments, None, None, True)
1780
1781 # put the file back
1782- self.util_write_about_file(self.accomp_root)
1783+ self.util_write_about_file(self.accom_root)
1784
1785 def test_bad_accomplishment_list(self):
1786 # this test ensures that a bad accompishment doesn't crash the
1787 # daemon or get into the list
1788
1789 # ensure a clean start
1790- self.util_remove_all_accomps(self.accomp_dir)
1791- self.util_copy_accomp(self.accomp_dir, "first")
1792+ self.util_remove_all_accoms(self.accom_dir)
1793+ self.util_copy_accom(self.accom_dir, "first")
1794 a = api.Accomplishments(None, None, True)
1795- self.assertEqual(len(a.list_accomplishments()), 1)
1796- self.util_write_file(self.accomp_dir, "bad.accomplishment",
1797+ self.assertEqual(len(a.list_accoms()), 1)
1798+ self.util_write_file(self.accom_dir, "bad.accomplishment",
1799 "[accomplishment]\n"\
1800 "descriptionbad desc\n")
1801 a.reload_accom_database()
1802- self.assertEqual(len(a.list_accomplishments()), 1)
1803+ self.assertEqual(len(a.list_accoms()), 1)
1804
1805- self.util_write_file(self.accomp_dir, "bad.accomplishment",
1806+ self.util_write_file(self.accom_dir, "bad.accomplishment",
1807 "descriptionbad desc\n")
1808 a.reload_accom_database()
1809- self.assertEqual(len(a.list_accomplishments()), 1)
1810+ self.assertEqual(len(a.list_accoms()), 1)
1811
1812 # cleanup
1813- self.util_remove_all_accomps(self.accomp_dir)
1814+ self.util_remove_all_accoms(self.accom_dir)
1815
1816 # also tests get_config_value()
1817 def test_write_config_file_item(self):
1818@@ -563,16 +563,16 @@
1819
1820 # this tests the get_collection_* functions and list_collections():
1821 def test_get_collection_all_funcs(self):
1822- self.util_remove_all_accomps(self.accomp_dir)
1823- self.util_copy_accomp(self.accomp_dir, "first")
1824- self.util_copy_accomp(self.accomp_dir, "second")
1825- self.util_copy_accomp(self.accomp_dir, "third")
1826+ self.util_remove_all_accoms(self.accom_dir)
1827+ self.util_copy_accom(self.accom_dir, "first")
1828+ self.util_copy_accom(self.accom_dir, "second")
1829+ self.util_copy_accom(self.accom_dir, "third")
1830 a = api.Accomplishments(None, None, True)
1831
1832 # list_collections
1833 collections = a.list_collections()
1834 self.assertEqual(len(collections), 1)
1835- self.assertEqual(collections[0], self.ACCOMP_SET)
1836+ self.assertEqual(collections[0], self.ACCOM_SET)
1837
1838 # get_collection_name
1839 self.assertEqual(a.get_collection_name(collections[0]),
1840@@ -610,18 +610,18 @@
1841
1842 # get trophy path
1843 def test_get_trophy_path(self):
1844- self.util_remove_all_accomps(self.accomp_dir)
1845- self.util_copy_accomp(self.accomp_dir, "first")
1846- self.util_copy_accomp(self.accomp_dir, "second")
1847- self.util_copy_accomp(self.accomp_dir, "third")
1848+ self.util_remove_all_accoms(self.accom_dir)
1849+ self.util_copy_accom(self.accom_dir, "first")
1850+ self.util_copy_accom(self.accom_dir, "second")
1851+ self.util_copy_accom(self.accom_dir, "third")
1852 a = api.Accomplishments(None, None, True)
1853
1854 self.assertTrue(a.get_trophy_path("%s/first" %
1855- self.ACCOMP_SET).endswith("first.trophy"))
1856+ self.ACCOM_SET).endswith("first.trophy"))
1857 self.assertTrue(a.get_trophy_path("%s/second" %
1858- self.ACCOMP_SET).endswith("second.trophy"))
1859+ self.ACCOM_SET).endswith("second.trophy"))
1860 self.assertTrue(a.get_trophy_path("%s/third" %
1861- self.ACCOMP_SET).endswith("third.trophy"))
1862+ self.ACCOM_SET).endswith("third.trophy"))
1863
1864 def test_write_extra_information_file(self):
1865 a = api.Accomplishments(None, None, True)
1866@@ -648,11 +648,11 @@
1867 a = api.Accomplishments(None, None, True)
1868 self.util_copy_extrainfo(self.extrainfo_dir, "info")
1869 self.util_copy_extrainfo(self.extrainfo_dir, "info2")
1870- self.util_copy_accomp(self.accomp_dir, "first")
1871+ self.util_copy_accom(self.accom_dir, "first")
1872
1873 # get extra information
1874 # these won't show up until we reload
1875- self.assertRaises(KeyError, a.get_extra_information, self.ACCOMP_SET,
1876+ self.assertRaises(KeyError, a.get_extra_information, self.ACCOM_SET,
1877 "info")
1878
1879 # should return None when the collection doesn't exist
1880@@ -663,15 +663,15 @@
1881
1882 # will throw a KeyError if collection is right, but extrainfo is
1883 # wrong
1884- self.assertRaises(KeyError, a.get_extra_information, self.ACCOMP_SET,
1885+ self.assertRaises(KeyError, a.get_extra_information, self.ACCOM_SET,
1886 "wrong")
1887
1888- ei = a.get_extra_information(self.ACCOMP_SET, "info")
1889+ ei = a.get_extra_information(self.ACCOM_SET, "info")
1890 self.assertTrue(isinstance(ei, list))
1891 self.assertTrue(len(ei) == 1)
1892 self.assertEqual(ei[0]['info'], '')
1893 self.assertEqual(ei[0]['label'], 'Some info')
1894- ei = a.get_extra_information(self.ACCOMP_SET, "info2")
1895+ ei = a.get_extra_information(self.ACCOM_SET, "info2")
1896 self.assertTrue(isinstance(ei, list))
1897 self.assertTrue(len(ei) == 1)
1898 self.assertEqual(ei[0]['info2'], '')
1899@@ -679,10 +679,10 @@
1900
1901 # write some data out and reload the DB
1902 a.write_extra_information_file("info", "whatever")
1903- ei = a.get_extra_information(self.ACCOMP_SET, "info")
1904+ ei = a.get_extra_information(self.ACCOM_SET, "info")
1905 self.assertEqual(ei[0]['info'], 'whatever')
1906 a.write_extra_information_file("info2", "whatever2")
1907- ei = a.get_extra_information(self.ACCOMP_SET, "info2")
1908+ ei = a.get_extra_information(self.ACCOM_SET, "info2")
1909 self.assertEqual(ei[0]['info2'], 'whatever2')
1910
1911 # get all extra information
1912@@ -691,7 +691,7 @@
1913 self.assertTrue(len(all_extra_info) == 2)
1914 for ei in all_extra_info:
1915 self.assertTrue(isinstance(ei, dict))
1916- self.assertEquals(ei['collection'], self.ACCOMP_SET)
1917+ self.assertEquals(ei['collection'], self.ACCOM_SET)
1918 self.assertTrue(ei['description'] is not None)
1919 self.assertTrue(ei['example'] is not None)
1920 self.assertTrue(ei['needs-information'] is not None)

Subscribers

People subscribed via source and target branches