mirror of
https://github.com/platformio/platformio-core.git
synced 2025-10-04 17:40:57 +02:00
Introduce Black to automate code formatting
This commit is contained in:
@@ -28,19 +28,25 @@ def test_search(clirunner, validate_cliresult):
|
||||
match = re.search(r"Found\s+(\d+)\slibraries:", result.output)
|
||||
assert int(match.group(1)) > 2
|
||||
|
||||
result = clirunner.invoke(cmd_lib,
|
||||
["search", "DHT22", "--platform=timsp430"])
|
||||
result = clirunner.invoke(cmd_lib, ["search", "DHT22", "--platform=timsp430"])
|
||||
validate_cliresult(result)
|
||||
match = re.search(r"Found\s+(\d+)\slibraries:", result.output)
|
||||
assert int(match.group(1)) > 1
|
||||
|
||||
|
||||
def test_global_install_registry(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install", "64", "ArduinoJson@~5.10.0", "547@2.2.4",
|
||||
"AsyncMqttClient@<=0.8.2", "999@77d4eb3f8a"
|
||||
])
|
||||
def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"64",
|
||||
"ArduinoJson@~5.10.0",
|
||||
"547@2.2.4",
|
||||
"AsyncMqttClient@<=0.8.2",
|
||||
"999@77d4eb3f8a",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
# install unknown library
|
||||
@@ -50,29 +56,40 @@ def test_global_install_registry(clirunner, validate_cliresult,
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"ArduinoJson_ID64", "ArduinoJson_ID64@5.10.1", "NeoPixelBus_ID547",
|
||||
"AsyncMqttClient_ID346", "ESPAsyncTCP_ID305", "AsyncTCP_ID1826",
|
||||
"RFcontrol_ID999"
|
||||
"ArduinoJson_ID64",
|
||||
"ArduinoJson_ID64@5.10.1",
|
||||
"NeoPixelBus_ID547",
|
||||
"AsyncMqttClient_ID346",
|
||||
"ESPAsyncTCP_ID305",
|
||||
"AsyncTCP_ID1826",
|
||||
"RFcontrol_ID999",
|
||||
]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
|
||||
def test_global_install_archive(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||
"SomeLib=http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip"
|
||||
])
|
||||
def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||
"SomeLib=http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
# incorrect requirements
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@1.2.3"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@1.2.3",
|
||||
],
|
||||
)
|
||||
assert result.exit_code != 0
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
@@ -80,8 +97,7 @@ def test_global_install_archive(clirunner, validate_cliresult,
|
||||
assert set(items1) >= set(items2)
|
||||
|
||||
|
||||
def test_global_install_repository(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_global_install_repository(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
@@ -93,24 +109,28 @@ def test_global_install_repository(clirunner, validate_cliresult,
|
||||
"https://gitlab.com/ivankravets/rs485-nodeproto.git",
|
||||
"https://github.com/platformio/platformio-libmirror.git",
|
||||
# "https://developer.mbed.org/users/simon/code/TextLCD/",
|
||||
"knolleary/pubsubclient#bef58148582f956dfa772687db80c44e2279a163"
|
||||
])
|
||||
"knolleary/pubsubclient#bef58148582f956dfa772687db80c44e2279a163",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"PJON", "PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81", "rs485-nodeproto",
|
||||
"platformio-libmirror", "PubSubClient"
|
||||
"PJON",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"rs485-nodeproto",
|
||||
"platformio-libmirror",
|
||||
"PubSubClient",
|
||||
]
|
||||
assert set(items1) >= set(items2)
|
||||
|
||||
|
||||
def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
# registry
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"http://dl.platformio.org/libraries/archives/0/9540.tar.gz"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "install", "http://dl.platformio.org/libraries/archives/0/9540.tar.gz"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
@@ -120,18 +140,22 @@ def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
assert "is already installed" in result.output
|
||||
|
||||
# archive
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
# repository
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/platformio/platformio-libmirror.git"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "install", "https://github.com/platformio/platformio-libmirror.git"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
@@ -139,27 +163,48 @@ def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
def test_global_lib_list(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
n in result.output for n in
|
||||
("Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
"Version: 5.10.1",
|
||||
"Source: git+https://github.com/gioblu/PJON.git#3.0",
|
||||
"Version: 1fb26fd")
|
||||
])
|
||||
assert all(
|
||||
[
|
||||
n in result.output
|
||||
for n in (
|
||||
"Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
"Version: 5.10.1",
|
||||
"Source: git+https://github.com/gioblu/PJON.git#3.0",
|
||||
"Version: 1fb26fd",
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||
assert all([
|
||||
n in result.output for n in
|
||||
("__pkg_dir",
|
||||
'"__src_url": "git+https://gitlab.com/ivankravets/rs485-nodeproto.git"',
|
||||
'"version": "5.10.1"')
|
||||
])
|
||||
items1 = [i['name'] for i in json.loads(result.output)]
|
||||
assert all(
|
||||
[
|
||||
n in result.output
|
||||
for n in (
|
||||
"__pkg_dir",
|
||||
'"__src_url": "git+https://gitlab.com/ivankravets/rs485-nodeproto.git"',
|
||||
'"version": "5.10.1"',
|
||||
)
|
||||
]
|
||||
)
|
||||
items1 = [i["name"] for i in json.loads(result.output)]
|
||||
items2 = [
|
||||
"ESP32WebServer", "ArduinoJson", "ArduinoJson", "ArduinoJson",
|
||||
"ArduinoJson", "AsyncMqttClient", "AsyncTCP", "SomeLib", "ESPAsyncTCP",
|
||||
"NeoPixelBus", "OneWire", "PJON", "PJON", "PubSubClient", "RFcontrol",
|
||||
"platformio-libmirror", "rs485-nodeproto"
|
||||
"ESP32WebServer",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"AsyncMqttClient",
|
||||
"AsyncTCP",
|
||||
"SomeLib",
|
||||
"ESPAsyncTCP",
|
||||
"NeoPixelBus",
|
||||
"OneWire",
|
||||
"PJON",
|
||||
"PJON",
|
||||
"PubSubClient",
|
||||
"RFcontrol",
|
||||
"platformio-libmirror",
|
||||
"rs485-nodeproto",
|
||||
]
|
||||
assert sorted(items1) == sorted(items2)
|
||||
|
||||
@@ -167,33 +212,37 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
||||
"{name}@{version}".format(**item) for item in json.loads(result.output)
|
||||
]
|
||||
versions2 = [
|
||||
"ArduinoJson@5.8.2", "ArduinoJson@5.10.1", "AsyncMqttClient@0.8.2",
|
||||
"NeoPixelBus@2.2.4", "PJON@07fe9aa", "PJON@1fb26fd",
|
||||
"PubSubClient@bef5814", "RFcontrol@77d4eb3f8a"
|
||||
"ArduinoJson@5.8.2",
|
||||
"ArduinoJson@5.10.1",
|
||||
"AsyncMqttClient@0.8.2",
|
||||
"NeoPixelBus@2.2.4",
|
||||
"PJON@07fe9aa",
|
||||
"PJON@1fb26fd",
|
||||
"PubSubClient@bef5814",
|
||||
"RFcontrol@77d4eb3f8a",
|
||||
]
|
||||
assert set(versions1) >= set(versions2)
|
||||
|
||||
|
||||
def test_global_lib_update_check(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib, ["-g", "update", "--only-check", "--json-output"])
|
||||
cmd_lib, ["-g", "update", "--only-check", "--json-output"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
output = json.loads(result.output)
|
||||
assert set(["RFcontrol",
|
||||
"NeoPixelBus"]) == set([l['name'] for l in output])
|
||||
assert set(["RFcontrol", "NeoPixelBus"]) == set([l["name"] for l in output])
|
||||
|
||||
|
||||
def test_global_lib_update(clirunner, validate_cliresult):
|
||||
# update library using package directory
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "update", "NeoPixelBus", "--only-check", "--json-output"])
|
||||
cmd_lib, ["-g", "update", "NeoPixelBus", "--only-check", "--json-output"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
oudated = json.loads(result.output)
|
||||
assert len(oudated) == 1
|
||||
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)
|
||||
assert "Uninstalling NeoPixelBus @ 2.2.4" in result.output
|
||||
|
||||
@@ -210,31 +259,43 @@ def test_global_lib_update(clirunner, validate_cliresult):
|
||||
assert isinstance(result.exception, exception.UnknownPackage)
|
||||
|
||||
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
||||
# uninstall using package directory
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
items = json.loads(result.output)
|
||||
result = clirunner.invoke(cmd_lib,
|
||||
["-g", "uninstall", items[5]['__pkg_dir']])
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "uninstall", items[5]["__pkg_dir"]])
|
||||
validate_cliresult(result)
|
||||
assert "Uninstalling AsyncTCP" in result.output
|
||||
|
||||
# uninstall the rest libraries
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "uninstall", "1", "https://github.com/bblanchon/ArduinoJson.git",
|
||||
"ArduinoJson@!=5.6.7", "RFcontrol"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"uninstall",
|
||||
"1",
|
||||
"https://github.com/bblanchon/ArduinoJson.git",
|
||||
"ArduinoJson@!=5.6.7",
|
||||
"RFcontrol",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"rs485-nodeproto", "platformio-libmirror",
|
||||
"PubSubClient", "ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"ESPAsyncTCP_ID305", "SomeLib_ID54", "NeoPixelBus_ID547", "PJON",
|
||||
"AsyncMqttClient_ID346", "ArduinoJson_ID64",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d", "ESP32WebServer"
|
||||
"rs485-nodeproto",
|
||||
"platformio-libmirror",
|
||||
"PubSubClient",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"ESPAsyncTCP_ID305",
|
||||
"SomeLib_ID54",
|
||||
"NeoPixelBus_ID547",
|
||||
"PJON",
|
||||
"AsyncMqttClient_ID346",
|
||||
"ArduinoJson_ID64",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ESP32WebServer",
|
||||
]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
@@ -247,8 +308,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
def test_lib_show(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_lib, ["show", "64"])
|
||||
validate_cliresult(result)
|
||||
assert all(
|
||||
[s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR")])
|
||||
assert all([s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR")])
|
||||
result = clirunner.invoke(cmd_lib, ["show", "OneWire", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert "OneWire" in result.output
|
||||
@@ -264,14 +324,23 @@ def test_lib_builtin(clirunner, validate_cliresult):
|
||||
def test_lib_stats(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_lib, ["stats"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
s in result.output
|
||||
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
|
||||
])
|
||||
assert all(
|
||||
[
|
||||
s in result.output
|
||||
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
|
||||
]
|
||||
)
|
||||
|
||||
result = clirunner.invoke(cmd_lib, ["stats", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert set([
|
||||
"dlweek", "added", "updated", "topkeywords", "dlmonth", "dlday",
|
||||
"lastkeywords"
|
||||
]) == set(json.loads(result.output).keys())
|
||||
assert set(
|
||||
[
|
||||
"dlweek",
|
||||
"added",
|
||||
"updated",
|
||||
"topkeywords",
|
||||
"dlmonth",
|
||||
"dlday",
|
||||
"lastkeywords",
|
||||
]
|
||||
) == set(json.loads(result.output).keys())
|
||||
|
Reference in New Issue
Block a user