Merge lp:~seb128/software-center/dont_use_gwibber into lp:software-center

Proposed by Sebastien Bacher
Status: Merged
Approved by: dobey
Approved revision: 3325
Merged at revision: 3331
Proposed branch: lp:~seb128/software-center/dont_use_gwibber
Merge into: lp:software-center
Diff against target: 677 lines (+1/-580)
8 files modified
README (+0/-1)
data/ui/gtk3/dialogs.ui (+0/-68)
data/ui/gtk3/submit_review.ui (+0/-30)
softwarecenter/config.py (+0/-14)
softwarecenter/gwibber_helper.py (+0/-147)
softwarecenter/ui/gtk3/review_gui_helper.py (+0/-248)
tests/test_gwibber.py (+0/-71)
tests/test_reinstall_purchased.py (+1/-1)
To merge this branch: bzr merge lp:~seb128/software-center/dont_use_gwibber
Reviewer Review Type Date Requested Status
dobey Approve
Review via email: mp+272941@code.launchpad.net

Commit message

clean out gwibber reviews code, that service is deprecated

Description of the change

clean out gwibber reviews code, that service is deprecated

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2012-05-22 12:13:02 +0000
3+++ README 2015-09-30 15:59:57 +0000
4@@ -47,7 +47,6 @@
5 SOFTWARE_CENTER_DEBUG_WEBKIT - enable webkit debuging
6 SOFTWARE_CENTER_IPSUM_REVIEWS - generate random reviews
7 SOFTWARE_CENTER_FAKE_REVIEW_API - use a fake server for all review network operations
8-SOFTWARE_CENTER_GWIBBER_MOCK_USERS=2 - use mock gwibber service
9 SOFTWARE_CENTER_AGENT_INCLUDE_QA - show not yet QA apps available from the agent
10 SOFTWARE_CENTER_NET_DISCONNECTED - make software-center's netstatus module believe network manager is in a disconnected state
11 SOFTWARE_CENTER_WEBLIVE_HOST - overwrite default weblive server
12
13=== modified file 'data/ui/gtk3/dialogs.ui'
14--- data/ui/gtk3/dialogs.ui 2012-11-21 15:17:13 +0000
15+++ data/ui/gtk3/dialogs.ui 2015-09-30 15:59:57 +0000
16@@ -423,74 +423,6 @@
17 <action-widget response="-3">button_dependency_do</action-widget>
18 </action-widgets>
19 </object>
20- <object class="GtkMessageDialog" id="dialog_gwibber_error">
21- <property name="can_focus">False</property>
22- <property name="border_width">5</property>
23- <property name="modal">True</property>
24- <property name="window_position">center-on-parent</property>
25- <property name="destroy_with_parent">True</property>
26- <property name="type_hint">normal</property>
27- <property name="skip_taskbar_hint">True</property>
28- <property name="message_type">error</property>
29- <property name="text" translatable="yes">There was a problem posting this review to %s</property>
30- <property name="secondary_text" translatable="yes">%s had not responded within 30 seconds.</property>
31- <child internal-child="vbox">
32- <object class="GtkBox" id="dialog-vbox3">
33- <property name="visible">True</property>
34- <property name="can_focus">False</property>
35- <property name="orientation">vertical</property>
36- <property name="spacing">2</property>
37- <child internal-child="action_area">
38- <object class="GtkButtonBox" id="dialog-action_area3">
39- <property name="visible">True</property>
40- <property name="can_focus">False</property>
41- <property name="layout_style">end</property>
42- <child>
43- <object class="GtkButton" id="gwib_err_cancel_button">
44- <property name="label">gtk-cancel</property>
45- <property name="use_action_appearance">False</property>
46- <property name="visible">True</property>
47- <property name="can_focus">True</property>
48- <property name="receives_default">True</property>
49- <property name="use_action_appearance">False</property>
50- <property name="use_stock">True</property>
51- </object>
52- <packing>
53- <property name="expand">False</property>
54- <property name="fill">False</property>
55- <property name="position">0</property>
56- </packing>
57- </child>
58- <child>
59- <object class="GtkButton" id="gwib_err_retry_button">
60- <property name="label" translatable="yes">Retry</property>
61- <property name="use_action_appearance">False</property>
62- <property name="visible">True</property>
63- <property name="can_focus">True</property>
64- <property name="receives_default">True</property>
65- <property name="use_action_appearance">False</property>
66- </object>
67- <packing>
68- <property name="expand">False</property>
69- <property name="fill">False</property>
70- <property name="position">1</property>
71- </packing>
72- </child>
73- </object>
74- <packing>
75- <property name="expand">False</property>
76- <property name="fill">True</property>
77- <property name="pack_type">end</property>
78- <property name="position">0</property>
79- </packing>
80- </child>
81- </object>
82- </child>
83- <action-widgets>
84- <action-widget response="-2">gwib_err_cancel_button</action-widget>
85- <action-widget response="-3">gwib_err_retry_button</action-widget>
86- </action-widgets>
87- </object>
88 <object class="GtkDialog" id="dialog_install_error">
89 <property name="can_focus">False</property>
90 <property name="border_width">5</property>
91
92=== modified file 'data/ui/gtk3/submit_review.ui'
93--- data/ui/gtk3/submit_review.ui 2011-10-02 02:45:50 +0000
94+++ data/ui/gtk3/submit_review.ui 2015-09-30 15:59:57 +0000
95@@ -362,36 +362,6 @@
96 <property name="position">6</property>
97 </packing>
98 </child>
99- <child>
100- <object class="GtkHBox" id="gwibber_hbox">
101- <property name="visible">True</property>
102- <property name="can_focus">False</property>
103- <property name="spacing">6</property>
104- <child>
105- <object class="GtkCheckButton" id="gwibber_checkbutton">
106- <property name="visible">True</property>
107- <property name="can_focus">True</property>
108- <property name="receives_default">False</property>
109- <property name="use_action_appearance">False</property>
110- <property name="xalign">0</property>
111- <property name="draw_indicator">True</property>
112- </object>
113- <packing>
114- <property name="expand">False</property>
115- <property name="fill">False</property>
116- <property name="position">0</property>
117- </packing>
118- </child>
119- <child>
120- <placeholder/>
121- </child>
122- </object>
123- <packing>
124- <property name="expand">False</property>
125- <property name="fill">False</property>
126- <property name="position">7</property>
127- </packing>
128- </child>
129 </object>
130 <packing>
131 <property name="position">1</property>
132
133=== modified file 'softwarecenter/config.py'
134--- softwarecenter/config.py 2013-07-09 14:33:47 +0000
135+++ softwarecenter/config.py 2015-09-30 15:59:57 +0000
136@@ -141,20 +141,6 @@
137 "username", value, section="reviews"),
138 None,
139 "The sso username")
140- reviews_post_via_gwibber = property(
141- lambda self: self._generic_getbool(
142- "gwibber_send", section="reviews", default=False),
143- lambda self, value: self._generic_setbool(
144- "gwibber_send", value, section="reviews"),
145- None,
146- "Also post reviews via gwibber")
147- reviews_gwibber_account_id = property(
148- lambda self: self._generic_get(
149- "account_id", section="reviews", default=""),
150- lambda self, value: self._generic_setbool(
151- "account_id", value, section="reviews"),
152- None,
153- "The account id to use when sending via gwibber")
154
155 # app_window_size is special as its a tuple
156 def _app_window_size_get(self):
157
158=== removed file 'softwarecenter/gwibber_helper.py'
159--- softwarecenter/gwibber_helper.py 2012-11-28 16:58:59 +0000
160+++ softwarecenter/gwibber_helper.py 1970-01-01 00:00:00 +0000
161@@ -1,147 +0,0 @@
162-# Copyright (C) 2010 Matthew McGowan
163-#
164-# Authors:
165-# Matthew McGowan
166-# Michael Vogt
167-#
168-# This program is free software; you can redistribute it and/or modify it under
169-# the terms of the GNU General Public License as published by the Free Software
170-# Foundation; version 3.
171-#
172-# This program is distributed in the hope that it will be useful, but WITHOUT
173-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
174-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
175-# details.
176-#
177-# You should have received a copy of the GNU General Public License along with
178-# this program; if not, write to the Free Software Foundation, Inc.,
179-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
180-
181-import dbus
182-import logging
183-from xdg import BaseDirectory as xdg
184-import os.path
185-import json
186-import sys
187-from random import random
188-
189-
190-class GwibberHelper(object):
191- """ A helper class for gwibber. ideally we would just use
192- from gi.repository import Gwibber
193- accounts = Gwibbers.Accounts()
194- accounts.list()
195- ...
196- instead of the dbus iface, but the gi stuff fails
197- to export "Accounts.list()" (and possible more) currently
198- """
199-
200- def accounts(self):
201- """ returns accounts that are send_enabled """
202- accounts = []
203- try:
204- bus = dbus.SessionBus()
205- proxy_obj = bus.get_object("com.Gwibber.Accounts",
206- "/com/gwibber/Accounts")
207- accounts_iface = dbus.Interface(proxy_obj, "com.Gwibber.Accounts")
208- for account in json.loads(accounts_iface.List()):
209- if 'send_enabled' in account and account["send_enabled"]:
210- accounts.append(account)
211- return accounts
212- except:
213- logging.exception("GwibberHelper.accounts() failed")
214- return accounts
215-
216- def send_message(self, message, account_id=None):
217- """ send message to all accounts with send_enabled """
218- bus = dbus.SessionBus()
219- proxy_obj = bus.get_object("com.Gwibber.Service",
220- "/com/gwibber/Service")
221- service_iface = dbus.Interface(proxy_obj, "com.Gwibber.Service")
222- if account_id:
223- json_str = json.dumps({'message': message,
224- 'accounts': [account_id],
225- })
226- service_iface.Send(json_str)
227- else:
228- service_iface.SendMessage(message)
229- return True
230-
231- @staticmethod
232- def has_accounts_in_sqlite():
233- """ return if there are accounts for gwibber in sqlite """
234- # don't use dbus, triggers a gwibber start each time we call this
235- dbpath = "%s/gwibber/gwibber.sqlite" % xdg.xdg_config_home
236- if not os.path.exists(dbpath):
237- return False
238- try:
239- import sqlite3
240- with sqlite3.connect(dbpath) as db:
241- results = db.execute("SELECT data FROM accounts")
242- if len(results.fetchall()) > 0:
243- return True
244- return False
245- except:
246- logging.exception("GwibberHelper.has_accounts_in_sqlite() failed")
247- return False
248-
249-
250-class GwibberHelperMock(object):
251-
252- fake_gwibber_accounts_one = [
253- {u'username': u'randomuser',
254- u'user_id': u'2323434224',
255- u'service': u'twitter',
256- u'secret_token': u':some-token',
257- u'color': u'#729FCF',
258- u'receive_enabled': True,
259- u'access_token': u'some_access_token',
260- u'send_enabled': True,
261- u'id': u'twitter-id-random-15af8bddb6',
262- }]
263- fake_gwibber_accounts_multiple = [
264- {u'username': u'random1 with a very long name',
265- u'user_id': u'2342342313',
266- u'service': u'twitter',
267- u'secret_token': u':some-token',
268- u'color': u'#729FCF',
269- u'receive_enabled': True,
270- u'access_token': u'some_access_token',
271- u'send_enabled': True,
272- u'id': u'twitter-id-rnadomuser-radfsdf'},
273- {u'username': u'mpt',
274- u'user_id': u'23safdsaf5',
275- u'service': u'twitter',
276- u'secret_token': u':some_otken',
277- u'color': u'#729FCF',
278- u'receive_enabled': True,
279- u'access_token': u'some_access_token',
280- u'send_enabled': True,
281- u'id': u'twitter-id-mpt-afsdfsa'}]
282-
283- def accounts(self):
284- import copy
285- num = os.environ["SOFTWARE_CENTER_GWIBBER_MOCK_USERS"]
286- if int(num) == 0:
287- return []
288- elif int(num) == 1:
289- return copy.copy(self.fake_gwibber_accounts_one)
290- else:
291- return copy.copy(self.fake_gwibber_accounts_multiple)
292-
293- def send_message(self, message, account_id="all"):
294- sys.stderr.write("sending '%s' to '%s'\n" % (message, account_id))
295- # used for testing purposes, to emulate a gwibber failure for ~1 out
296- # of every 5 attempts
297- r = random()
298- if (r < 0.2 and
299- not "SOFTWARE_CENTER_GWIBBER_MOCK_NO_FAIL" in os.environ):
300- return False
301- return True
302-
303- def has_accounts_in_sqlite():
304- return True
305-
306-
307-GWIBBER_SERVICE_AVAILABLE = (GwibberHelper.has_accounts_in_sqlite() and
308- os.path.exists("/usr/bin/gwibber-poster"))
309
310=== modified file 'softwarecenter/ui/gtk3/review_gui_helper.py'
311--- softwarecenter/ui/gtk3/review_gui_helper.py 2012-12-14 16:44:25 +0000
312+++ softwarecenter/ui/gtk3/review_gui_helper.py 2015-09-30 15:59:57 +0000
313@@ -54,7 +54,6 @@
314 from softwarecenter.backend.login import get_login_backend
315 from softwarecenter.backend.reviews import Review
316 from softwarecenter.db.database import Application
317-from softwarecenter.gwibber_helper import GwibberHelper, GwibberHelperMock
318 from softwarecenter.i18n import get_language
319 from softwarecenter.ui.gtk3.SimpleGtkbuilderApp import SimpleGtkbuilderApp
320 from softwarecenter.ui.gtk3.dialogs import SimpleGtkbuilderDialog
321@@ -657,23 +656,6 @@
322 self.star_rating.connect('changed', self._on_mandatory_fields_changed)
323 self.review_buffer.connect('changed', self._on_text_entry_changed)
324
325- # gwibber stuff
326- self.gwibber_combo = Gtk.ComboBoxText.new()
327- #cells = self.gwibber_combo.get_cells()
328- #cells[0].set_property("ellipsize", pango.ELLIPSIZE_END)
329- self.gwibber_hbox.pack_start(self.gwibber_combo, True, True, 0)
330- if "SOFTWARE_CENTER_GWIBBER_MOCK_USERS" in os.environ:
331- self.gwibber_helper = GwibberHelperMock()
332- else:
333- self.gwibber_helper = GwibberHelper()
334-
335- # get a dict with a saved gwibber_send (boolean) and gwibber
336- # account_id for persistent state
337- self.gwibber_prefs = self._get_gwibber_prefs()
338-
339- # gwibber stuff
340- self._setup_gwibber_gui()
341-
342 #now setup rest of app based on whether submit or modify
343 if self.action == "submit":
344 self._init_submit()
345@@ -911,81 +893,6 @@
346 self.iconname, self.version, display_name)
347 self.textview_review.grab_focus()
348
349- def _setup_gwibber_gui(self):
350- self.gwibber_accounts = self.gwibber_helper.accounts()
351- list_length = len(self.gwibber_accounts)
352- if list_length == 0:
353- self._on_no_gwibber_accounts()
354- elif list_length == 1:
355- self._on_one_gwibber_account()
356- else:
357- self._on_multiple_gwibber_accounts()
358-
359- def _get_gwibber_prefs(self):
360- send = self.config.reviews_post_via_gwibber
361- account_id = self.config.reviews_gwibber_account_id
362-
363- return {
364- "gwibber_send": send,
365- "account_id": account_id
366- }
367-
368- def _on_no_gwibber_accounts(self):
369- self.gwibber_hbox.hide()
370- self.gwibber_checkbutton.set_active(False)
371-
372- def _on_one_gwibber_account(self):
373- account = self.gwibber_accounts[0]
374- self.gwibber_hbox.show()
375- self.gwibber_combo.hide()
376- from softwarecenter.utils import utf8
377- acct_text = utf8(_("Also post this review to %s (@%s)")) % (
378- utf8(account['service'].capitalize()), utf8(account['username']))
379- self.gwibber_checkbutton.set_label(acct_text)
380- # simplifies on_transmit_successful later
381- self.gwibber_combo.append_text(acct_text)
382- self.gwibber_combo.set_active(0)
383- # auto select submit via gwibber checkbutton if saved prefs say True
384- self.gwibber_checkbutton.set_active(self.gwibber_prefs['gwibber_send'])
385-
386- def _on_multiple_gwibber_accounts(self):
387- self.gwibber_hbox.show()
388- self.gwibber_combo.show()
389-
390- # setup accounts combo
391- self.gwibber_checkbutton.set_label(_("Also post this review to: "))
392- for account in self.gwibber_accounts:
393- acct_text = "%s (@%s)" % (
394- account['service'].capitalize(), account['username'])
395- self.gwibber_combo.append_text(acct_text)
396-
397- # add "all" to both combo and accounts (the later is only pseudo)
398- self.gwibber_combo.append_text(_("All my Gwibber services"))
399- self.gwibber_accounts.append({"id": "pseudo-sc-all"})
400-
401- # reapply preferences
402- self.gwibber_checkbutton.set_active(self.gwibber_prefs['gwibber_send'])
403- gwibber_active_account = 0
404- for account in self.gwibber_accounts:
405- if account['id'] == self.gwibber_prefs['account_id']:
406- gwibber_active_account = self.gwibber_accounts.index(account)
407- self.gwibber_combo.set_active(gwibber_active_account)
408-
409- def _post_to_one_gwibber_account(self, msg, account):
410- """ little helper to facilitate posting message to twitter account
411- passed in
412- """
413- status_text = _("Posting to %s") % utf8(
414- account['service'].capitalize())
415- self._change_status("progress", status_text)
416- return self.gwibber_helper.send_message(msg, account['id'])
417-
418- def on_transmit_success(self, api, trans):
419- """on successful submission of a review, try to send to gwibber as
420- well
421- """
422- self._run_gwibber_submits(api, trans)
423-
424 def _on_key_press_event(self, widget, event):
425 if event.keyval == Gdk.KEY_Escape:
426 self._confirm_cancellation()
427@@ -1018,161 +925,6 @@
428 self.submit_window.destroy()
429 self.quit()
430
431- def _get_send_accounts(self, sel_index):
432- """return the account referenced by the passed in index, or all
433- accounts if the index of the combo points to the pseudo-sc-all
434- string
435- """
436- if self.gwibber_accounts[sel_index]["id"] == "pseudo-sc-all":
437- return self.gwibber_accounts
438- else:
439- return [self.gwibber_accounts[sel_index]]
440-
441- def _submit_to_gwibber(self, msg, send_accounts):
442- """for each send_account passed in, try to submit to gwibber
443- then return a list of accounts that failed to submit (empty list
444- if all succeeded)
445- """
446- #list of gwibber accounts that failed to submit, used later to allow
447- # selective re-send if user desires
448- failed_accounts = []
449- for account in send_accounts:
450- if account["id"] != "pseudo-sc-all":
451- if not self._post_to_one_gwibber_account(msg, account):
452- failed_accounts.append(account)
453- return failed_accounts
454-
455- def _run_gwibber_submits(self, api, trans):
456- """check if gwibber send should occur and send via gwibber if so"""
457- gwibber_success = True
458- using_gwibber = self.gwibber_checkbutton.get_active()
459- if using_gwibber:
460- i = self.gwibber_combo.get_active()
461- msg = (self._gwibber_message())
462- send_accounts = self._get_send_accounts(i)
463- self._save_gwibber_state(True, self.gwibber_accounts[i]['id'])
464- #tries to send to gwibber, and gets back any failed accounts
465- failed_accounts = self._submit_to_gwibber(msg, send_accounts)
466- if len(failed_accounts) > 0:
467- gwibber_success = False
468- #FIXME: send an error string to this method instead of empty
469- # string
470- self._on_gwibber_fail(api, trans, failed_accounts, "")
471- else:
472- # prevent _save_gwibber_state from overwriting the account id
473- # in config if the checkbutton was not selected
474- self._save_gwibber_state(False, None)
475- # run parent handler on gwibber success, otherwise this will be dealt
476- # with in _on_gwibber_fail
477- if gwibber_success:
478- self._success_status()
479- BaseApp.on_transmit_success(self, api, trans)
480-
481- def _gwibber_retry_some(self, api, trans, accounts):
482- """ perform selective retrying of gwibber posting, using only
483- accounts passed in
484- """
485- gwibber_success = True
486- failed_accounts = []
487- msg = (self._gwibber_message())
488-
489- for account in accounts:
490- if not self._post_to_one_gwibber_account(msg, account):
491- failed_accounts.append(account)
492- gwibber_success = False
493-
494- if not gwibber_success:
495- #FIXME: send an error string to this method instead of empty string
496- self._on_gwibber_fail(api, trans, failed_accounts, "")
497- else:
498- self._success_status()
499- BaseApp.on_transmit_success(self, api, trans)
500-
501- def _success_status(self):
502- """Updates status area to show success for 2 seconds then allows
503- window to proceed
504- """
505- self._change_status("success", _(self.SUCCESS_MESSAGE))
506- while Gtk.events_pending():
507- Gtk.main_iteration()
508- time.sleep(2)
509-
510- def _on_gwibber_fail(self, api, trans, failed_accounts, error):
511- self._change_status("fail", _("Problems posting to Gwibber"))
512- #list to hold service strings in the format: "Service (@username)"
513- failed_services = []
514- for account in failed_accounts:
515- failed_services.append("%s (@%s)" % (
516- account['service'].capitalize(), account['username']))
517-
518- glade_dialog = SimpleGtkbuilderDialog(self.datadir,
519- domain="software-center")
520- dialog = glade_dialog.dialog_gwibber_error
521- dialog.set_transient_for(self.submit_window)
522- # build the failure string
523- # TRANSLATORS: the part in %s can either be a single entry
524- # like "facebook" or a string like
525- # "factbook and twister"
526- error_str = gettext.ngettext(
527- "There was a problem posting this review to %s.",
528- "There was a problem posting this review to %s.",
529- len(failed_services))
530- error_str = make_string_from_list(error_str, failed_services)
531- dialog.set_markup(error_str)
532- dialog.format_secondary_text(error)
533- result = dialog.run()
534- dialog.destroy()
535- if result == Gtk.RESPONSE_ACCEPT:
536- self._gwibber_retry_some(api, trans, failed_accounts)
537- else:
538- BaseApp.on_transmit_success(self, api, trans)
539-
540- def _save_gwibber_state(self, gwibber_send, account_id):
541- self.config.reviews_post_via_gwibber = gwibber_send
542- if account_id:
543- self.config.reviews_gwibber_account_id = account_id
544- self.config.write()
545-
546- def _gwibber_message(self, max_len=140):
547- """ build a gwibber message of max_len"""
548- def _gwibber_message_string_from_data(appname, rating, summary, link):
549- """ helper so that we do not duplicate the "reviewed..." string """
550- return _("reviewed %(appname)s in Ubuntu: %(rating)s "
551- "%(summary)s %(link)s") % {'appname': appname,
552- 'rating': rating,
553- 'summary': summary,
554- 'link': link}
555-
556- rating = self.star_rating.get_rating()
557- rating_string = ''
558-
559- #fill star ratings for string
560- for i in range(1, 6):
561- if i <= rating:
562- rating_string = rating_string + u"\u2605"
563- else:
564- rating_string = rating_string + u"\u2606"
565-
566- review_summary_text = self.review_summary_entry.get_text()
567- # FIXME: currently the link is not useful (at all) for most
568- # people not running ubuntu
569- #app_link = "http://apt.ubuntu.com/p/%s" % self.app.pkgname
570- app_link = ""
571- gwib_msg = _gwibber_message_string_from_data(
572- self.app.name, rating_string, review_summary_text, app_link)
573-
574- #check char count and ellipsize review summary if larger than 140 chars
575- if len(gwib_msg) > max_len:
576- chars_to_reduce = len(gwib_msg) - (max_len - 1)
577- new_char_count = len(review_summary_text) - chars_to_reduce
578- review_summary_text = (review_summary_text[:new_char_count] +
579- u"\u2026")
580- gwib_msg = _gwibber_message_string_from_data(
581- self.app.name, rating_string, review_summary_text, app_link)
582-
583- return gwib_msg
584-
585-
586 class ReportReviewApp(BaseApp):
587 """ report a given application or package """
588
589
590=== removed file 'tests/test_gwibber.py'
591--- tests/test_gwibber.py 2012-05-30 21:52:08 +0000
592+++ tests/test_gwibber.py 1970-01-01 00:00:00 +0000
593@@ -1,71 +0,0 @@
594-import os
595-import unittest
596-
597-Gwibber = None
598-try:
599- from gi.repository import Gwibber
600-except ImportError:
601- pass
602-
603-from tests.utils import (
604- setup_test_env,
605-)
606-setup_test_env()
607-from softwarecenter.gwibber_helper import GwibberHelper, GwibberHelperMock
608-
609-NOT_DEFINED = object()
610-
611-
612-@unittest.skipIf(Gwibber is None,
613- "Please install the gwibber gir bindings to run this test case.")
614-class TestGwibber(unittest.TestCase):
615- """Tests the "where is it in the menu" code."""
616-
617- patch_vars = (("SOFTWARE_CENTER_GWIBBER_MOCK_USERS", "2"),
618- ("SOFTWARE_CENTER_GWIBBER_MOCK_NO_FAIL", "1"))
619-
620- def setUp(self):
621- for env_var, value in self.patch_vars:
622- real = os.environ.get(env_var, NOT_DEFINED)
623- if real is NOT_DEFINED:
624- self.addCleanup(os.environ.pop, env_var)
625- else:
626- self.addCleanup(os.environ.__setitem__, env_var, real)
627- os.environ[env_var] = value
628-
629- def test_gwibber_helper_mock(self):
630- gh = GwibberHelperMock()
631- accounts = gh.accounts()
632- self.assertEqual(len(accounts), 2)
633- #print accounts
634- # we can not test the real gwibber here, otherwise it will
635- # post our test data to real services
636- self.assertEqual(gh.send_message ("test"), True)
637-
638- def test_gwibber_helper(self):
639- # readonly test as there maybe be real accounts
640- gh = GwibberHelper()
641- have_accounts = gh.has_accounts_in_sqlite()
642- self.assertTrue(isinstance(have_accounts, bool))
643- accounts = gh.accounts()
644- self.assertTrue(isinstance(accounts, list))
645-
646- @unittest.skip('not_working_because_gi_does_not_provide_list_test_gwibber')
647- def test_gwibber_send_message(self):
648- service = Gwibber.Service()
649- self.addCleanup(service.quit)
650- # get account data
651- accounts = Gwibber.Accounts()
652- # print dir(accounts)
653- self.assertTrue(len(accounts.list()) > 0)
654- # check single account for send enabled, only do if "True"
655- #print accounts.send_enabled(accounts.list[0])
656- # first check gwibber available
657- service = Gwibber.Service()
658- # print dir(service)
659- service.service_available(False)
660- service.send_message("test")
661-
662-
663-if __name__ == "__main__":
664- unittest.main()
665
666=== modified file 'tests/test_reinstall_purchased.py'
667--- tests/test_reinstall_purchased.py 2012-12-17 09:01:00 +0000
668+++ tests/test_reinstall_purchased.py 2015-09-30 15:59:57 +0000
669@@ -104,7 +104,7 @@
670 "package_name": "photobomb",
671 "video_embedded_html_urls": [ ],
672 "demo": null,
673- "keywords": "photos, pictures, editing, gwibber, twitter, facebook, drawing",
674+ "keywords": "photos, pictures, editing, twitter, facebook, drawing",
675 "video_urls": [ ],
676 "screenshot_url": "http://software-center.ubuntu.com/site_media/screenshots/2011/08/Screenshot-45.png",
677 "id": 83,