diff --git a/python-api/gstswitch/connection.py b/python-api/gstswitch/connection.py index 949e33c..80d6325 100644 --- a/python-api/gstswitch/connection.py +++ b/python-api/gstswitch/connection.py @@ -52,7 +52,7 @@ def address(self, address): http://dbus.freedesktop.org/doc/dbus-specification.html#addresses """ if not address: - raise ValueError("Address '{0} cannot be blank'") + raise ValueError("Address '{0}' cannot be blank") else: try: a = str(address) @@ -62,7 +62,7 @@ def address(self, address): raise ValueError("""Address must follow specifications mentioned at http://dbus.freedesktop.org/doc/dbus-specification.html#addresses""") except TypeError: - raise TypeError("Address should be a string or buffer, not '{0}'".format(type(address))) + raise TypeError("Address cannot be '{0}'".format(type(address))) @bus_name.setter def bus_name(self, bus_name): @@ -76,7 +76,7 @@ def bus_name(self, bus_name): a = str(bus_name) self._bus_name = a except TypeError: - raise TypeError("Bus Name should be a string or buffer, not '{0}'".format(type(bus_name))) + raise TypeError("Bus Name cannot be '{0}'".format(type(bus_name))) @object_path.setter def object_path(self, object_path): @@ -94,8 +94,8 @@ def object_path(self, object_path): raise ValueError("""object_path must follow specifications mentioned at http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path""") except TypeError: - raise TypeError("object_path should be a string or buffer, not '{0}'".format(type(object_path))) - + raise TypeError("object_path cannot be '{0}'".format(type(object_path))) + @default_interface.setter def default_interface(self, default_interface): """Set the default_interface @@ -112,7 +112,7 @@ def default_interface(self, default_interface): raise ValueError("""default_interface must follow specifications mentioned at http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface""") except TypeError: - raise TypeError("default_interface should be a string or buffer, not '{0}'".format(type(default_interface))) + raise TypeError("default_interface cannot be '{0}'".format(type(default_interface))) def connect_dbus(self): """Make a new connection using the parameters belonging to the class diff --git a/python-api/gstswitch/server.py b/python-api/gstswitch/server.py index cee639d..06147b5 100644 --- a/python-api/gstswitch/server.py +++ b/python-api/gstswitch/server.py @@ -112,7 +112,7 @@ def record_file(self, record_file): else: raise ValueError("Record File: '{0}' cannot have forward slashes".format(rec)) except TypeError: - raise TypeError("Record File should be a string or buffer, not '{0}'".format(type(record_file))) + raise TypeError("Record File cannot be '{0}'".format(type(record_file))) def run(self, gst_option=''): """Launch the server process diff --git a/python-api/gstswitch/test_connection.py b/python-api/gstswitch/test_connection.py index 44aede2..61acaae 100644 --- a/python-api/gstswitch/test_connection.py +++ b/python-api/gstswitch/test_connection.py @@ -16,9 +16,22 @@ def test_address_colon(self): with pytest.raises(ValueError): Connection(address=address) - def test_address_unknown(self): - address = [1, 2, 3] - with pytest.raises(ValueError): - Connection(address=address) + def test_address_normal(self): + address = ['unix:abstract=gstswitch', 'unix:temp=/tmp/abcd/xyz'] + for x in address: + conn = Connection(address=x) + assert conn.address == x + + +class TestBusName(object): + + def test_normal(self): + names = ['', 'abcd', 12345] + for bus in names: + conn = Connection(bus_name=bus) + assert conn.bus_name == str(bus) -class Test \ No newline at end of file + def test_normal_none(self): + name = None + conn = Connection(bus_name=name) + assert conn.bus_name == name diff --git a/python-api/gstswitch/test_server.py b/python-api/gstswitch/test_server.py index efab223..0dc721b 100644 --- a/python-api/gstswitch/test_server.py +++ b/python-api/gstswitch/test_server.py @@ -4,7 +4,6 @@ class TestPath(object): - # Path Tests def test_invalid_path(self): path = '/usr/'