-
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 10 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,98 @@ | ||
| from datetime import datetime, timedelta | ||
|
|
||
| import pytest | ||
|
|
||
| from currencycom import constants | ||
| from currencycom.client import CandlesticksChartIntervals | ||
|
|
||
|
|
||
| class TestKlines: | ||
| values = [60, 90, 120, 360, 999, 1000] | ||
| old_dates = [datetime(1970, 1, 1, 0, 33), datetime(1965, 3, 1, 16, 48), | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| datetime(1945, 9, 1, 6, 55)] | ||
|
|
||
| def test_get_klines_max_limit_interval_minute(self, client): | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| klines = client.get_klines(symbol='META.', | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| interval=CandlesticksChartIntervals. | ||
| MINUTE, | ||
| limit=constants.CurrencycomConstants. | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| KLINES_MAX_LIMIT) | ||
| assert len(klines) > 0, "We didn't get any information about " | ||
| assert isinstance(klines, list) | ||
| assert isinstance(klines[0][0], | ||
| int), "We get wrong information " \ | ||
| "from klines(open time), we should get int" | ||
| assert all(isinstance(i, list) for i in klines) | ||
|
|
||
| def test_get_klines_fiften_minutes_min_stock_limit(self, client): | ||
| klines = client.get_klines(symbol="NZD/JPY_LEVERAGE", | ||
| interval=CandlesticksChartIntervals. | ||
| FIFTEEN_MINUTES) | ||
| assert len( | ||
| klines) > 0, f"We didn't get ant information " \ | ||
| f"about klines/candlestick NZD/JPY_LEVERAGE" | ||
| assert isinstance(klines, list) | ||
| assert isinstance(klines[0][0], | ||
| int), "We get wrong information " \ | ||
| "from klines(open time), we should get int" | ||
| assert all(isinstance(i, list) for i in klines) | ||
|
|
||
| def test_get_klines_week_limit_min(self, client): | ||
| klines = client.get_klines(symbol="AOS.", | ||
| interval=CandlesticksChartIntervals. | ||
| WEEK, | ||
| limit=1) | ||
| assert len( | ||
| klines) == 1, f"We didn't get ant information " \ | ||
| f"about klines/candlestick NZD/JPY_LEVERAGE" | ||
| assert isinstance(klines[0][0], | ||
| int), "We get wrong information " \ | ||
| "from klines(open time), we should get int" | ||
| assert isinstance(klines, list) | ||
| assert all(isinstance(i, list) for i in klines) | ||
|
|
||
| def test_get_klines_negative_symbol(self, client): | ||
| klines = client.get_klines(symbol="TEST", | ||
| interval=CandlesticksChartIntervals.DAY) | ||
| assert klines[ | ||
| 'code'] == -1128, "The negative test has problem " \ | ||
| "with klines['code'] == -1128" | ||
| assert 'Invalid symbol:' in klines['msg'] | ||
|
|
||
| def test_get_klines_negative_limit_minus(self, client): | ||
| klines = client.get_klines(symbol="META.", | ||
| interval=CandlesticksChartIntervals.HOUR, | ||
| limit=-500) | ||
| assert klines['code'] == -1128, "The test has problem with -500 limit" | ||
| assert klines['msg'] == 'Invalid limit parameter' | ||
|
|
||
| def test_get_klines_negative_limit_float(self, client): | ||
| klines = client.get_klines(symbol="META.", | ||
| interval=CandlesticksChartIntervals.MINUTE, | ||
| limit=400.5) | ||
| assert klines['code'] == -1128, "The test has problem with -500 limit" | ||
| assert klines['msg'] == 'Combination of parameters invalid' | ||
|
|
||
| def test_get_klines_negative_limit_str(self, client): | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| with pytest.raises(TypeError): | ||
| client.get_klines(symbol='META.', | ||
| interval=CandlesticksChartIntervals. | ||
| FIFTEEN_MINUTES, limit='ups') | ||
|
|
||
| def test_get_klines_negative_limit_more_max(self, client): | ||
| with pytest.raises(ValueError): | ||
| client.get_agg_trades(symbol='EUR/USD_LEVERAGE', limit=1001) | ||
|
|
||
| def test_get_klines_negative_with_interval(self, client): | ||
|
andrgit marked this conversation as resolved.
Outdated
|
||
| klines = client.get_klines(symbol='META.', | ||
| interval=CandlesticksChartIntervals. | ||
| THIRTY_MINUTES, ) | ||
|
|
||
| @pytest.mark.parametrize('minutes', values) | ||
| def test_start_time_in_future(self, client, minutes): | ||
| dttm_now_plus = datetime.now() + timedelta(minutes=minutes) | ||
| klines = client.get_klines(symbol='EUR/USD_LEVERAGE', | ||
| interval=CandlesticksChartIntervals. | ||
| FIVE_MINUTES, | ||
| start_time=dttm_now_plus) | ||
| assert len(klines) == 0 | ||
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.