Open
Conversation
Add tests for `pyxtb` project * **tests/test_api.py** - Import `pytest` and `pytest-asyncio` - Import `Api` from `pyxtb.api` - Add fixture `api` to set up and tear down `Api` instance - Add test function `test_login` to test the `login` method of `Api` - Add test function `test_get_all_symbols` to test the `get_all_symbols` method of `Api` - Add test function `test_get_calendar` to test the `get_calendar` method of `Api` * **README.md** - Add a section "## Running Tests" with instructions on how to run the tests using `pytest`
* Import necessary modules and classes * Add test functions for: - `get_chart_last_request` - `get_chart_range_request` - `get_commission_def` - `get_current_user_data` - `get_ibs_history` - `get_margin_level` - `get_margin_trade` - `get_news` - `get_profit_calculation` - `get_server_time` - `get_step_rules` - `get_symbol` - `get_tick_prices` - `get_trade_records` - `get_trades` - `get_trades_history` - `get_trading_hours` - `get_version` - `ping` - `trade_transaction` - `trade_transaction_status`
* Write `fetch_and_store_data` function to fetch data for various methods and store it in JSON files in `mock_data` directory * Add main block to run `fetch_and_store_data` function Update `tests/test_api.py` to use mocked data * Add `mock_data` fixture to load mocked data from `mock_data` directory * Modify test functions to use mocked data instead of making actual API calls
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pyxtb/api.py:255
- Fix the nested double quotes in the f-string; consider using single quotes for the key (e.g., parsed_data['data']).
f"Received command: {command} with data: {parsed_data["data"]}"
| data['get_chart_last_request'] = await api.get_chart_last_request( | ||
| ChartLastInfoRecord( | ||
| period=Period.PERIOD_M5, | ||
| start=int((datetime.datetime.now() - datetime.timedelta(days=1)).timestamp() * 1000), |
There was a problem hiding this comment.
Missing import for datetime; please add 'import datetime' at the top of the file.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add tests for
pyxtbprojecttests/test_api.py
pytestandpytest-asyncioApifrompyxtb.apiapito set up and tear downApiinstancetest_loginto test theloginmethod ofApitest_get_all_symbolsto test theget_all_symbolsmethod ofApitest_get_calendarto test theget_calendarmethod ofApiREADME.md
pytest