From c28740cfb16943977c2051df19dc3e28864571a5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Mar 2024 13:43:44 +0200 Subject: [PATCH] Update tests --- tests/commands/pkg/test_outdated.py | 6 +++--- tests/commands/pkg/test_update.py | 12 +++++++----- tests/commands/test_lib.py | 30 ++++++++++++++--------------- tests/commands/test_lib_complex.py | 8 ++++---- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/commands/pkg/test_outdated.py b/tests/commands/pkg/test_outdated.py index 91180b42..c13d4d2a 100644 --- a/tests/commands/pkg/test_outdated.py +++ b/tests/commands/pkg/test_outdated.py @@ -24,7 +24,7 @@ PROJECT_OUTDATED_CONFIG_TPL = """ platform = platformio/atmelavr@^2 framework = arduino board = attiny88 -lib_deps = milesburton/DallasTemperature@~3.8.0 +lib_deps = milesburton/DallasTemperature@~3.9.0 """ PROJECT_UPDATED_CONFIG_TPL = """ @@ -32,7 +32,7 @@ PROJECT_UPDATED_CONFIG_TPL = """ platform = platformio/atmelavr@<4 framework = arduino board = attiny88 -lib_deps = milesburton/DallasTemperature@^3.8.0 +lib_deps = milesburton/DallasTemperature@^3.9.0 """ @@ -56,7 +56,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path): re.MULTILINE, ) assert re.search( - r"^DallasTemperature\s+3\.8\.1\s+3\.\d+\.\d+\s+3\.\d+\.\d+\s+Library\s+devkit", + r"^DallasTemperature\s+3\.\.1\s+3\.\d+\.\d+\s+3\.\d+\.\d+\s+Library\s+devkit", result.output, re.MULTILINE, ) diff --git a/tests/commands/pkg/test_update.py b/tests/commands/pkg/test_update.py index 5656daac..1fd953ed 100644 --- a/tests/commands/pkg/test_update.py +++ b/tests/commands/pkg/test_update.py @@ -26,12 +26,14 @@ from platformio.package.manager.tool import ToolPackageManager from platformio.package.meta import PackageSpec from platformio.project.config import ProjectConfig +DALLASTEMPERATURE_LATEST_VERSION = "3.11.0" + PROJECT_OUTDATED_CONFIG_TPL = """ [env:devkit] platform = platformio/atmelavr@^2 framework = arduino board = attiny88 -lib_deps = milesburton/DallasTemperature@~3.8.0 +lib_deps = milesburton/DallasTemperature@^3.8.0 """ PROJECT_UPDATED_CONFIG_TPL = """ @@ -162,7 +164,7 @@ def test_project( os.path.join(config.get("platformio", "libdeps_dir"), "devkit") ) assert pkgs_to_specs(lm.get_installed()) == [ - PackageSpec("DallasTemperature@3.8.1"), + PackageSpec(f"DallasTemperature@{DALLASTEMPERATURE_LATEST_VERSION}"), PackageSpec( "OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire") ), @@ -176,7 +178,7 @@ def test_project( PackageSpec("toolchain-atmelavr@1.50400.190710"), ] assert config.get("env:devkit", "lib_deps") == [ - "milesburton/DallasTemperature@~3.8.0" + "milesburton/DallasTemperature@^3.8.0" ] # update packages @@ -227,7 +229,7 @@ def test_custom_project_libraries( project_dir = tmp_path / "project" project_dir.mkdir() (project_dir / "platformio.ini").write_text(PROJECT_OUTDATED_CONFIG_TPL) - spec = "milesburton/DallasTemperature@~3.8.0" + spec = "milesburton/DallasTemperature@^3.8.0" result = clirunner.invoke( package_install_cmd, ["-d", str(project_dir), "-e", "devkit", "-l", spec], @@ -240,7 +242,7 @@ def test_custom_project_libraries( os.path.join(config.get("platformio", "libdeps_dir"), "devkit") ) assert pkgs_to_specs(lm.get_installed()) == [ - PackageSpec("DallasTemperature@3.8.1"), + PackageSpec(f"DallasTemperature@{DALLASTEMPERATURE_LATEST_VERSION}"), PackageSpec( "OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire") ), diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index 8f47ad61..221d788f 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -42,7 +42,7 @@ board = devkit framework = foo lib_deps = CustomLib - ArduinoJson @ 5.10.1 + ArduinoJson @ 6.18.5 """ ) result = clirunner.invoke( @@ -163,7 +163,7 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory storage_dir = tmpdir_factory.mktemp("test-updates") result = clirunner.invoke( cmd_lib, - ["-d", str(storage_dir), "install", "ArduinoJson @ 5.10.1", "Blynk @ ~0.5.0"], + ["-d", str(storage_dir), "install", "ArduinoJson @ 6.18.5", "Blynk @ ~1.2"], ) validate_cliresult(result) result = clirunner.invoke( @@ -173,17 +173,17 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory outdated = json.loads(result.stdout) assert len(outdated) == 2 # ArduinoJson - assert outdated[0]["version"] == "5.10.1" + assert outdated[0]["version"] == "6.18.5" assert outdated[0]["versionWanted"] is None assert semantic_version.Version( outdated[0]["versionLatest"] - ) > semantic_version.Version("6.16.0") + ) > semantic_version.Version("6.18.5") # Blynk - assert outdated[1]["version"] == "0.5.4" + assert outdated[1]["version"] == "1.2.0" assert outdated[1]["versionWanted"] is None assert semantic_version.Version( outdated[1]["versionLatest"] - ) > semantic_version.Version("0.6.0") + ) > semantic_version.Version("1.2.0") # check with spec result = clirunner.invoke( @@ -194,19 +194,19 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory "update", "--dry-run", "--json-output", - "ArduinoJson @ ^5", + "ArduinoJson @ ^6", ], ) validate_cliresult(result) outdated = json.loads(result.stdout) - assert outdated[0]["version"] == "5.10.1" - assert outdated[0]["versionWanted"] == "5.13.4" + assert outdated[0]["version"] == "6.18.5" + assert outdated[0]["versionWanted"] == "6.21.5" assert semantic_version.Version( outdated[0]["versionLatest"] ) > semantic_version.Version("6.16.0") # update with spec result = clirunner.invoke( - cmd_lib, ["-d", str(storage_dir), "update", "--silent", "ArduinoJson @ ^5.10.1"] + cmd_lib, ["-d", str(storage_dir), "update", "--silent", "ArduinoJson @ ^6.18.5"] ) validate_cliresult(result) result = clirunner.invoke( @@ -215,12 +215,12 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory validate_cliresult(result) items = json.loads(result.stdout) assert len(items) == 2 - assert items[0]["version"] == "5.13.4" - assert items[1]["version"] == "0.5.4" + assert items[0]["version"] == "6.21.5" + assert items[1]["version"] == "1.2.0" # Check incompatible result = clirunner.invoke( - cmd_lib, ["-d", str(storage_dir), "update", "--dry-run", "ArduinoJson @ ^5"] + cmd_lib, ["-d", str(storage_dir), "update", "--dry-run", "ArduinoJson @ ^6"] ) with pytest.raises( AssertionError, @@ -228,7 +228,7 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory ): validate_cliresult(result) result = clirunner.invoke( - cmd_lib, ["-d", str(storage_dir), "update", "ArduinoJson @ ^5"] + cmd_lib, ["-d", str(storage_dir), "update", "ArduinoJson @ ^6"] ) validate_cliresult(result) - assert "ArduinoJson@5.13.4 is already up-to-date" in result.stdout + assert "ArduinoJson@6.21.5 is already up-to-date" in result.stdout diff --git a/tests/commands/test_lib_complex.py b/tests/commands/test_lib_complex.py index a4e8faff..55563be5 100644 --- a/tests/commands/test_lib_complex.py +++ b/tests/commands/test_lib_complex.py @@ -61,7 +61,7 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_cor items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()] items2 = [ "ArduinoJson", - "fArduinoJson@{ARDUINO_JSON_VERSION}", + f"ArduinoJson@{ARDUINO_JSON_VERSION}", "NeoPixelBus", "AsyncMqttClient", "ESPAsyncTCP", @@ -189,7 +189,7 @@ def test_global_lib_list(clirunner, validate_cliresult): for n in ( "__pkg_dir", '"__src_url": "git+https://github.com/gioblu/PJON.git#6.2"', - '"version": "5.10.1"', + f'"version": "{ARDUINO_JSON_VERSION}"', ) ) items1 = [i["name"] for i in json.loads(result.output)] @@ -219,13 +219,13 @@ def test_global_lib_list(clirunner, validate_cliresult): ] versions2 = [ "ArduinoJson@5.8.2", - "ArduinoJson@5.10.1", + f"ArduinoJson@{ARDUINO_JSON_VERSION}", "AsyncMqttClient@0.8.2", "NeoPixelBus@2.7.3", "PJON@6.2.0+sha.07fe9aa", "PJON@3.0.0+sha.1fb26fd", "PubSubClient@2.6.0+sha.bef5814", - "Adafruit PN532@1.2.0", + "Adafruit PN532@1.3.2", ] assert set(versions1) >= set(versions2)