-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: support new config type
account-id
(#500)
* feat: support `account-id` config * refactor: reuse interactive logic of `input-account-id` * refactor: update account_ids in AuthConfiguration feat: skip account ids if it is not provided * test:feat: Auth0Client * feat: support Prompt in AccountIdsConfiguration * feat: handle accountIds and provide different option to user * refactor: handle of accountIds in json_module * refactor: validate len api_accounts_ids refactor: use elif instead of if * feat: handle when api return None of api_account_ids * feat: skip validation of choices (not provided) * feat: filter dict config by regex condition * refactor: update of api_account_ids * remove: not used class AccountIdsConfiguration * remove: missed import class * remove: not used import * test:refactor: test_auth0_client * feat: new config of TredeStation brokerage in README * refactor: change spacing * feat: class Accounts in auth0_client * feat: skip choice type without choices * feat: new object account in Auth0 model refactor: parsing of new object Auth0 test:refactor: use new mock object of Auth0 * refactor: QCAuth0Authorization model * test:feat: add alpaca configuration test * remove: trade-station-account-type parameter (deprecated) * feat: add filter_dependency flag * refactor: remove optional in trade-station-account-id
- Loading branch information
Showing
6 changed files
with
166 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,76 @@ | ||
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
# Lean CLI v1.0. Copyright 2021 QuantConnect Corporation. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import responses | ||
from unittest import mock | ||
from lean.constants import API_BASE_URL | ||
from lean.components.api.api_client import APIClient | ||
from lean.components.util.http_client import HTTPClient | ||
|
||
|
||
@responses.activate | ||
def test_auth0client_trade_station() -> None: | ||
api_clint = APIClient(mock.Mock(), HTTPClient(mock.Mock()), user_id="123", api_token="abc") | ||
|
||
responses.add( | ||
responses.POST, | ||
f"{API_BASE_URL}live/auth0/read", | ||
json={ | ||
"authorization": { | ||
"trade-station-client-id": "123", | ||
"trade-station-refresh-token": "456", | ||
"accounts": [ | ||
{"id": "11223344", "name": "11223344 | Margin | USD"}, | ||
{"id": "55667788", "name": "55667788 | Futures | USD"} | ||
] | ||
}, | ||
"success": "true"}, | ||
status=200 | ||
) | ||
|
||
brokerage_id = "TestBrokerage" | ||
|
||
result = api_clint.auth0.read(brokerage_id) | ||
|
||
assert result | ||
assert result.authorization | ||
assert len(result.authorization) > 0 | ||
assert len(result.get_authorization_config_without_account()) > 0 | ||
assert len(result.get_account_ids()) > 0 | ||
|
||
|
||
@responses.activate | ||
def test_auth0client_alpaca() -> None: | ||
api_clint = APIClient(mock.Mock(), HTTPClient(mock.Mock()), user_id="123", api_token="abc") | ||
|
||
responses.add( | ||
responses.POST, | ||
f"{API_BASE_URL}live/auth0/read", | ||
json={ | ||
"authorization": { | ||
"alpaca-access-token": "XXXX-XXX-XXX-XXX-XXXXX-XX", | ||
"accounts": [{"id": "XXXX-XXX-XXX-XXX-XXXXX-XX", "name": " |USD"}] | ||
}, | ||
"success": "true"}, | ||
status=200 | ||
) | ||
|
||
brokerage_id = "TestBrokerage" | ||
|
||
result = api_clint.auth0.read(brokerage_id) | ||
|
||
assert result | ||
assert result.authorization | ||
assert len(result.authorization) > 0 | ||
assert len(result.get_authorization_config_without_account()) > 0 | ||
assert len(result.get_account_ids()) > 0 |