Exemplo n.º 1
0
def test_upstream_url(urn_test_request_dicts):
    os.environ['JUSSI_ACCOUNT_TRANSFER_STEEMD_URL'] = 'account_transfer_url'
    upstreams = _Upstreams(TEST_UPSTREAM_CONFIG, validate=False)
    jsonrpc_request, urn, url, ttl, timeout = urn_test_request_dicts
    test_urn = URN.from_request(jsonrpc_request)
    upstream = Upstream.from_urn(test_urn, upstreams=upstreams)
    del os.environ['JUSSI_ACCOUNT_TRANSFER_STEEMD_URL']
    assert upstream.url == url
Exemplo n.º 2
0
def test_ttl_object():
    from jussi.urn import URN
    urn = URN('test2', 'api', 'method', False)
    upstreams = _Upstreams(SIMPLE_CONFIG, validate=False)
    assert upstreams.ttl(urn) == 2
Exemplo n.º 3
0
def test_timeout_pair():
    from jussi.urn import URN
    urn = URN('test', 'api', 'method', False)
    upstreams = _Upstreams(SIMPLE_CONFIG, validate=False)
    assert upstreams.timeout(urn) == 1
Exemplo n.º 4
0
def test_url_pair():
    from jussi.urn import URN
    urn = URN('test', 'api', 'method', False)
    upstreams = _Upstreams(SIMPLE_CONFIG, validate=False)
    assert upstreams.url(urn) == 'http://test.com'
Exemplo n.º 5
0
def test_translate_to_appbase_config_false():
    from jussi.urn import URN
    urn = URN('test2', 'api', 'method', False)
    upstreams = _Upstreams(SIMPLE_CONFIG, validate=False)
    assert upstreams.translate_to_appbase(urn) is False
Exemplo n.º 6
0
def test_upstream_timeout(urn_test_request_dicts):
    upstreams = _Upstreams(TEST_UPSTREAM_CONFIG, validate=False)
    jsonrpc_request, urn, url, ttl, timeout = urn_test_request_dicts
    test_urn = URN.from_request(jsonrpc_request)
    upstream = Upstream.from_urn(test_urn, upstreams=upstreams)
    assert upstream.timeout == timeout
Exemplo n.º 7
0
def test_parse_jrpc_namespaces(full_urn_test_request_dicts):
    jsonrpc_request, urn_parsed, urn, url, ttl, timeout = full_urn_test_request_dicts
    result = URN._parse_jrpc(jsonrpc_request)
    assert result == urn_parsed
Exemplo n.º 8
0
def test_urn_not_eq(full_urn_test_request_dicts):
    jsonrpc_request, urn_parsed, urn, url, ttl, timeout = full_urn_test_request_dicts
    result_urn = URN.from_request(jsonrpc_request)
    assert result_urn != 'nope'
Exemplo n.º 9
0
def test_urn_hash(full_urn_test_request_dicts):
    jsonrpc_request, urn_parsed, urn, url, ttl, timeout = full_urn_test_request_dicts
    result_urn = URN.from_request(jsonrpc_request)
    assert hash(result_urn) == hash(urn)
Exemplo n.º 10
0
def test_parse_jrpc_namespace_is_appbase(appbase_requests_and_responses):
    req, resp = appbase_requests_and_responses
    result = URN._parse_jrpc(req)
    assert result['namespace'] == 'appbase'
Exemplo n.º 11
0
def test_parse_jrpc_namespace_is_steemd(just_steemd_requests_and_responses):
    req, resp = just_steemd_requests_and_responses
    result = URN._parse_jrpc(req)
    assert result['namespace'] == 'steemd'
Exemplo n.º 12
0
def test_parse_jrpc_errors(jsonrpc_request, expected):
    with pytest.raises(expected):
        result = URN._parse_jrpc(jsonrpc_request)