Skip to content

Commit

Permalink
Merge branch 'nosammai/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyqs committed Mar 21, 2022
2 parents d25fab3 + 66feef9 commit aab5c91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions nats/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,9 @@ async def flush(self, timeout: int = 10) -> None:
raise errors.TimeoutError

@property
def connected_url(self) -> Optional[str]:
def connected_url(self) -> Optional[ParseResult]:
if self._current_server and self.is_connected:
return str(self._current_server.uri)
return self._current_server.uri
return None

@property
Expand Down
8 changes: 6 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ssl
import time
import unittest
import urllib
from unittest import mock

import pytest
Expand Down Expand Up @@ -37,6 +38,7 @@ def test_default_connect_command(self):
expected = f'CONNECT {{"echo": true, "lang": "python3", "pedantic": false, "protocol": 1, "verbose": false, "version": "{__version__}"}}\r\n'
self.assertEqual(expected.encode(), got)


def test_default_connect_command_with_name(self):
nc = NATS()
nc.options["verbose"] = False
Expand All @@ -53,16 +55,18 @@ class ClientTest(SingleServerTestCase):

@async_test
async def test_default_connect(self):
nc = NATS()
await nc.connect()
nc = await nats.connect()
self.assertIn('server_id', nc._server_info)
self.assertIn('client_id', nc._server_info)
self.assertIn('max_payload', nc._server_info)
self.assertEqual(nc._server_info['max_payload'], nc.max_payload)
self.assertTrue(nc.max_payload > 0)
self.assertTrue(nc.is_connected)
self.assertTrue(nc.client_id > 0)
self.assertEqual(type(nc.connected_url), urllib.parse.ParseResult)
await nc.close()

self.assertEqual(nc.connected_url, None)
self.assertTrue(nc.is_closed)
self.assertFalse(nc.is_connected)

Expand Down

0 comments on commit aab5c91

Please sign in to comment.