Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/godel/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
url: str = "https://dapp.golden.xyz/graphql",
jwt_token: str = "",
headers: dict = {},
timeout: float = None,
):
self.url = url
self.jwt_token = jwt_token
Expand All @@ -71,7 +72,8 @@ def __init__(
self.headers.update(
{"Authorization": f"Bearer {jwt_token}"} if jwt_token else {}
)
self.endpoint = HTTPEndpoint(self.url, self.headers)
self.timeout = timeout
self.endpoint = HTTPEndpoint(self.url, self.headers, timeout=self.timeout)
self.predicates_cache = self.predicates()
self.templates_cache = self.templates()

Expand All @@ -89,7 +91,7 @@ def set_jwt_token(self, jwt_token: str = "") -> None:
self.headers.update(
{"Authorization": f"Bearer {jwt_token}"} if jwt_token else {}
)
self.endpoint = HTTPEndpoint(self.url, self.headers)
self.endpoint = HTTPEndpoint(self.url, self.headers, timeout=self.timeout)

def query(self, query: str = "", variables: dict = {}) -> dict:
"""Generic method to query graphql endpoint"""
Expand Down
7 changes: 4 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_predicates():
def test_templates():
_GOLDAPI.templates()


@pytest.mark.skip(reason="Needs config")
def test_auntheticate():
# Retrieve one-off nonce from GraphQL API
message_response = _GOLDAPI.get_authentication_message(user_id=_WALLET_A)
Expand All @@ -50,7 +50,7 @@ def test_auntheticate():
global _JWT_TOKEN
_JWT_TOKEN = jwt_token


@pytest.mark.skip(reason="Needs config")
def test_create_entity():
# Test connection with search
search_results = _GOLDAPI.entity_search(name="Miles")
Expand Down Expand Up @@ -128,6 +128,7 @@ def test_create_entity():
assert "errors" not in data


@pytest.mark.skip(reason="Needs config")
def test_create_triple():
# Test with search
search_results = _GOLDAPI.entity_search(name="Miles")
Expand Down Expand Up @@ -157,7 +158,7 @@ def test_create_triple():
data = _GOLDAPI.create_statement(create_statement_input=create_statement_input)
assert "errors" not in data


@pytest.mark.skip(reason="Needs config")
def test_create_verification():
# Get an unvalidated triple
data = _GOLDAPI.unvalidated_triple()["data"]
Expand Down