Yann Leboulanger pushed to branch gajim_0.16 at gajim / gajim
Commits: 0a28e0f0 by Yann Leboulanger at 2017-08-09T21:54:48+02:00 ability to run tests without gui
- - - - -
6 changed files:
- .gitlab-ci.yml - Makefile.am - src/common/connection_handlers_events.py - src/gtkgui_helpers.py - src/notify.py - test/runtests.py
Changes:
===================================== .gitlab-ci.yml ===================================== --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,8 @@ stages: run-test: stage: test script: - - make test + - ./autogen.sh + - make test_nogui
run-build: stage: build
===================================== Makefile.am ===================================== --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,10 @@ test: python test/runtests.py .PHONY: test
+test_nogui: + python test/runtests.py -n +.PHONY: test_nogui + doc: epydoc --config=doc/epydoc.conf .PHONY: doc
===================================== src/common/connection_handlers_events.py ===================================== --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -41,8 +41,6 @@ from nbxmpp.protocol import NS_CHATSTATES from common.jingle_transport import JingleTransportSocks5 from common.file_props import FilesProp
-import gtkgui_helpers - if gajim.HAVE_PYOPENSSL: import OpenSSL.crypto
@@ -2484,8 +2482,6 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.popup_title = _('New Message from %(nickname)s') % \ {'nickname': nick}
- self.popup_image = gtkgui_helpers.get_icon_path(self.popup_image, 48) - if not gajim.config.get('notify_on_new_message') or \ not self.first_unread: self.do_popup = False @@ -2541,6 +2537,29 @@ class NotificationEvent(nec.NetworkIncomingEvent):
self.do_popup = False
+ def get_path_to_generic_or_avatar(generic, jid=None, suffix=None): + """ + Choose between avatar image and default image + + Returns full path to the avatar image if it exists, otherwise returns + full path to the image. generic must be with extension and suffix + without + """ + if jid: + # we want an avatar + puny_jid = helpers.sanitize_filename(jid) + path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix + path_to_local_file = path_to_file + '_local' + for extension in ('.png', '.jpeg'): + path_to_local_file_full = path_to_local_file + extension + if os.path.exists(path_to_local_file_full): + return path_to_local_file_full + for extension in ('.png', '.jpeg'): + path_to_file_full = path_to_file + extension + if os.path.exists(path_to_file_full): + return path_to_file_full + return os.path.abspath(generic) + def handle_incoming_pres_event(self, pres_obj): if gajim.jid_is_transport(pres_obj.jid): return True @@ -2619,8 +2638,8 @@ class NotificationEvent(nec.NetworkIncomingEvent): iconset = gajim.config.get('iconset') img_path = os.path.join(helpers.get_iconset_path(iconset), '48x48', show_image) - self.popup_image = gtkgui_helpers.get_path_to_generic_or_avatar( - img_path, jid=self.jid, suffix=suffix) + self.popup_image_path = self.get_path_to_generic_or_avatar(img_path, + jid=self.jid, suffix=suffix)
self.popup_timeout = gajim.config.get('notification_timeout')
@@ -2666,6 +2685,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.popup_event_type = '' self.popup_msg_type = '' self.popup_image = '' + self.popup_image_path = '' self.popup_timeout = -1
self.do_command = False
===================================== src/gtkgui_helpers.py ===================================== --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -642,28 +642,6 @@ def make_pixbuf_grayscale(pixbuf): pixbuf.saturate_and_pixelate(pixbuf2, 0.0, False) return pixbuf2
-def get_path_to_generic_or_avatar(generic, jid = None, suffix = None): - """ - Choose between avatar image and default image - - Returns full path to the avatar image if it exists, otherwise returns full - path to the image. generic must be with extension and suffix without - """ - if jid: - # we want an avatar - puny_jid = helpers.sanitize_filename(jid) - path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix - path_to_local_file = path_to_file + '_local' - for extension in ('.png', '.jpeg'): - path_to_local_file_full = path_to_local_file + extension - if os.path.exists(path_to_local_file_full): - return path_to_local_file_full - for extension in ('.png', '.jpeg'): - path_to_file_full = path_to_file + extension - if os.path.exists(path_to_file_full): - return path_to_file_full - return os.path.abspath(generic) - def decode_filechooser_file_paths(file_paths): """ Decode as UTF-8 under Windows and ask sys.getfilesystemencoding() in POSIX
===================================== src/notify.py ===================================== --- a/src/notify.py +++ b/src/notify.py @@ -155,8 +155,16 @@ class Notification:
def _nec_notification(self, obj): if obj.do_popup: + if obj.popup_image: + icon_path = gtkgui_helpers.get_icon_path(obj.popup_image, 48) + if icon_path: + image_path = icon_path + elif obj.popup_image_path: + image_path = obj.popup_image_path + else: + image_path = '' popup(obj.popup_event_type, obj.jid, obj.conn.name, - obj.popup_msg_type, path_to_image=obj.popup_image, + obj.popup_msg_type, path_to_image=image_path, title=obj.popup_title, text=obj.popup_text, timeout=obj.popup_timeout)
===================================== test/runtests.py ===================================== --- a/test/runtests.py +++ b/test/runtests.py @@ -39,7 +39,6 @@ modules = ( 'unit.test_protocol_caps', 'unit.test_caps_cache', 'unit.test_contacts', 'unit.test_account', - 'unit.test_gui_interface', )
if use_x: @@ -47,6 +46,7 @@ if use_x: #'integration.test_gui_event_integration', 'integration.test_roster', 'integration.test_resolver', + 'unit.test_gui_interface', )
nb_errors = 0
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/0a28e0f0665378263381d29a55d5d563ecb...
--- View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/0a28e0f0665378263381d29a55d5d563ecb... You're receiving this email because of your account on dev.gajim.org.