# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# def load_module(name: str):
# def _format_args(args):
#     def format_arg(a):
# def _wrap_in_dbus_variant(value):
#     def __init__(self, bus_name: str, path: str, interface: str, props: PropsType,
#                  logfile: Optional[str] = None, is_object_manager: bool = False) -> None:
#     def __del__(self) -> None:
#     def _set_up_object_manager(self) -> None:
#     def _reset(self, props: PropsType) -> None:
#     def Get(self, interface_name: str, property_name: str) -> Any:
#     def GetAll(self, interface_name: str, *_, **__) -> PropsType:
#     def Set(self, interface_name: str, property_name: str, value: Any, *_, **__) -> None:
#     def AddObject(self, path: str, interface: str, properties: PropsType, methods: List[MethodType]) -> None:
#     def RemoveObject(self, path: str) -> None:  # pylint: disable=no-self-use
#     def Reset(self) -> None:
#     def AddMethod(self, interface, name: str, in_sig: str, out_sig: str, code: str) -> None:
#     def AddMethods(self, interface: str, methods: List[MethodType]) -> None:
#     def _set_property(self, interface, name, value):
#     def UpdateProperties(self, interface: str, properties: PropsType) -> None:
#     def AddProperty(self, interface: str, name: str, value: Any) -> None:
#     def AddProperties(self, interface: str, properties: PropsType) -> None:
#     def AddTemplate(self, template: str, parameters: PropsType) -> None:
#     def EmitSignal(self, interface: str, name: str, signature: str, args: List[Any]) -> None:
#     def GetCalls(self) -> List[CallLogType]:
#     def GetMethodCalls(self, method: str) -> List[Tuple[int, Sequence[Any]]]:
#     def ClearCalls(self) -> None:
#     def MethodCalled(self, name, args):
#     def object_manager_emit_added(self, path: str) -> None:
#     def object_manager_emit_removed(self, path: str) -> None:
#     def mock_method(self, interface: str, dbus_method: str, in_signature: str, *args, **_) -> Any:
#     def log(self, msg: str) -> None:
#     def Introspect(self, object_path: str, connection: dbus.connection.Connection) -> str:
# def _dbusmock_method_lookup(obj, method_name, dbus_interface):
# def get_objects() -> KeysView[str]:
# def get_object(path) -> DBusMockObject:
# class DBusMockObject(dbus.service.Object):  # pylint: disable=too-many-instance-attributes


import dbus
import dbusmock
from dbusmock import MOCK_IFACE, mockobject
                   DEVICE_IFACE,
                   {
                       'PowerSupply': dbus.Boolean(True, variant_level=1),
                       'IsPresent': dbus.Boolean(True, variant_level=1),
                       'Model': dbus.String(model_name, variant_level=1),
                       'Percentage': dbus.Double(percentage, variant_level=1),
                       'TimeToFull': dbus.Int64(seconds_to_full, variant_level=1),
                       'EnergyFull': dbus.Double(100.0, variant_level=1),
                       'Energy': dbus.Double(percentage, variant_level=1),
                       # UP_DEVICE_STATE_CHARGING
                       'State': dbus.UInt32(1, variant_level=1),
                       # UP_DEVICE_KIND_BATTERY
                       'Type': dbus.UInt32(2, variant_level=1),
                   },
                   [])
    self.EmitSignal(MAIN_IFACE, 'DeviceAdded', 'o', [path])
    return path


@dbus.service.method(MOCK_IFACE,
                     in_signature='uuddddxxbsu', out_signature='')
def SetupDisplayDevice(self, _type, state, percentage, energy, energy_full,
                       energy_rate, time_to_empty, time_to_full, is_present,
                       icon_name, warning_level):
    '''Convenience method to configure DisplayDevice properties

    This calls Set() for all properties that the DisplayDevice is defined to
    have, and is shorter if you have to completely set it up instead of
    changing just one or two properties.
    '''

# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# def load_module(name: str):
# def _format_args(args):
#     def format_arg(a):
# def _wrap_in_dbus_variant(value):
#     def __init__(self, bus_name: str, path: str, interface: str, props: PropsType,
#                  logfile: Optional[str] = None, is_object_manager: bool = False) -> None:
#     def __del__(self) -> None:
#     def _set_up_object_manager(self) -> None:
#     def _reset(self, props: PropsType) -> None:
#     def Get(self, interface_name: str, property_name: str) -> Any:
#     def GetAll(self, interface_name: str, *_, **__) -> PropsType:
#     def Set(self, interface_name: str, property_name: str, value: Any, *_, **__) -> None:
#     def AddObject(self, path: str, interface: str, properties: PropsType, methods: List[MethodType]) -> None:
#     def RemoveObject(self, path: str) -> None:  # pylint: disable=no-self-use
#     def Reset(self) -> None:
#     def AddMethod(self, interface, name: str, in_sig: str, out_sig: str, code: str) -> None:
#     def AddMethods(self, interface: str, methods: List[MethodType]) -> None:
#     def _set_property(self, interface, name, value):
#     def UpdateProperties(self, interface: str, properties: PropsType) -> None:
#     def AddProperty(self, interface: str, name: str, value: Any) -> None:
#     def AddProperties(self, interface: str, properties: PropsType) -> None:
#     def AddTemplate(self, template: str, parameters: PropsType) -> None:
#     def EmitSignal(self, interface: str, name: str, signature: str, args: List[Any]) -> None:
#     def GetCalls(self) -> List[CallLogType]:
#     def GetMethodCalls(self, method: str) -> List[Tuple[int, Sequence[Any]]]:
#     def ClearCalls(self) -> None:
#     def MethodCalled(self, name, args):
#     def object_manager_emit_added(self, path: str) -> None:
#     def object_manager_emit_removed(self, path: str) -> None:
#     def mock_method(self, interface: str, dbus_method: str, in_signature: str, *args, **_) -> Any:
#     def log(self, msg: str) -> None:
#     def Introspect(self, object_path: str, connection: dbus.connection.Connection) -> str:
# def _dbusmock_method_lookup(obj, method_name, dbus_interface):
# def get_objects() -> KeysView[str]:
# def get_object(path) -> DBusMockObject:
# class DBusMockObject(dbus.service.Object):  # pylint: disable=too-many-instance-attributes


# Path: dbusmock/templates/upower.py
import dbus
import dbusmock
from dbusmock import MOCK_IFACE, mockobject

                   DEVICE_IFACE,
                   {
                       'PowerSupply': dbus.Boolean(True, variant_level=1),
                       'IsPresent': dbus.Boolean(True, variant_level=1),
                       'Model': dbus.String(model_name, variant_level=1),
                       'Percentage': dbus.Double(percentage, variant_level=1),
                       'TimeToFull': dbus.Int64(seconds_to_full, variant_level=1),
                       'EnergyFull': dbus.Double(100.0, variant_level=1),
                       'Energy': dbus.Double(percentage, variant_level=1),
                       # UP_DEVICE_STATE_CHARGING
                       'State': dbus.UInt32(1, variant_level=1),
                       # UP_DEVICE_KIND_BATTERY
                       'Type': dbus.UInt32(2, variant_level=1),
                   },
                   [])
    self.EmitSignal(MAIN_IFACE, 'DeviceAdded', 'o', [path])
    return path


@dbus.service.method(MOCK_IFACE,
                     in_signature='uuddddxxbsu', out_signature='')
def SetupDisplayDevice(self, _type, state, percentage, energy, energy_full,
                       energy_rate, time_to_empty, time_to_full, is_present,
                       icon_name, warning_level):
    '''Convenience method to configure DisplayDevice properties

    This calls Set() for all properties that the DisplayDevice is defined to
    have, and is shorter if you have to completely set it up instead of
    changing just one or two properties.
    '''

    display_props = mockobject.objects[self.p_display_dev]