mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Update tests
This commit is contained in:
@ -23,6 +23,7 @@ from platformio.package.exception import UnknownPackageError
|
|||||||
from platformio.util import strip_ansi_codes
|
from platformio.util import strip_ansi_codes
|
||||||
|
|
||||||
PlatformioCLI.leftover_args = ["--json-output"] # hook for click
|
PlatformioCLI.leftover_args = ["--json-output"] # hook for click
|
||||||
|
ARDUINO_JSON_VERSION = "6.21.5"
|
||||||
|
|
||||||
|
|
||||||
def test_search(clirunner, validate_cliresult):
|
def test_search(clirunner, validate_cliresult):
|
||||||
@ -44,10 +45,10 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_cor
|
|||||||
"-g",
|
"-g",
|
||||||
"install",
|
"install",
|
||||||
"64",
|
"64",
|
||||||
"ArduinoJson@~5.10.0",
|
"ArduinoJson@~6",
|
||||||
"547@2.2.4",
|
"547@2.7.3",
|
||||||
"AsyncMqttClient@<=0.8.2",
|
"AsyncMqttClient@<=0.8.2",
|
||||||
"Adafruit PN532@1.2.0",
|
"Adafruit PN532@1.3.2",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
@ -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()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = [
|
items2 = [
|
||||||
"ArduinoJson",
|
"ArduinoJson",
|
||||||
"ArduinoJson@5.10.1",
|
"fArduinoJson@{ARDUINO_JSON_VERSION}",
|
||||||
"NeoPixelBus",
|
"NeoPixelBus",
|
||||||
"AsyncMqttClient",
|
"AsyncMqttClient",
|
||||||
"ESPAsyncTCP",
|
"ESPAsyncTCP",
|
||||||
@ -79,7 +80,7 @@ def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_core
|
|||||||
"install",
|
"install",
|
||||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||||
"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",
|
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -142,7 +143,7 @@ def test_install_duplicates( # pylint: disable=unused-argument
|
|||||||
[
|
[
|
||||||
"-g",
|
"-g",
|
||||||
"install",
|
"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)
|
validate_cliresult(result)
|
||||||
@ -176,11 +177,11 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
|||||||
n in result.output
|
n in result.output
|
||||||
for n in (
|
for n in (
|
||||||
"required: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
"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",
|
"required: git+https://github.com/gioblu/PJON.git#3.0",
|
||||||
"PJON @ 3.0.0+sha.1fb26f",
|
"PJON @ 3.0.0+sha.1fb26f",
|
||||||
)
|
)
|
||||||
)
|
), result.output
|
||||||
|
|
||||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||||
assert all(
|
assert all(
|
||||||
@ -220,7 +221,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
|||||||
"ArduinoJson@5.8.2",
|
"ArduinoJson@5.8.2",
|
||||||
"ArduinoJson@5.10.1",
|
"ArduinoJson@5.10.1",
|
||||||
"AsyncMqttClient@0.8.2",
|
"AsyncMqttClient@0.8.2",
|
||||||
"NeoPixelBus@2.2.4",
|
"NeoPixelBus@2.7.3",
|
||||||
"PJON@6.2.0+sha.07fe9aa",
|
"PJON@6.2.0+sha.07fe9aa",
|
||||||
"PJON@3.0.0+sha.1fb26fd",
|
"PJON@3.0.0+sha.1fb26fd",
|
||||||
"PubSubClient@2.6.0+sha.bef5814",
|
"PubSubClient@2.6.0+sha.bef5814",
|
||||||
@ -249,7 +250,7 @@ def test_global_lib_update(clirunner, validate_cliresult):
|
|||||||
assert "__pkg_dir" in oudated[0]
|
assert "__pkg_dir" in oudated[0]
|
||||||
result = clirunner.invoke(cmd_lib, ["-g", "update", oudated[0]["__pkg_dir"]])
|
result = clirunner.invoke(cmd_lib, ["-g", "update", oudated[0]["__pkg_dir"]])
|
||||||
validate_cliresult(result)
|
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
|
# update all libraries
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
|
@ -63,7 +63,7 @@ def test_install_unknown_from_registry(clirunner):
|
|||||||
def test_install_core_3_dev_platform(clirunner, validate_cliresult, isolated_pio_core):
|
def test_install_core_3_dev_platform(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_install,
|
cli_platform.platform_install,
|
||||||
["atmelavr@1.2.0", "--skip-default-package"],
|
["atmelavr@2.2.0", "--skip-default-package"],
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
@ -71,11 +71,11 @@ def test_install_core_3_dev_platform(clirunner, validate_cliresult, isolated_pio
|
|||||||
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_core):
|
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_install,
|
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)
|
validate_cliresult(result)
|
||||||
output = strip_ansi_codes(result.output)
|
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")))
|
assert not os.path.isdir(str(isolated_pio_core.join("packages")))
|
||||||
|
|
||||||
|
|
||||||
@ -128,14 +128,14 @@ def test_update_raw(clirunner, validate_cliresult, isolated_pio_core):
|
|||||||
result = clirunner.invoke(cli_platform.platform_update, ["atmelavr"])
|
result = clirunner.invoke(cli_platform.platform_update, ["atmelavr"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
output = strip_ansi_codes(result.output)
|
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 "Platform Manager: Installing platformio/atmelavr @" in output
|
||||||
assert len(isolated_pio_core.join("packages").listdir()) == 2
|
assert len(isolated_pio_core.join("packages").listdir()) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_uninstall(clirunner, validate_cliresult, isolated_pio_core):
|
def test_uninstall(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
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)
|
validate_cliresult(result)
|
||||||
assert not isolated_pio_core.join("platforms").listdir()
|
assert not isolated_pio_core.join("platforms").listdir()
|
||||||
|
@ -219,7 +219,7 @@ def test_install_from_registry(isolated_pio_core, tmpdir_factory):
|
|||||||
# test conflicted names
|
# test conflicted names
|
||||||
lm = LibraryPackageManager(str(tmpdir_factory.mktemp("conflicted-storage")))
|
lm = LibraryPackageManager(str(tmpdir_factory.mktemp("conflicted-storage")))
|
||||||
lm.set_log_level(logging.ERROR)
|
lm.set_log_level(logging.ERROR)
|
||||||
lm.install("z3t0/IRremote@2.6.1")
|
lm.install("z3t0/IRremote")
|
||||||
lm.install("mbed-yuhki50/IRremote")
|
lm.install("mbed-yuhki50/IRremote")
|
||||||
assert len(lm.get_installed()) == 2
|
assert len(lm.get_installed()) == 2
|
||||||
|
|
||||||
@ -554,14 +554,14 @@ def test_uninstall(isolated_pio_core, tmpdir_factory):
|
|||||||
assert not lm.get_installed()
|
assert not lm.get_installed()
|
||||||
|
|
||||||
# test uninstall dependencies
|
# test uninstall dependencies
|
||||||
assert lm.install("AsyncMqttClient-esphome @ 0.8.4")
|
assert lm.install("AsyncMqttClient-esphome")
|
||||||
assert len(lm.get_installed()) == 3
|
assert len(lm.get_installed()) == 3
|
||||||
assert lm.uninstall("AsyncMqttClient-esphome", skip_dependencies=True)
|
assert lm.uninstall("AsyncMqttClient-esphome", skip_dependencies=True)
|
||||||
assert len(lm.get_installed()) == 2
|
assert len(lm.get_installed()) == 2
|
||||||
|
|
||||||
lm = LibraryPackageManager(str(storage_dir))
|
lm = LibraryPackageManager(str(storage_dir))
|
||||||
lm.set_log_level(logging.ERROR)
|
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 lm.uninstall("AsyncMqttClient-esphome")
|
||||||
assert not lm.get_installed()
|
assert not lm.get_installed()
|
||||||
|
|
||||||
@ -604,23 +604,23 @@ def test_update_with_metadata(isolated_pio_core, tmpdir_factory):
|
|||||||
assert str(outdated.current) == "1.8.7"
|
assert str(outdated.current) == "1.8.7"
|
||||||
assert outdated.latest > semantic_version.Version("1.10.0")
|
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
|
# test latest
|
||||||
outdated = lm.outdated(pkg)
|
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.wanted is None
|
||||||
assert outdated.latest > outdated.current
|
assert outdated.latest > outdated.current
|
||||||
assert outdated.latest > semantic_version.Version("5.99.99")
|
assert outdated.latest > semantic_version.Version("5.99.99")
|
||||||
|
|
||||||
# test wanted
|
# test wanted
|
||||||
outdated = lm.outdated(pkg, PackageSpec("ArduinoJson@~5"))
|
outdated = lm.outdated(pkg, PackageSpec("ArduinoJson@~6"))
|
||||||
assert str(outdated.current) == "5.10.1"
|
assert str(outdated.current) == "6.19.4"
|
||||||
assert str(outdated.wanted) == "5.13.4"
|
assert str(outdated.wanted) == "6.21.5"
|
||||||
assert outdated.latest > semantic_version.Version("6.16.0")
|
assert outdated.latest > semantic_version.Version("6.16.0")
|
||||||
|
|
||||||
# update to the wanted 5.x
|
# update to the wanted 6.x
|
||||||
new_pkg = lm.update("ArduinoJson@^5", PackageSpec("ArduinoJson@^5"))
|
new_pkg = lm.update("ArduinoJson@^6", PackageSpec("ArduinoJson@^6"))
|
||||||
assert str(new_pkg.metadata.version) == "5.13.4"
|
assert str(new_pkg.metadata.version) == "6.21.5"
|
||||||
# check that old version is removed
|
# check that old version is removed
|
||||||
assert len(lm.get_installed()) == 2
|
assert len(lm.get_installed()) == 2
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user