Beispiel #1
0
    def __init__(self, config, endpoint_prefix="", mute_raise=False):
        self.mute_raise = mute_raise

        # url
        self.server_url = create_url(**config, path=endpoint_prefix)

        # authentication
        self.token = config.get("token")
        self.login = config.get("login")
        self.password = config.get("password")
Beispiel #2
0
    def init_worker(self, config, endpoint="", header={}):
        # url
        self.server_url = create_url(**config,
                                     path=endpoint,
                                     scheme_no_ssl="ws",
                                     scheme_ssl="wss")

        # other
        self.header = header
        self.websocket = None
        self.retry = False
        self.reconnect_interval = config.get("reconnect_interval",
                                             RECONNECT_INTERVAL)

        # create callbacks
        self.callbacks = {}
        self.set_default_callbacks()

        # create timer
        self.timer = self.create_timer(0, self.run)
 def test_invalid_furl(self, mocked_furl):
     """Test to create URL with invalid arguments for furl."""
     mocked_furl.side_effect = ValueError("error")
     with self.assertRaises(URLParameterError):
         create_url(host="www.example.com", scheme_no_ssl="http")
 def test_address_host_port(self):
     """Test to create URL with provided address containing host and port."""
     url = create_url(address="www.example.com:8000", scheme_no_ssl="http")
     self.assertEqual(url, "http://www.example.com:8000")
 def test_nothing(self):
     """Test to create URL when nothing is provided."""
     with self.assertRaises(URLParameterError):
         create_url()
 def test_host_path(self):
     """Test to create URL with provided host and path."""
     url = create_url(host="www.example.com",
                      path="path/to/resource",
                      scheme_no_ssl="http")
     self.assertEqual(url, "http://www.example.com/path/to/resource")
 def test_host_port(self):
     """Test to create URL with provided host and port."""
     url = create_url(host="www.example.com",
                      port=8000,
                      scheme_no_ssl="http")
     self.assertEqual(url, "http://www.example.com:8000")
 def test_host_ssl(self):
     """Test to create URL with provided host and SSL security."""
     url = create_url(host="www.example.com", ssl=True, scheme_ssl="https")
     self.assertEqual(url, "https://www.example.com")
 def test_url_path(self):
     """Test to create URL directly with provided URL and path."""
     url = create_url(url="http://www.example.com", path="path/to/resource")
     self.assertEqual(url, "http://www.example.com/path/to/resource")
Beispiel #10
0
 def test_url(self):
     """Test to create URL directly with provided URL."""
     url = create_url(url="http://www.example.com", host="www.other.com")
     self.assertEqual(url, "http://www.example.com")