forked from platformio/platformio-core
Fix test
This commit is contained in:
@ -14,9 +14,6 @@
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from time import time
|
||||
|
||||
from platformio import app, maintenance
|
||||
@ -51,103 +48,3 @@ def test_check_pio_upgrade(clirunner, isolated_pio_core, validate_cliresult):
|
||||
|
||||
# restore original version
|
||||
_patch_pio_version(origin_version)
|
||||
|
||||
|
||||
def test_check_lib_updates(clirunner, isolated_pio_core, validate_cliresult):
|
||||
# install obsolete library
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "install", "ArduinoJson@<6.13"])
|
||||
validate_cliresult(result)
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_libraries_interval")) * 3600 * 24
|
||||
last_check = {"libraries_update": time() - interval - 1}
|
||||
app.set_state_item("last_check", last_check)
|
||||
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "list"])
|
||||
validate_cliresult(result)
|
||||
assert "There are the new updates for libraries (ArduinoJson)" in result.output
|
||||
|
||||
|
||||
def test_check_and_update_libraries(clirunner, isolated_pio_core, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"]
|
||||
)
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_libraries_interval")) * 3600 * 24
|
||||
last_check = {"libraries_update": time() - interval - 1}
|
||||
app.set_state_item("last_check", last_check)
|
||||
|
||||
# fetch installed version
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
prev_data = json.loads(result.output)
|
||||
assert len(prev_data) == 1
|
||||
|
||||
# initiate auto-updating
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "show", "ArduinoJson"])
|
||||
validate_cliresult(result)
|
||||
assert "There are the new updates for libraries (ArduinoJson)" in result.output
|
||||
assert "Please wait while updating libraries" in result.output
|
||||
assert re.search(
|
||||
r"Updating bblanchon/ArduinoJson\s+6\.12\.0\s+\[Updating to [\d\.]+\]",
|
||||
result.output,
|
||||
)
|
||||
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert prev_data[0]["version"] != json.loads(result.output)[0]["version"]
|
||||
|
||||
|
||||
def test_check_platform_updates(clirunner, isolated_pio_core, validate_cliresult):
|
||||
# install obsolete platform
|
||||
result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
|
||||
validate_cliresult(result)
|
||||
os.remove(str(isolated_pio_core.join("platforms", "native", ".piopm")))
|
||||
manifest_path = isolated_pio_core.join("platforms", "native", "platform.json")
|
||||
manifest = json.loads(manifest_path.read())
|
||||
manifest["version"] = "0.0.0"
|
||||
manifest_path.write(json.dumps(manifest))
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24
|
||||
last_check = {"platforms_update": time() - interval - 1}
|
||||
app.set_state_item("last_check", last_check)
|
||||
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list"])
|
||||
validate_cliresult(result)
|
||||
assert "There are the new updates for platforms (native)" in result.output
|
||||
|
||||
|
||||
def test_check_and_update_platforms(clirunner, isolated_pio_core, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"]
|
||||
)
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24
|
||||
last_check = {"platforms_update": time() - interval - 1}
|
||||
app.set_state_item("last_check", last_check)
|
||||
|
||||
# fetch installed version
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
prev_data = json.loads(result.output)
|
||||
assert len(prev_data) == 1
|
||||
|
||||
# initiate auto-updating
|
||||
result = clirunner.invoke(cli_pio, ["platform", "show", "native"])
|
||||
validate_cliresult(result)
|
||||
assert "There are the new updates for platforms (native)" in result.output
|
||||
assert "Please wait while updating platforms" in result.output
|
||||
assert re.search(
|
||||
r"Updating native\s+0.0.0\s+\[Updating to [\d\.]+\]", result.output
|
||||
)
|
||||
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert prev_data[0]["version"] != json.loads(result.output)[0]["version"]
|
||||
|
Reference in New Issue
Block a user