-
Notifications
You must be signed in to change notification settings - Fork 15
Add test_klines.py #15
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
Open
andrgit
wants to merge
15
commits into
sann05:hybrid
Choose a base branch
from
andrgit:hybrid_klines
base: hybrid
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
efca772
Merge pull request #1 from sann05/hybrid
andrgit 33482aa
Add test_exchange_info
andrgit 6525b6c
update test_exchange_info, add second condition
andrgit f8fc0a5
update test_exchange_info
andrgit acedfab
add test klines
andrgit 85bffa4
Revert "add test klines"
andrgit aaf0fd6
Revert "Revert "add test klines""
andrgit 8caff45
Deleted test_exchange_info.py
andrgit 21904a3
changed line length to 79 chars
andrgit 94a2f7d
updated test_klines
andrgit 7eb545e
changed all test,add test interval,limit
andrgit 58a7388
refixed functions,made base test,interval test,limit test
andrgit 1b0e0ae
fix some bugs
andrgit be87e12
Add tests start_time and end_time
andrgit 9b0e394
Add tests: wrong_symbol, start_time_in_future,end_time_less_then_star…
andrgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,57 @@ | ||
| import sys | ||
| import time | ||
| from datetime import datetime, timedelta | ||
|
|
||
| import pytest | ||
|
|
||
| from currencycom import constants | ||
| from currencycom.client import CandlesticksChartIntervals | ||
|
|
||
|
|
||
| class TestKlines: | ||
| values = [1, 59, 99, 101, 500, 999, 1000] | ||
|
|
||
| def test_klines_check_interval_pos(self, client): | ||
| klines = client.get_klines(symbol='META.', | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| interval=CandlesticksChartIntervals.MINUTE, | ||
| limit=10) | ||
|
|
||
| count = 0 | ||
| prev_value = None | ||
| for op_time in klines: | ||
| assert op_time[0] % 60000 == 0 # and | ||
| if count > 0: | ||
| assert op_time[0] - prev_value == 60000 | ||
| prev_value = op_time[0] | ||
| count += 1 | ||
|
|
||
| @pytest.mark.parametrize('limit', | ||
| [1, 500, 999, 1000]) | ||
| def test_get_klines_limits_pos(self, client, limit): | ||
|
sann05 marked this conversation as resolved.
Outdated
|
||
| """ | ||
| Проверяем количество лимитов и количество полученных значений | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| """ | ||
| klines = client.get_klines(symbol='META.', | ||
| interval=CandlesticksChartIntervals.MINUTE, | ||
| limit=limit) | ||
| assert len(klines) == limit | ||
|
|
||
| @pytest.mark.parametrize('limit', | ||
| [float('inf'), float('-inf'), -1, 0, 1001, | ||
| sys.maxsize, -sys.maxsize]) | ||
| def test_get_klines_limits_neg(self, client, limit): | ||
| """ | ||
| Проверяем количество лимитов и количество полученных значений | ||
| """ | ||
| if limit <= 0: | ||
| klines = client.get_klines(symbol='META.', | ||
| interval=CandlesticksChartIntervals. | ||
| FIFTEEN_MINUTES, | ||
| limit=limit) | ||
| assert klines['code'] == -1128 | ||
| else: | ||
| with pytest.raises(ValueError): | ||
| client.get_klines(symbol='META.', | ||
| interval=CandlesticksChartIntervals. | ||
| FIFTEEN_MINUTES, | ||
| limit=limit) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.