本文整理汇总了Python中gstswitch.connection.Connection类的典型用法代码示例。如果您正苦于以下问题:Python Connection类的具体用法?Python Connection怎么用?Python Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handler_passed_to_gio
def test_handler_passed_to_gio(self, monkeypatch):
"""Test if handler is correctly passed to Gio"""
monkeypatch.setattr(
Gio.DBusConnection, 'new_for_address_sync',
Mock(return_value=Gio.DBusConnection()))
signal_subscribe_mock = Mock()
monkeypatch.setattr(
Gio.DBusConnection, 'signal_subscribe',
signal_subscribe_mock)
conn = Connection()
conn.connect_dbus()
test_cb = lambda: None
conn.signal_subscribe(test_cb)
# test that Gio's signal_subscribe method is called once
# and passed the callback as-is
signal_subscribe_mock.assert_called_once()
# pylint does not recognize Mock.call_args as sequence and won't
# allow us to unpack it. Disabling the warning because we know what
# we're doing here
# pylint: disable=unpacking-non-sequence
args, _ = signal_subscribe_mock.call_args
assert args[6] == test_cb
示例2: test_mock2
def test_mock2(self, monkeypatch):
"""Test GLib.GError exception"""
monkeypatch.setattr(
Gio.DBusConnection, 'new_for_address_sync',
Mock(return_value=1))
conn = Connection()
conn.connect_dbus()
assert conn.connection is not None
示例3: test_handler_not_callable
def test_handler_not_callable(self, monkeypatch):
"""Test if handler is not callable"""
conn = Connection()
test_cbs = ['', None, [], {}]
for test_cb in test_cbs:
with pytest.raises(ValueError):
conn.signal_subscribe(test_cb)
示例4: test_mock1
def test_mock1(self, monkeypatch):
"""Test GLib.GError exception"""
monkeypatch.setattr(
Gio.DBusConnection,
'new_for_address_sync',
Mock(side_effect=GLib.GError))
conn = Connection()
with pytest.raises(ConnectionError):
conn.connect_dbus()
示例5: test_gio_error_is_converted
def test_gio_error_is_converted(self, monkeypatch):
"""Test if handler is correctly passed to Gio"""
monkeypatch.setattr(Gio.DBusConnection, "new_for_address_sync", Mock(return_value=Gio.DBusConnection()))
monkeypatch.setattr(Gio.DBusConnection, "signal_subscribe", Mock(side_effect=GLib.GError("Boom!")))
conn = Connection()
conn.connect_dbus()
test_cb = Mock()
with pytest.raises(ConnectionError):
conn.signal_subscribe(test_cb)
示例6: test_gio_error_is_converted
def test_gio_error_is_converted(self, monkeypatch):
"""Test if handler is correctly passed to Gio"""
monkeypatch.setattr(
Gio.DBusConnection, 'new_for_address_sync',
Mock(return_value=Gio.DBusConnection()))
monkeypatch.setattr(
Gio.DBusConnection, 'signal_subscribe',
Mock(side_effect=GLib.GError('Boom!')))
conn = Connection()
conn.connect_dbus()
def test_cb():
""" Dummy callback. """
pass
with pytest.raises(ConnectionError):
conn.signal_subscribe(test_cb)
示例7: test_get_compose_port
def test_get_compose_port():
"""Test the get_compose_port method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection("get_compose_port")
with pytest.raises(ConnectionError):
conn.get_compose_port()
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection("get_compose_port")
assert conn.get_compose_port() == (3001,)
示例8: test_get_encode_port
def test_get_encode_port():
"""Test the get_encode_port method"""
default_interface = "info.duzy.gst.switch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_encode_port')
with pytest.raises(ConnectionError):
conn.get_encode_port()
default_interface = "info.duzy.gst.switch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_encode_port')
assert conn.get_encode_port() == (3002,)
示例9: test_switch
def test_switch():
"""Test the switch method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('switch')
with pytest.raises(ConnectionError):
conn.switch(1, 2)
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('switch')
assert conn.switch(1, 2) == (True,)
示例10: test_click_video
def test_click_video():
"""Test the click_video method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('click_video')
with pytest.raises(ConnectionError):
conn.click_video(1, 2, 3, 4)
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('click_video')
assert conn.click_video(1, 2, 3, 4) == (True,)
示例11: test_new_record
def test_new_record():
"""Test the new_record method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('new_record')
with pytest.raises(ConnectionError):
conn.new_record()
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('new_record')
assert conn.new_record() == (False,)
示例12: test_adjust_pip
def test_adjust_pip():
"""Test the adjust_pip method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('adjust_pip')
with pytest.raises(ConnectionError):
conn.adjust_pip(1, 2, 3, 4)
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('adjust_pip')
assert conn.adjust_pip(1, 2, 3, 4) == (1,)
示例13: test_get_composite_mode
def test_get_composite_mode():
"""Test the set_composite_mode method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_composite_mode')
with pytest.raises(ConnectionError):
conn.get_composite_mode()
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_composite_mode')
assert conn.get_composite_mode() == (0,)
示例14: test_set_encode_mode
def test_set_encode_mode():
"""Test the set_encode_mode method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('set_encode_mode')
with pytest.raises(ConnectionError):
conn.set_encode_mode(2)
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('set_encode_mode')
assert conn.set_encode_mode(2) == (False,)
示例15: test_get_audio_port
def test_get_audio_port():
"""Test the get_audio_port method"""
default_interface = "us.timvideos.gstswitch"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_audio_port')
with pytest.raises(ConnectionError):
conn.get_audio_port()
default_interface = "us.timvideos.gstswitch.SwitchControllerInterface"
conn = Connection(default_interface=default_interface)
conn.connection = MockConnection('get_audio_port')
assert conn.get_audio_port() == (4000,)