Skip to content

Commit

Permalink
Add test to fix connected_url type
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <[email protected]>
  • Loading branch information
wallyqs committed Mar 21, 2022
1 parent 77638df commit 66feef9
Showing 1 changed file with 6 additions and 2 deletions.
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 66feef9

Please sign in to comment.