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
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
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
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'
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
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
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
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'
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)
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'
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'
def test_parse_jrpc_errors(jsonrpc_request, expected): with pytest.raises(expected): result = URN._parse_jrpc(jsonrpc_request)