Skip to content
Snippets Groups Projects
Select Git revision
  • be1199be74620d2e9865755c27b566c58400a1a0
  • main default protected
  • release/1.1
  • encrypt_comments
  • mnemonic_dewif
  • authors_rules
  • 0.14
  • rtd
  • 1.2.1 protected
  • 1.2.0 protected
  • 1.1.1 protected
  • 1.1.0 protected
  • 1.0.0 protected
  • 1.0.0rc1 protected
  • 1.0.0rc0 protected
  • 1.0.0-rc protected
  • 0.62.0 protected
  • 0.61.0 protected
  • 0.60.1 protected
  • 0.58.1 protected
  • 0.60.0 protected
  • 0.58.0 protected
  • 0.57.0 protected
  • 0.56.0 protected
  • 0.55.1 protected
  • 0.55.0 protected
  • 0.54.3 protected
  • 0.54.2 protected
28 results

test_bma.py

Blame
  • Inso's avatar
    inso authored
    be1199be
    History
    test_bma.py 1.31 KiB
    import unittest
    from ucoinpy.api.bma import API
    from ucoinpy.documents.peer import BMAEndpoint
    
    
    class Test_BMA_API(unittest.TestCase):
    
        def test_reverse_url_complete(self):
            endpoint = BMAEndpoint("test.com", "124.2.2.1", "2001:0db8:0000:85a3:0000:0000:ac1f:8001 ", 9092)
            api = API(endpoint.conn_handler(), "any")
            self.assertEqual(api.reverse_url("http", "/test/url"), "http://test.com:9092/any/test/url")
    
        def test_reverse_url_only_ipv4(self):
            endpoint = BMAEndpoint(None, "124.2.2.1", None, 9092)
            api = API(endpoint.conn_handler(), "any")
            self.assertEqual(api.reverse_url("http", "/test/url"), "http://124.2.2.1:9092/any/test/url")
    
        def test_reverse_url_only_ipv6(self):
            endpoint = BMAEndpoint(None, None, "2001:0db8:0000:85a3:0000:0000:ac1f:8001", 9092)
            api = API(endpoint.conn_handler(), "any")
            self.assertEqual(api.reverse_url("http", "/test/url"), "http://2001:0db8:0000:85a3:0000:0000:ac1f:8001:9092/any/test/url")
    
        def test_parse_error(self):
            api = API(None, "any")
            error = api.parse_error("""{
    "ucode": 1005,
    "message": "Document has unkown fields or wrong line ending format"
    }""")
            self.assertEqual(error["ucode"], 1005)
            self.assertEqual(error["message"], "Document has unkown fields or wrong line ending format")