Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] fetcher_sync_sucess fails for TheGraphFetcher #49

Open
1 task done
EvolveArt opened this issue Nov 4, 2023 · 0 comments
Open
1 task done

[BUG] fetcher_sync_sucess fails for TheGraphFetcher #49

EvolveArt opened this issue Nov 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@EvolveArt
Copy link
Contributor

What happened

Once #48 is done, we can fix this test.

I couldn't find a way to correctly mock post requests depending on the body which is only a problem for TheGraphFetcher as it works with POST requests and not GET requests as other fetchers do.

Note that weirdly enough, it works in the async case.

Stack trace

fetcher_config = {'expected_result': [SpotEntry(pair_id="BTC/USD", price=3459885191309, timestamp=12345, source="THEGRAPH", publisher="...file': PosixPath('/Users/matthall/Documents/pragma-sdk/pragma/tests/mock/responses/thegraph.json'), 'name': 'TheGraph'}
mock_data = {'BTC': {'data': {'pool': {'feeTier': '3000', 'liquidity': '12133869505104', 'sqrtPrice': '147370456125399510359475624...500', 'liquidity': '20753232973335935007', 'sqrtPrice': '1867199352400732300487913333649122', 'tick': '201362', ...}}}}

    @mock.patch("time.time", mock.MagicMock(return_value=12345))
    def test_fetcher_sync_success(fetcher_config, mock_data):
        with requests_mock.Mocker() as mocker:
            fetcher = fetcher_config["fetcher_class"](SAMPLE_ASSETS, PUBLISHER_NAME)
    
            # Mocking the expected call for assets
            for asset in SAMPLE_ASSETS:
                quote_asset = asset["pair"][0]
                base_asset = asset["pair"][1]
                url = fetcher.format_url(quote_asset, base_asset)
    
                # TODO (#000): Fix this test
                if fetcher_config["name"] == "TheGraph":
                    query = fetcher.query_body(quote_asset)
                    print(query)
                    mocker.post(
                        url,
                        json=mock_data[quote_asset],
                        additional_matcher=lambda request: request.text
                        == '{"query": "' + query + '"}}',
                    )
                else:
                    mocker.get(url, json=mock_data[quote_asset])
    
>           result = fetcher.fetch_sync()
...
requests_mock.exceptions.NoMockAddress: No mock address: POST https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3

Steps to reproduce

  1. poe test_ci_fetchers

SDK Version

1.0.4

Python version

3.9.13

What operating system are you using?

Mac

Is there an existing issue for this?

  • I have searched the existing issues and verified no issue exits for this problem.
@EvolveArt EvolveArt added the bug Something isn't working label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant