-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from gondixyz/feature/testCoverage
Tests
- Loading branch information
Showing
10 changed files
with
164 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from gondi.common_utils import Environment | ||
from gondi.api import inputs | ||
from gondi.api.client import Client | ||
|
||
|
||
async def test(): | ||
from gondi.api.query_provider import QueryProvider | ||
|
||
client = Client(Environment.MAIN) | ||
offers_input = inputs.OfferInput(statuses=[inputs.OfferStatus.ACTIVE]) | ||
provider = QueryProvider(client) | ||
for i in range(300): | ||
print(await client.query(provider.get_offers(offers_input))) | ||
print(i) | ||
|
||
|
||
if __name__ == "__main__": | ||
import asyncio | ||
|
||
loop = asyncio.get_event_loop() | ||
|
||
loop.run_until_complete(test()) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
from gql.dsl import DSLQuery | ||
|
||
from gondi.api.client import Client | ||
from test.mocks import MockedGraphqlClient, MockedSession | ||
|
||
|
||
GraphqlClientPatch = patch("gql.Client", MockedGraphqlClient) | ||
|
||
|
||
@GraphqlClientPatch | ||
class TestClient(unittest.IsolatedAsyncioTestCase): | ||
async def asyncSetUp(self) -> None: | ||
self._session = MockedSession() | ||
|
||
async def test_login(self): | ||
client = Client() | ||
await client.login() | ||
self.assertEquals( | ||
client.bearer, self._session.return_values["signInWithEthereum"] | ||
) | ||
|
||
async def test_check_bearer(self): | ||
client = Client() | ||
await client.check_bearer() | ||
self.assertEquals( | ||
client.bearer, self._session.return_values["signInWithEthereum"] | ||
) | ||
|
||
async def test_query(self): | ||
client = Client() | ||
sample_query = self._sample_query(client.lending_schema) | ||
no_queries = len(self._session.queries) | ||
await client.query(sample_query) | ||
self.assertEqual(no_queries + 1, len(self._session.queries)) | ||
|
||
async def test_auth_query(self): | ||
client = Client() | ||
sample_query = self._sample_query(client.lending_schema) | ||
await client.auth_query(sample_query) | ||
self.assertEquals( | ||
client.bearer, self._session.return_values["signInWithEthereum"] | ||
) | ||
|
||
def _sample_query(self, schema): | ||
return DSLQuery( | ||
schema.Query.listOffers.select(schema.OfferConnection.totalCount) | ||
) |
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters