Skip to content

Commit

Permalink
Merge pull request #234 from jhonabreul/update-project-name-rules
Browse files Browse the repository at this point in the history
Allow - and _ in project name
  • Loading branch information
Martin-Molinero authored Nov 21, 2022
2 parents c94708b + b8fd16c commit 40c0eea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lean/components/util/path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def is_name_valid(self, name: str) -> bool:
:return: True if the name is valid on Windows operating system, False if not
"""
import re
return re.match('^[a-zA-Z0-9\\s/]*$', name)
return re.match('^[-_a-zA-Z0-9\\s/]*$', name) is not None

def is_path_valid(self, path: Path) -> bool:
"""Returns whether a path is valid on the current operating system.
Expand Down
3 changes: 0 additions & 3 deletions tests/commands/cloud/live/test_cloud_live_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def test_cloud_live_deploy_with_notifications(notice_method: str, configs: str)
("Trading Technologies", "USD:100"),
("Binance", "USD:100"),
("Bitfinex", "USD:100"),
("FTX", "USD:100"),
("Coinbase Pro", "USD:100"),
("Interactive Brokers", "USD:100"),
("Kraken", "USD:100"),
Expand Down Expand Up @@ -250,8 +249,6 @@ def test_cloud_live_deploy_with_live_cash_balance(brokerage: str, cash: str) ->
("Binance", "A:A 2T:1:145.1"),
("Bitfinex", ""),
("Bitfinex", "A:A 2T:1:145.1"),
("FTX", ""),
("FTX", "A:A 2T:1:145.1"),
("Coinbase Pro", ""),
("Coinbase Pro", "A:A 2T:1:145.1"),
("Interactive Brokers", ""),
Expand Down
29 changes: 2 additions & 27 deletions tests/commands/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,6 @@ def test_live_aborts_when_lean_config_is_missing_properties(target: str, replace
"kraken-api-secret": "abc",
"kraken-verification-tier": "starter",
},
"FTX": {
"ftxus-api-key": "abc",
"ftxus-api-secret": "abc",
"ftxus-account-tier": "tier1",
"ftx-api-key": "abc",
"ftx-api-secret": "abc",
"ftx-account-tier": "tier1",
"ftx-exchange-name": "FTX",
},
"Trading Technologies": {
"tt-user-name": "abc",
"tt-session-password": "abc",
Expand Down Expand Up @@ -334,7 +325,6 @@ def test_live_aborts_when_lean_config_is_missing_properties(target: str, replace
"Samco": brokerage_required_options["Samco"],
"Terminal Link": brokerage_required_options["Terminal Link"],
"Kraken": brokerage_required_options["Kraken"],
"FTX": brokerage_required_options["FTX"],
}


Expand Down Expand Up @@ -542,13 +532,6 @@ def test_live_non_interactive_falls_back_to_lean_config_for_brokerage_settings(b
if brokerage == "Binance":
data_feed = "Bitfinex"
options.extend(["--bitfinex-api-key", "123", "--bitfinex-api-secret", "456"])
elif brokerage == "FTX":
data_feed = "Binance"
options.extend(["--ftx-exchange-name", "FTXUS",
"--binance-exchange-name", "binance",
"--binance-api-key", "123",
"--binance-api-secret", "456",
"--binance-use-testnet", "live"])
else:
data_feed = "Binance"
options.extend(["--binance-exchange-name", "binance",
Expand Down Expand Up @@ -604,9 +587,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_data_feed_settings(d
"job-organization-id": "abc"
}))

if data_feed == "FTX":
options.extend(["--ftx-exchange-name", "FTX"])
elif data_feed == "Binance":
if data_feed == "Binance":
options.extend(["--binance-exchange-name", "binance"])

result = CliRunner().invoke(lean, ["live", "Python Project",
Expand Down Expand Up @@ -654,9 +635,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_multiple_data_feed_s
"job-organization-id": "abc"
}))

if data_feed1 == "FTX" or data_feed2 == "FTX":
options.extend(["--ftx-exchange-name", "FTX"])
elif data_feed1 == "Binance" or data_feed2 == "Binance":
if data_feed1 == "Binance" or data_feed2 == "Binance":
options.extend(["--binance-exchange-name", "binance"])

result = CliRunner().invoke(lean, ["live", "Python Project",
Expand Down Expand Up @@ -772,8 +751,6 @@ def test_live_passes_custom_python_venv_to_lean_runner_when_given_as_option(pyth
("Binance", "USD:100"),
("Bitfinex", ""),
("Bitfinex", "USD:100"),
("FTX", ""),
("FTX", "USD:100"),
("Coinbase Pro", ""),
("Coinbase Pro", "USD:100"),
("Interactive Brokers", ""),
Expand Down Expand Up @@ -836,8 +813,6 @@ def test_live_passes_live_cash_balance_to_lean_runner_when_given_as_option(broke
("Binance", "A:A 2T:1:145.1"),
("Bitfinex", ""),
("Bitfinex", "A:A 2T:1:145.1"),
("FTX", ""),
("FTX", "A:A 2T:1:145.1"),
("Coinbase Pro", ""),
("Coinbase Pro", "A:A 2T:1:145.1"),
("Interactive Brokers", ""),
Expand Down
15 changes: 15 additions & 0 deletions tests/components/util/test_path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,18 @@ def test_is_path_valid_windows(path: str, valid: bool) -> None:
path_manager = PathManager(PlatformManager())

assert path_manager.is_path_valid(Path.cwd() / path) == valid


@pytest.mark.parametrize("name, valid", [("123", True),
("abc", True),
("1a2b3c", True),
("a-1_b-2", True),
("1-a 2_b 3-c", True),
("1 a/2_b/3-c", True),
("1a2b3c$", False),
("abc:123", False),
("abc.def", False)])
def test_is_name_valid(name: str, valid: bool) -> None:
path_manager = PathManager(PlatformManager())

assert path_manager.is_name_valid(name) == valid

0 comments on commit 40c0eea

Please sign in to comment.