Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Mar 16, 2024
1 parent 6449115 commit 0f3dbe6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
21 changes: 11 additions & 10 deletions tests/commands/test_lib_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from platformio.util import strip_ansi_codes

PlatformioCLI.leftover_args = ["--json-output"] # hook for click
ARDUINO_JSON_VERSION = "6.21.5"


def test_search(clirunner, validate_cliresult):
Expand All @@ -44,10 +45,10 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_cor
"-g",
"install",
"64",
"ArduinoJson@~5.10.0",
"547@2.2.4",
"ArduinoJson@~6",
"547@2.7.3",
"AsyncMqttClient@<=0.8.2",
"Adafruit PN532@1.2.0",
"Adafruit PN532@1.3.2",
],
)
validate_cliresult(result)
Expand All @@ -60,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",
"[email protected]",
"fArduinoJson@{ARDUINO_JSON_VERSION}",
"NeoPixelBus",
"AsyncMqttClient",
"ESPAsyncTCP",
Expand All @@ -79,7 +80,7 @@ def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_core
"install",
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
"https://github.com/bblanchon/ArduinoJson/archive/[email protected]",
"SomeLib=https://dl.registry.platformio.org/download/milesburton/library/DallasTemperature/3.8.1/DallasTemperature-3.8.1.tar.gz",
"SomeLib=https://dl.registry.platformio.org/download/milesburton/library/DallasTemperature/3.11.0/DallasTemperature-3.11.0.tar.gz",
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
],
)
Expand Down Expand Up @@ -142,7 +143,7 @@ def test_install_duplicates( # pylint: disable=unused-argument
[
"-g",
"install",
"https://dl.registry.platformio.org/download/milesburton/library/DallasTemperature/3.8.1/DallasTemperature-3.8.1.tar.gz",
"https://dl.registry.platformio.org/download/milesburton/library/DallasTemperature/3.11.0/DallasTemperature-3.11.0.tar.gz",
],
)
validate_cliresult(result)
Expand Down Expand Up @@ -176,11 +177,11 @@ def test_global_lib_list(clirunner, validate_cliresult):
n in result.output
for n in (
"required: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
"ArduinoJson @ 5.10.1",
f"ArduinoJson @ {ARDUINO_JSON_VERSION}",
"required: git+https://github.com/gioblu/PJON.git#3.0",
"PJON @ 3.0.0+sha.1fb26f",
)
)
), result.output

result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
assert all(
Expand Down Expand Up @@ -220,7 +221,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
"[email protected]",
"[email protected]",
"[email protected]",
"NeoPixelBus@2.2.4",
"NeoPixelBus@2.7.3",
"[email protected]+sha.07fe9aa",
"[email protected]+sha.1fb26fd",
"[email protected]+sha.bef5814",
Expand Down Expand Up @@ -249,7 +250,7 @@ def test_global_lib_update(clirunner, validate_cliresult):
assert "__pkg_dir" in oudated[0]
result = clirunner.invoke(cmd_lib, ["-g", "update", oudated[0]["__pkg_dir"]])
validate_cliresult(result)
assert "Removing NeoPixelBus @ 2.2.4" in strip_ansi_codes(result.output)
assert "Removing NeoPixelBus @ 2.7.3" in strip_ansi_codes(result.output)

# update all libraries
result = clirunner.invoke(
Expand Down
10 changes: 5 additions & 5 deletions tests/commands/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ def test_install_unknown_from_registry(clirunner):
def test_install_core_3_dev_platform(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_install,
["atmelavr@1.2.0", "--skip-default-package"],
["atmelavr@2.2.0", "--skip-default-package"],
)
assert result.exit_code == 0


def test_install_known_version(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_install,
["atmelavr@2.0.0", "--skip-default-package", "--with-package", "tool-avrdude"],
["atmelavr@4.2.0", "--skip-default-package", "--with-package", "tool-avrdude"],
)
validate_cliresult(result)
output = strip_ansi_codes(result.output)
assert "atmelavr @ 2.0.0" in output
assert "atmelavr@4.2.0" in output
assert not os.path.isdir(str(isolated_pio_core.join("packages")))


Expand Down Expand Up @@ -128,14 +128,14 @@ def test_update_raw(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(cli_platform.platform_update, ["atmelavr"])
validate_cliresult(result)
output = strip_ansi_codes(result.output)
assert "Removing atmelavr @ 2.0.0" in output
assert "Removing atmelavr @ 4.2.0" in output
assert "Platform Manager: Installing platformio/atmelavr @" in output
assert len(isolated_pio_core.join("packages").listdir()) == 2


def test_uninstall(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_uninstall, ["atmelavr@1.2.0", "atmelavr", "espressif8266"]
cli_platform.platform_uninstall, ["atmelavr@2.2.0", "atmelavr", "espressif8266"]
)
validate_cliresult(result)
assert not isolated_pio_core.join("platforms").listdir()
22 changes: 11 additions & 11 deletions tests/package/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_install_from_registry(isolated_pio_core, tmpdir_factory):
# test conflicted names
lm = LibraryPackageManager(str(tmpdir_factory.mktemp("conflicted-storage")))
lm.set_log_level(logging.ERROR)
lm.install("z3t0/IRremote@2.6.1")
lm.install("z3t0/IRremote")
lm.install("mbed-yuhki50/IRremote")
assert len(lm.get_installed()) == 2

Expand Down Expand Up @@ -554,14 +554,14 @@ def test_uninstall(isolated_pio_core, tmpdir_factory):
assert not lm.get_installed()

# test uninstall dependencies
assert lm.install("AsyncMqttClient-esphome @ 0.8.4")
assert lm.install("AsyncMqttClient-esphome")
assert len(lm.get_installed()) == 3
assert lm.uninstall("AsyncMqttClient-esphome", skip_dependencies=True)
assert len(lm.get_installed()) == 2

lm = LibraryPackageManager(str(storage_dir))
lm.set_log_level(logging.ERROR)
assert lm.install("AsyncMqttClient-esphome @ 0.8.4")
assert lm.install("AsyncMqttClient-esphome")
assert lm.uninstall("AsyncMqttClient-esphome")
assert not lm.get_installed()

Expand Down Expand Up @@ -604,23 +604,23 @@ def test_update_with_metadata(isolated_pio_core, tmpdir_factory):
assert str(outdated.current) == "1.8.7"
assert outdated.latest > semantic_version.Version("1.10.0")

pkg = lm.install("ArduinoJson @ 5.10.1")
pkg = lm.install("ArduinoJson @ 6.19.4")
# test latest
outdated = lm.outdated(pkg)
assert str(outdated.current) == "5.10.1"
assert str(outdated.current) == "6.19.4"
assert outdated.wanted is None
assert outdated.latest > outdated.current
assert outdated.latest > semantic_version.Version("5.99.99")

# test wanted
outdated = lm.outdated(pkg, PackageSpec("ArduinoJson@~5"))
assert str(outdated.current) == "5.10.1"
assert str(outdated.wanted) == "5.13.4"
outdated = lm.outdated(pkg, PackageSpec("ArduinoJson@~6"))
assert str(outdated.current) == "6.19.4"
assert str(outdated.wanted) == "6.21.5"
assert outdated.latest > semantic_version.Version("6.16.0")

# update to the wanted 5.x
new_pkg = lm.update("ArduinoJson@^5", PackageSpec("ArduinoJson@^5"))
assert str(new_pkg.metadata.version) == "5.13.4"
# update to the wanted 6.x
new_pkg = lm.update("ArduinoJson@^6", PackageSpec("ArduinoJson@^6"))
assert str(new_pkg.metadata.version) == "6.21.5"
# check that old version is removed
assert len(lm.get_installed()) == 2

Expand Down

0 comments on commit 0f3dbe6

Please sign in to comment.