Added proper timeouts

api-breakage
Morty Space 4 years ago
parent 131971c325
commit 1c72cbe44e
  1. 1
      .github/workflows/test.yml
  2. 61
      azure-pipelines.yml
  3. 4
      src/cryptocom/exchange/api.py
  4. 8
      tests/test_market.py

@ -75,6 +75,7 @@ jobs:
- name: Test docs
run: . activate.sh && cd docs && make doctest && cd ..
- name: Test code
timeout-minutes: 5
run: . activate.sh && poetry run pytest -v --cov . --cov-report xml:coverage.xml
- name: Send codeclimate analytics
run: ./cc-test-reporter after-build -r ${{ secrets.CC_TEST_REPORTER_ID }} --exit-code $?

@ -1,61 +0,0 @@
---
trigger:
- master
schedules:
- cron: 0 0 * * *
displayName: Daily test run
branches:
include:
- master
always: true
variables:
- name: CRYPTOCOM_API_KEY
value: PCuweiWhHJC339hHdMdcVC
- name: CRYPTOCOM_API_SECRET
value: mXYtwLajZdFGU56mDo8eqL
- name: CC_TEST_REPORTER_ID
value: 16bcfb0958d99f11456f8d80aeb5800d567724471e151fe6e74a4b329b45dcb6
pool:
vmImage: ubuntu-20.04
strategy:
maxParallel: 1
matrix:
Python37:
python.version: '3.7'
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
steps:
- checkout: self
persistCredentials: true
clean: true
- task: UsePythonVersion@0
inputs:
versionSpec: $(python.version)
displayName: Use Python $(python.version)
- script: |
python -m pip install --upgrade pip
pip install poetry
poetry install
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
displayName: Install dependencies
- script: |
git pull origin master
poetry run python generatestructs.py
git config --global user.email "morty.space@gmail.com"
git config --global user.name "Morty Space"
git add -A .
git commit -m "[JOB] Updated API pairs and coins"
git push origin HEAD:master
displayName: Update API structs
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
# - script: |
# cd docs && make doctest && cd ..
# poetry run pytest -v --cov . --cov-report xml:coverage.xml
# ./cc-test-reporter after-build --exit-code $?
# displayName: Run tests

@ -269,10 +269,10 @@ class ApiProvider:
async for ws in websockets.connect(url, open_timeout=self.timeout):
try:
dataiterator = ApiListenAsyncIterable(self, ws, channels, sign)
async with async_timeout.timeout(120) as tm:
async with async_timeout.timeout(70) as tm:
async for data in dataiterator:
if data:
tm.shift(120)
tm.shift(70)
yield data
except (websockets.ConnectionClosed, asyncio.TimeoutError):
continue

@ -78,17 +78,13 @@ async def test_listen_candles(exchange: cro.Exchange):
@pytest.mark.asyncio
async def test_listen_trades(exchange: cro.Exchange):
trades = []
count = 0
pairs = [cro.pairs.CRO_USDT, cro.pairs.BTC_USDT]
pairs = [cro.pairs.BTC_USDC, cro.pairs.BTC_USDT]
pairs_seen = set()
async for trade in exchange.listen_trades(*pairs):
trades.append(trade)
pairs_seen.add(trade.pair)
if count > 100:
if len(pairs_seen) == len(pairs) and len(trades) > 30:
break
count += 1
assert len(pairs_seen) == len(pairs)
@pytest.mark.asyncio

Loading…
Cancel
Save