From 62b65e53076805cb807f07d8d972197c98dbb6c2 Mon Sep 17 00:00:00 2001 From: Francesco Calcavecchia Date: Tue, 13 Feb 2024 17:59:44 +0100 Subject: [PATCH] Find next version robust to dash or underscore (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * find latest version is now robust to use of "-" and "_" without distinction * update changelog * readme typo --------- Co-authored-by: Ádám Juhász <91451893+ajuhasz10@users.noreply.github.com> --- CHANGELOG.md | 6 + src/dac/_version_management.py | 5 +- test/data/__init__.py | 8 ++ ...nvesting_algorithm_framework_with_dash.txt | 104 ++++++++++++++++++ ...ng_algorithm_framework_with_underscore.txt | 104 ++++++++++++++++++ .../_version_management/find_latest_test.py | 54 +++++++++ 6 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 test/data/pip_log/log_for_investing_algorithm_framework_with_dash.txt create mode 100644 test/data/pip_log/log_for_investing_algorithm_framework_with_underscore.txt create mode 100644 test/unit_test/_version_management/find_latest_test.py diff --git a/CHANGELOG.md b/CHANGELOG.md index bfaffaf..2dd301f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Anything MAY change at any time. The public API SHOULD NOT be considered stable."). While in this phase, we will denote breaking changes with a minor increase. +## 0.4.2 + +### Fixed + +* `dac next-version` is able to find the existing version of a package irrespectively of the use of `-` or `_` as a separator. + ## 0.4.1 ### Added diff --git a/src/dac/_version_management.py b/src/dac/_version_management.py index 769da62..22ac57c 100644 --- a/src/dac/_version_management.py +++ b/src/dac/_version_management.py @@ -16,9 +16,10 @@ def find_latest_version(pkg_name: str, major: Optional[int] = None) -> str: ], stderr=subprocess.DEVNULL, ) - last_line = output.decode("utf-8").splitlines()[-1] + output_lines = output.decode("utf-8").splitlines() + would_install_line = [line for line in output_lines if "Would install" in line][0] regex_rule = f"{pkg_name.replace('_', '-')}-{major if major is not None else ''}.[^ ]+" - match = re.search(regex_rule, last_line) + match = re.search(regex_rule, would_install_line.replace("_", "-")) assert match is not None return match[0][len(f"{pkg_name}-") :] diff --git a/test/data/__init__.py b/test/data/__init__.py index e9732be..7161205 100644 --- a/test/data/__init__.py +++ b/test/data/__init__.py @@ -89,6 +89,14 @@ def get_sample_pandas_df() -> pd.DataFrame: ) +def get_pip_log_with_dash() -> str: + return (Path(__file__).parent / "pip_log" / "log_for_investing_algorithm_framework_with_dash.txt").read_text() + + +def get_pip_log_with_underscore() -> str: + return (Path(__file__).parent / "pip_log" / "log_for_investing_algorithm_framework_with_underscore.txt").read_text() + + def generate_random_project_name() -> str: return "".join(random.choice(string.ascii_lowercase) for _ in range(16)) diff --git a/test/data/pip_log/log_for_investing_algorithm_framework_with_dash.txt b/test/data/pip_log/log_for_investing_algorithm_framework_with_dash.txt new file mode 100644 index 0000000..f1f74a2 --- /dev/null +++ b/test/data/pip_log/log_for_investing_algorithm_framework_with_dash.txt @@ -0,0 +1,104 @@ +Looking in indexes: https://****:****@****/simple, https://pypi.org/simple +Collecting investing-algorithm-framework + Downloading investing_algorithm_framework-2.3.2-py3-none-any.whl.metadata (29 kB) +Requirement already satisfied: wrapt>=1.11.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (1.15.0) +Collecting Flask>=2.3.2 (from investing-algorithm-framework) + Downloading flask-3.0.2-py3-none-any.whl.metadata (3.6 kB) +Collecting Flask-Migrate>=2.6.0 (from investing-algorithm-framework) + Downloading Flask_Migrate-4.0.5-py3-none-any.whl.metadata (3.1 kB) +Collecting Flask-Cors>=3.0.9 (from investing-algorithm-framework) + Downloading Flask_Cors-4.0.0-py2.py3-none-any.whl.metadata (5.4 kB) +Collecting SQLAlchemy>=2.0.18 (from investing-algorithm-framework) + Downloading SQLAlchemy-2.0.26-cp310-cp310-macosx_11_0_arm64.whl.metadata (9.6 kB) +Collecting marshmallow>=3.5.0 (from investing-algorithm-framework) + Using cached marshmallow-3.20.2-py3-none-any.whl.metadata (7.5 kB) +Requirement already satisfied: setuptools>=60.9.0 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (68.0.0) +Collecting ccxt>=3.0.57 (from investing-algorithm-framework) + Downloading ccxt-4.2.44-py2.py3-none-any.whl.metadata (107 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 107.6/107.6 kB 8.1 MB/s eta 0:00:00 +Requirement already satisfied: python-dateutil>=2.8.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.8.2) +Requirement already satisfied: MarkupSafe>=2.1.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.1.3) +Collecting dependency-injector>=4.40.0 (from investing-algorithm-framework) + Downloading dependency-injector-4.41.0.tar.gz (913 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 913.2/913.2 kB 29.1 MB/s eta 0:00:00 + Preparing metadata (setup.py) ... done +Collecting schedule>=1.1.0 (from investing-algorithm-framework) + Downloading schedule-1.2.1-py2.py3-none-any.whl.metadata (3.3 kB) +Requirement already satisfied: pandas>=2.0.0 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.1.4) +Collecting tqdm>=4.66.1 (from investing-algorithm-framework) + Downloading tqdm-4.66.2-py3-none-any.whl.metadata (57 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 kB 7.5 MB/s eta 0:00:00 +Collecting tabulate>=0.9.0 (from investing-algorithm-framework) + Using cached tabulate-0.9.0-py3-none-any.whl (35 kB) +Collecting polars==0.20.5 (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) + Downloading polars-0.20.5-cp38-abi3-macosx_11_0_arm64.whl.metadata (15 kB) +Requirement already satisfied: numpy>=1.16.0 in ./venv/lib/python3.10/site-packages (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) (1.26.1) +Requirement already satisfied: pyarrow>=7.0.0 in ./venv/lib/python3.10/site-packages (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) (11.0.0) +Requirement already satisfied: certifi>=2018.1.18 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (2023.7.22) +Requirement already satisfied: requests>=2.18.4 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (2.28.2) +Requirement already satisfied: cryptography>=2.6.1 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (41.0.7) +Requirement already satisfied: typing-extensions>=4.4.0 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (4.8.0) +Requirement already satisfied: aiohttp>=3.8 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (3.9.1) +Collecting aiodns>=1.1.1 (from ccxt>=3.0.57->investing-algorithm-framework) + Downloading aiodns-3.1.1-py3-none-any.whl.metadata (4.0 kB) +Requirement already satisfied: yarl>=1.7.2 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (1.9.4) +Requirement already satisfied: six<=1.16.0,>=1.7.0 in ./venv/lib/python3.10/site-packages (from dependency-injector>=4.40.0->investing-algorithm-framework) (1.16.0) +Collecting Werkzeug>=3.0.0 (from Flask>=2.3.2->investing-algorithm-framework) + Downloading werkzeug-3.0.1-py3-none-any.whl.metadata (4.1 kB) +Requirement already satisfied: Jinja2>=3.1.2 in ./venv/lib/python3.10/site-packages (from Flask>=2.3.2->investing-algorithm-framework) (3.1.2) +Collecting itsdangerous>=2.1.2 (from Flask>=2.3.2->investing-algorithm-framework) + Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB) +Requirement already satisfied: click>=8.1.3 in ./venv/lib/python3.10/site-packages (from Flask>=2.3.2->investing-algorithm-framework) (8.1.6) +Collecting blinker>=1.6.2 (from Flask>=2.3.2->investing-algorithm-framework) + Downloading blinker-1.7.0-py3-none-any.whl.metadata (1.9 kB) +Collecting Flask-SQLAlchemy>=1.0 (from Flask-Migrate>=2.6.0->investing-algorithm-framework) + Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl.metadata (3.4 kB) +Collecting alembic>=1.9.0 (from Flask-Migrate>=2.6.0->investing-algorithm-framework) + Using cached alembic-1.13.1-py3-none-any.whl.metadata (7.4 kB) +Requirement already satisfied: packaging>=17.0 in ./venv/lib/python3.10/site-packages (from marshmallow>=3.5.0->investing-algorithm-framework) (23.2) +Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.10/site-packages (from pandas>=2.0.0->investing-algorithm-framework) (2023.3.post1) +Requirement already satisfied: tzdata>=2022.1 in ./venv/lib/python3.10/site-packages (from pandas>=2.0.0->investing-algorithm-framework) (2023.4) +Collecting pycares>=4.0.0 (from aiodns>=1.1.1->ccxt>=3.0.57->investing-algorithm-framework) + Downloading pycares-4.4.0-cp310-cp310-macosx_10_9_universal2.whl.metadata (4.1 kB) +Requirement already satisfied: attrs>=17.3.0 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (23.2.0) +Requirement already satisfied: multidict<7.0,>=4.5 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (6.0.4) +Requirement already satisfied: frozenlist>=1.1.1 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (1.4.1) +Requirement already satisfied: aiosignal>=1.1.2 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (1.3.1) +Requirement already satisfied: async-timeout<5.0,>=4.0 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (4.0.3) +Collecting Mako (from alembic>=1.9.0->Flask-Migrate>=2.6.0->investing-algorithm-framework) + Downloading Mako-1.3.2-py3-none-any.whl.metadata (2.9 kB) +Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.10/site-packages (from cryptography>=2.6.1->ccxt>=3.0.57->investing-algorithm-framework) (1.16.0) +Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (3.2.0) +Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (3.4) +Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (1.26.18) +Requirement already satisfied: pycparser in ./venv/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.6.1->ccxt>=3.0.57->investing-algorithm-framework) (2.21) +Downloading investing_algorithm_framework-2.3.2-py3-none-any.whl (115 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.4/115.4 kB 17.1 MB/s eta 0:00:00 +Downloading polars-0.20.5-cp38-abi3-macosx_11_0_arm64.whl (24.4 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 24.4/24.4 MB 25.2 MB/s eta 0:00:00 +Downloading ccxt-4.2.44-py2.py3-none-any.whl (4.2 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 27.0 MB/s eta 0:00:00 +Downloading flask-3.0.2-py3-none-any.whl (101 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.3/101.3 kB 12.5 MB/s eta 0:00:00 +Downloading Flask_Cors-4.0.0-py2.py3-none-any.whl (14 kB) +Downloading Flask_Migrate-4.0.5-py3-none-any.whl (21 kB) +Using cached marshmallow-3.20.2-py3-none-any.whl (49 kB) +Downloading schedule-1.2.1-py2.py3-none-any.whl (11 kB) +Downloading SQLAlchemy-2.0.26-cp310-cp310-macosx_11_0_arm64.whl (2.1 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 25.2 MB/s eta 0:00:00 +Downloading tqdm-4.66.2-py3-none-any.whl (78 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 11.9 MB/s eta 0:00:00 +Downloading aiodns-3.1.1-py3-none-any.whl (5.4 kB) +Using cached alembic-1.13.1-py3-none-any.whl (233 kB) +Downloading blinker-1.7.0-py3-none-any.whl (13 kB) +Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl (25 kB) +Downloading werkzeug-3.0.1-py3-none-any.whl (226 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 226.7/226.7 kB 17.4 MB/s eta 0:00:00 +Downloading pycares-4.4.0-cp310-cp310-macosx_10_9_universal2.whl (136 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 136.8/136.8 kB 18.0 MB/s eta 0:00:00 +Downloading Mako-1.3.2-py3-none-any.whl (78 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.7/78.7 kB 10.4 MB/s eta 0:00:00 +Would install Flask-3.0.2 Flask-Cors-4.0.0 Flask-Migrate-4.0.5 Flask-SQLAlchemy-3.1.1 Mako-1.3.2 SQLAlchemy-2.0.26 Werkzeug-3.0.1 aiodns-3.1.1 alembic-1.13.1 blinker-1.7.0 ccxt-4.2.44 dependency-injector-4.41.0 investing-algorithm-framework-2.3.2 itsdangerous-2.1.2 marshmallow-3.20.2 polars-0.20.5 pycares-4.4.0 schedule-1.2.1 tabulate-0.9.0 tqdm-4.66.2 + +[notice] A new release of pip is available: 23.3.2 -> 24.0 +[notice] To update, run: pip install --upgrade pip diff --git a/test/data/pip_log/log_for_investing_algorithm_framework_with_underscore.txt b/test/data/pip_log/log_for_investing_algorithm_framework_with_underscore.txt new file mode 100644 index 0000000..c398faf --- /dev/null +++ b/test/data/pip_log/log_for_investing_algorithm_framework_with_underscore.txt @@ -0,0 +1,104 @@ +Looking in indexes: https://****:****@****/simple, https://pypi.org/simple +Collecting investing-algorithm-framework + Downloading investing_algorithm_framework-2.3.2-py3-none-any.whl.metadata (29 kB) +Requirement already satisfied: wrapt>=1.11.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (1.15.0) +Collecting Flask>=2.3.2 (from investing-algorithm-framework) + Downloading flask-3.0.2-py3-none-any.whl.metadata (3.6 kB) +Collecting Flask-Migrate>=2.6.0 (from investing-algorithm-framework) + Downloading Flask_Migrate-4.0.5-py3-none-any.whl.metadata (3.1 kB) +Collecting Flask-Cors>=3.0.9 (from investing-algorithm-framework) + Downloading Flask_Cors-4.0.0-py2.py3-none-any.whl.metadata (5.4 kB) +Collecting SQLAlchemy>=2.0.18 (from investing-algorithm-framework) + Downloading SQLAlchemy-2.0.26-cp310-cp310-macosx_11_0_arm64.whl.metadata (9.6 kB) +Collecting marshmallow>=3.5.0 (from investing-algorithm-framework) + Using cached marshmallow-3.20.2-py3-none-any.whl.metadata (7.5 kB) +Requirement already satisfied: setuptools>=60.9.0 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (68.0.0) +Collecting ccxt>=3.0.57 (from investing-algorithm-framework) + Downloading ccxt-4.2.44-py2.py3-none-any.whl.metadata (107 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 107.6/107.6 kB 8.1 MB/s eta 0:00:00 +Requirement already satisfied: python-dateutil>=2.8.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.8.2) +Requirement already satisfied: MarkupSafe>=2.1.2 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.1.3) +Collecting dependency-injector>=4.40.0 (from investing-algorithm-framework) + Downloading dependency-injector-4.41.0.tar.gz (913 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 913.2/913.2 kB 29.1 MB/s eta 0:00:00 + Preparing metadata (setup.py) ... done +Collecting schedule>=1.1.0 (from investing-algorithm-framework) + Downloading schedule-1.2.1-py2.py3-none-any.whl.metadata (3.3 kB) +Requirement already satisfied: pandas>=2.0.0 in ./venv/lib/python3.10/site-packages (from investing-algorithm-framework) (2.1.4) +Collecting tqdm>=4.66.1 (from investing-algorithm-framework) + Downloading tqdm-4.66.2-py3-none-any.whl.metadata (57 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 kB 7.5 MB/s eta 0:00:00 +Collecting tabulate>=0.9.0 (from investing-algorithm-framework) + Using cached tabulate-0.9.0-py3-none-any.whl (35 kB) +Collecting polars==0.20.5 (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) + Downloading polars-0.20.5-cp38-abi3-macosx_11_0_arm64.whl.metadata (15 kB) +Requirement already satisfied: numpy>=1.16.0 in ./venv/lib/python3.10/site-packages (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) (1.26.1) +Requirement already satisfied: pyarrow>=7.0.0 in ./venv/lib/python3.10/site-packages (from polars[numpy,pandas]==0.20.5->investing-algorithm-framework) (11.0.0) +Requirement already satisfied: certifi>=2018.1.18 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (2023.7.22) +Requirement already satisfied: requests>=2.18.4 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (2.28.2) +Requirement already satisfied: cryptography>=2.6.1 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (41.0.7) +Requirement already satisfied: typing-extensions>=4.4.0 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (4.8.0) +Requirement already satisfied: aiohttp>=3.8 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (3.9.1) +Collecting aiodns>=1.1.1 (from ccxt>=3.0.57->investing-algorithm-framework) + Downloading aiodns-3.1.1-py3-none-any.whl.metadata (4.0 kB) +Requirement already satisfied: yarl>=1.7.2 in ./venv/lib/python3.10/site-packages (from ccxt>=3.0.57->investing-algorithm-framework) (1.9.4) +Requirement already satisfied: six<=1.16.0,>=1.7.0 in ./venv/lib/python3.10/site-packages (from dependency-injector>=4.40.0->investing-algorithm-framework) (1.16.0) +Collecting Werkzeug>=3.0.0 (from Flask>=2.3.2->investing-algorithm-framework) + Downloading werkzeug-3.0.1-py3-none-any.whl.metadata (4.1 kB) +Requirement already satisfied: Jinja2>=3.1.2 in ./venv/lib/python3.10/site-packages (from Flask>=2.3.2->investing-algorithm-framework) (3.1.2) +Collecting itsdangerous>=2.1.2 (from Flask>=2.3.2->investing-algorithm-framework) + Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB) +Requirement already satisfied: click>=8.1.3 in ./venv/lib/python3.10/site-packages (from Flask>=2.3.2->investing-algorithm-framework) (8.1.6) +Collecting blinker>=1.6.2 (from Flask>=2.3.2->investing-algorithm-framework) + Downloading blinker-1.7.0-py3-none-any.whl.metadata (1.9 kB) +Collecting Flask-SQLAlchemy>=1.0 (from Flask-Migrate>=2.6.0->investing-algorithm-framework) + Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl.metadata (3.4 kB) +Collecting alembic>=1.9.0 (from Flask-Migrate>=2.6.0->investing-algorithm-framework) + Using cached alembic-1.13.1-py3-none-any.whl.metadata (7.4 kB) +Requirement already satisfied: packaging>=17.0 in ./venv/lib/python3.10/site-packages (from marshmallow>=3.5.0->investing-algorithm-framework) (23.2) +Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.10/site-packages (from pandas>=2.0.0->investing-algorithm-framework) (2023.3.post1) +Requirement already satisfied: tzdata>=2022.1 in ./venv/lib/python3.10/site-packages (from pandas>=2.0.0->investing-algorithm-framework) (2023.4) +Collecting pycares>=4.0.0 (from aiodns>=1.1.1->ccxt>=3.0.57->investing-algorithm-framework) + Downloading pycares-4.4.0-cp310-cp310-macosx_10_9_universal2.whl.metadata (4.1 kB) +Requirement already satisfied: attrs>=17.3.0 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (23.2.0) +Requirement already satisfied: multidict<7.0,>=4.5 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (6.0.4) +Requirement already satisfied: frozenlist>=1.1.1 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (1.4.1) +Requirement already satisfied: aiosignal>=1.1.2 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (1.3.1) +Requirement already satisfied: async-timeout<5.0,>=4.0 in ./venv/lib/python3.10/site-packages (from aiohttp>=3.8->ccxt>=3.0.57->investing-algorithm-framework) (4.0.3) +Collecting Mako (from alembic>=1.9.0->Flask-Migrate>=2.6.0->investing-algorithm-framework) + Downloading Mako-1.3.2-py3-none-any.whl.metadata (2.9 kB) +Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.10/site-packages (from cryptography>=2.6.1->ccxt>=3.0.57->investing-algorithm-framework) (1.16.0) +Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (3.2.0) +Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (3.4) +Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./venv/lib/python3.10/site-packages (from requests>=2.18.4->ccxt>=3.0.57->investing-algorithm-framework) (1.26.18) +Requirement already satisfied: pycparser in ./venv/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.6.1->ccxt>=3.0.57->investing-algorithm-framework) (2.21) +Downloading investing_algorithm_framework-2.3.2-py3-none-any.whl (115 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.4/115.4 kB 17.1 MB/s eta 0:00:00 +Downloading polars-0.20.5-cp38-abi3-macosx_11_0_arm64.whl (24.4 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 24.4/24.4 MB 25.2 MB/s eta 0:00:00 +Downloading ccxt-4.2.44-py2.py3-none-any.whl (4.2 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 27.0 MB/s eta 0:00:00 +Downloading flask-3.0.2-py3-none-any.whl (101 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.3/101.3 kB 12.5 MB/s eta 0:00:00 +Downloading Flask_Cors-4.0.0-py2.py3-none-any.whl (14 kB) +Downloading Flask_Migrate-4.0.5-py3-none-any.whl (21 kB) +Using cached marshmallow-3.20.2-py3-none-any.whl (49 kB) +Downloading schedule-1.2.1-py2.py3-none-any.whl (11 kB) +Downloading SQLAlchemy-2.0.26-cp310-cp310-macosx_11_0_arm64.whl (2.1 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 25.2 MB/s eta 0:00:00 +Downloading tqdm-4.66.2-py3-none-any.whl (78 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 11.9 MB/s eta 0:00:00 +Downloading aiodns-3.1.1-py3-none-any.whl (5.4 kB) +Using cached alembic-1.13.1-py3-none-any.whl (233 kB) +Downloading blinker-1.7.0-py3-none-any.whl (13 kB) +Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl (25 kB) +Downloading werkzeug-3.0.1-py3-none-any.whl (226 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 226.7/226.7 kB 17.4 MB/s eta 0:00:00 +Downloading pycares-4.4.0-cp310-cp310-macosx_10_9_universal2.whl (136 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 136.8/136.8 kB 18.0 MB/s eta 0:00:00 +Downloading Mako-1.3.2-py3-none-any.whl (78 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.7/78.7 kB 10.4 MB/s eta 0:00:00 +Would install Flask-3.0.2 Flask-Cors-4.0.0 Flask-Migrate-4.0.5 Flask-SQLAlchemy-3.1.1 Mako-1.3.2 SQLAlchemy-2.0.26 Werkzeug-3.0.1 aiodns-3.1.1 alembic-1.13.1 blinker-1.7.0 ccxt-4.2.44 dependency-injector-4.41.0 investing_algorithm_framework-2.3.2 itsdangerous-2.1.2 marshmallow-3.20.2 polars-0.20.5 pycares-4.4.0 schedule-1.2.1 tabulate-0.9.0 tqdm-4.66.2 + +[notice] A new release of pip is available: 23.3.2 -> 24.0 +[notice] To update, run: pip install --upgrade pip diff --git a/test/unit_test/_version_management/find_latest_test.py b/test/unit_test/_version_management/find_latest_test.py new file mode 100644 index 0000000..25a6dca --- /dev/null +++ b/test/unit_test/_version_management/find_latest_test.py @@ -0,0 +1,54 @@ +import subprocess +from test.data import get_pip_log_with_dash, get_pip_log_with_underscore +from unittest.mock import MagicMock + +from dac._version_management import find_latest_version +from pytest import MonkeyPatch, fixture + + +def test_if_pkg_name_uses_dash_separator_and_pip_log_dash_then_correct_latest_version(mock_pip_output_with_dash: None): + latest_version = find_latest_version(pkg_name="investing-algorithm-framework") + assert latest_version == "2.3.2" + + +def test_if_pkg_name_uses_dash_separator_and_pip_log_underscore_then_correct_latest_version( + mock_pip_output_with_underscore: None, +): + latest_version = find_latest_version(pkg_name="investing-algorithm-framework") + assert latest_version == "2.3.2" + + +def test_if_pkg_name_uses_underscore_separator_and_pip_log_dash_then_correct_latest_version( + mock_pip_output_with_dash: None, +): + latest_version = find_latest_version(pkg_name="investing_algorithm_framework") + assert latest_version == "2.3.2" + + +def test_if_pkg_name_uses_underscore_separator_and_pip_log_underscore_then_correct_latest_version( + mock_pip_output_with_underscore: None, +): + latest_version = find_latest_version(pkg_name="investing_algorithm_framework") + assert latest_version == "2.3.2" + + +@fixture +def mock_pip_output_with_dash(monkeypatch: MonkeyPatch): + output = MagicMock() + output.decode.return_value = get_pip_log_with_dash() + + def return_foo(*args, **kwargs) -> str: + return output + + monkeypatch.setattr(subprocess, "check_output", return_foo) + + +@fixture +def mock_pip_output_with_underscore(monkeypatch: MonkeyPatch): + output = MagicMock() + output.decode.return_value = get_pip_log_with_underscore() + + def return_foo(*args, **kwargs) -> str: + return output + + monkeypatch.setattr(subprocess, "check_output", return_foo)