emulate_software_center_dbus_call is sort of a bad name, this might get used somewhere else so just wrap the launcher function and call it add_launcher_itom_from_position.
instead of importing dbus and doing bus.SessionBus just do:
from autopilot.emulators.dbus_handler import session_bus
session_bus is your bus object.
define the desktop file in a variable instead of reusing the string over and over.
sleep should not be the first thing you do in your test, also not the last!
You need to check that the icon isn't None when you get it after the dbus call. If the call failed, then the test will crash. So assert that it is not None
self.assertThat(icon, Not(Is(None)))
Instead of asserting that icon_text == "blah", Equals(True) do this
self.assertThat(icon[0].tooltip_text, Equals("Waiting to install"))
cleanup should go like this,
add an anonymous function to your test
def cleanup():
if icon is not None: launcher_instance.unlock_from_launcher(icon[0])
then
icon = self.launcher.model.get_icon_by_desktop_file(DESKTOP_FILE_PATH)
if icon is not None:
launcher_instance.unlock_from_launcher(icon[0])
sleep(1)
else:
self.addCleanup(cleanup)
emulate_ software_ center_ dbus_call is sort of a bad name, this might get used somewhere else so just wrap the launcher function and call it add_launcher_ itom_from_ position.
instead of importing dbus and doing bus.SessionBus just do: emulators. dbus_handler import session_bus
from autopilot.
session_bus is your bus object.
define the desktop file in a variable instead of reusing the string over and over.
sleep should not be the first thing you do in your test, also not the last!
You need to check that the icon isn't None when you get it after the dbus call. If the call failed, then the test will crash. So assert that it is not None (icon, Not(Is(None)))
self.assertThat
Instead of asserting that icon_text == "blah", Equals(True) do this (icon[0] .tooltip_ text, Equals("Waiting to install"))
self.assertThat
cleanup should go like this,
launcher_ instance. unlock_ from_launcher( icon[0] ) model.get_ icon_by_ desktop_ file(DESKTOP_ FILE_PATH) instance. unlock_ from_launcher( icon[0] ) addCleanup( cleanup)
add an anonymous function to your test
def cleanup():
if icon is not None:
then
icon = self.launcher.
if icon is not None:
launcher_
sleep(1)
else:
self.