Skip to content

Commit bb11e85

Browse files
committed
Add reverse url tests
1 parent fbeb5ab commit bb11e85

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

_ucoinpy_test/api/__init__.py

Whitespace-only changes.

_ucoinpy_test/api/test_bma.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import unittest
2+
from ucoinpy.api.bma import API
3+
from ucoinpy.documents.peer import BMAEndpoint
4+
5+
6+
class Test_BMA_API(unittest.TestCase):
7+
8+
def test_reverse_url_complete(self):
9+
endpoint = BMAEndpoint("test.com", "124.2.2.1", "2001:0db8:0000:85a3:0000:0000:ac1f:8001 ", 9092)
10+
api = API(endpoint.conn_handler(), "any")
11+
self.assertEqual(api.reverse_url("/test/url"), "http://test.com:9092/any/test/url")
12+
13+
def test_reverse_url_only_ipv4(self):
14+
endpoint = BMAEndpoint(None, "124.2.2.1", None, 9092)
15+
api = API(endpoint.conn_handler(), "any")
16+
self.assertEqual(api.reverse_url("/test/url"), "http://124.2.2.1:9092/any/test/url")
17+
18+
def test_reverse_url_only_ipv6(self):
19+
endpoint = BMAEndpoint(None, None, "2001:0db8:0000:85a3:0000:0000:ac1f:8001", 9092)
20+
api = API(endpoint.conn_handler(), "any")
21+
self.assertEqual(api.reverse_url("/test/url"), "http://2001:0db8:0000:85a3:0000:0000:ac1f:8001:9092/any/test/url")

0 commit comments

Comments
 (0)