forked from platformio/platformio-core
PlatformIO Library Manager 3.0 // Resolve #588 , Resolve #414, Resolve #498, Resolve #475, Resolve #410, Resolve #461, Resolve #361, Resolve #507, Resolve #554
This commit is contained in:
1 parent
5b5a63cb5f
commit
758396c9ea
34 files changed
+1185
-700
No files matched your search
@@ -14,10 +14,8 @@
|
||||
|
||||
import json
|
||||
|
||||
from platformio import util
|
||||
from platformio.commands.boards import cli as cmd_boards
|
||||
from platformio.commands.platform import \
|
||||
platform_search as cmd_platform_search
|
||||
from platformio.commands.platform import platform_search as cmd_platform_search
|
||||
|
||||
|
||||
def test_board_json_output(platformio_setup, clirunner, validate_cliresult):
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
from os import makedirs, getcwd
|
||||
from os import getcwd, makedirs
|
||||
from os.path import getsize, isdir, isfile, join
|
||||
|
||||
from platformio.commands.init import cli
|
||||
from platformio.commands.boards import cli as cmd_boards
|
||||
from platformio import util
|
||||
from platformio.commands.boards import cli as cmd_boards
|
||||
from platformio.commands.init import cli
|
||||
|
||||
|
||||
def validate_pioproject(pioproject_dir):
|
||||
|
||||
+54
-31
@@ -12,25 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from os import listdir
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
import re
|
||||
|
||||
from platformio.commands.lib import cli
|
||||
from platformio import util
|
||||
|
||||
|
||||
def validate_libfolder():
|
||||
libs_path = util.get_lib_dir()
|
||||
installed_libs = listdir(libs_path)
|
||||
for lib in installed_libs:
|
||||
assert isdir(join(libs_path, lib))
|
||||
assert isfile(join(libs_path, lib, ".library.json")) and isfile(
|
||||
join(libs_path, lib, "library.json"))
|
||||
|
||||
|
||||
def test_lib_search(clirunner, validate_cliresult):
|
||||
def test_search(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["search", "DHT22"])
|
||||
validate_cliresult(result)
|
||||
match = re.search(r"Found\s+(\d+)\slibraries:", result.output)
|
||||
@@ -42,34 +29,70 @@ def test_lib_search(clirunner, validate_cliresult):
|
||||
assert int(match.group(1)) == 1
|
||||
|
||||
|
||||
def test_lib_install(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["install", "58", "115"])
|
||||
def test_global_install_registry(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cli, ["-g", "install", "58", "OneWire", "Json@5.4.0", "Json@>5.4"])
|
||||
validate_cliresult(result)
|
||||
validate_libfolder()
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = ["DHT22_ID58", "Json_ID64", "Json_ID64@5.4.0", "OneWire_ID1"]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
|
||||
def test_lib_list(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["list"])
|
||||
def test_global_install_repository(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cli, ["-g", "install", "https://github.com/gioblu/PJON.git#3.0",
|
||||
"https://developer.mbed.org/users/simon/code/TextLCD/",
|
||||
"http://dl.platformio.org/libraries/archives/3/3756.tar.gz",
|
||||
"knolleary/pubsubclient"])
|
||||
validate_cliresult(result)
|
||||
assert "58" in result.output and "115" in result.output
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = ["PJON", "TextLCD", "ESPAsyncTCP", "PubSubClient"]
|
||||
assert set(items2) & set(items1)
|
||||
|
||||
|
||||
def test_lib_show(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["show", "115"])
|
||||
def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli, ["-g", "list"])
|
||||
validate_cliresult(result)
|
||||
assert "arduino" in result.output and "atmelavr" in result.output
|
||||
assert all([n in result.output for n in ("OneWire", "DHT22", "64")])
|
||||
|
||||
result = clirunner.invoke(cli, ["show", "58"])
|
||||
result = clirunner.invoke(cli, ["-g", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert "energia" in result.output and "timsp430" in result.output
|
||||
assert all(
|
||||
[n in result.output
|
||||
for n in ("PJON",
|
||||
"https://developer.mbed.org/users/simon/code/TextLCD/")])
|
||||
|
||||
|
||||
def test_lib_update(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["update"])
|
||||
def test_global_lib_show(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli, ["-g", "show", "64@5.4.0"])
|
||||
validate_cliresult(result)
|
||||
assert "58" in result.output and "115" in result.output
|
||||
assert all(
|
||||
[s in result.output for s in ("Json", "arduino", "atmelavr", "5.4.0")])
|
||||
|
||||
|
||||
def test_lib_uninstall(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli, ["uninstall", "58", "115"])
|
||||
result = clirunner.invoke(cli, ["-g", "show", "Json@>5.4.0"])
|
||||
validate_cliresult(result)
|
||||
assert all([s in result.output for s in ("Json", "arduino", "atmelavr")])
|
||||
assert "5.4.0" not in result.output
|
||||
|
||||
result = clirunner.invoke(cli, ["-g", "show", "1"])
|
||||
validate_cliresult(result)
|
||||
assert "OneWire" in result.output
|
||||
|
||||
|
||||
def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli, ["-g", "update"])
|
||||
validate_cliresult(result)
|
||||
assert all([s in result.output for s in ("Up-to-date", "Checking")])
|
||||
|
||||
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cli, ["-g", "uninstall", "1", "Json@!=5.4.0", "TextLCD"])
|
||||
validate_cliresult(result)
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = ["DHT22_ID58", "Json_ID64@5.4.0", "ESPAsyncTCP_ID305",
|
||||
"pubsubclient", "PJON"]
|
||||
assert set(items1) == set(items2)
|
||||
@@ -16,8 +16,8 @@ import json
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
from platformio.commands import platform as cli_platform
|
||||
from platformio import exception, util
|
||||
from platformio.commands import platform as cli_platform
|
||||
|
||||
|
||||
def test_list_json_output(clirunner, validate_cliresult):
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from platformio.commands.settings import cli
|
||||
from platformio import app
|
||||
from platformio.commands.settings import cli
|
||||
|
||||
|
||||
def test_settings_check(clirunner, validate_cliresult):
|
||||
|
||||
+19
-8
@@ -1,4 +1,4 @@
|
||||
# Copyright 2014-2016 Ivan Kravets <me@ikravets.com>
|
||||
# Copyright 2014-present Ivan Kravets <me@ikravets.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,29 +12,28 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from os import environ
|
||||
|
||||
from click.testing import CliRunner
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def platformio_setup(request):
|
||||
pioenvvars = ("ENABLE_PROMPTS", "ENABLE_TELEMETRY")
|
||||
for v in pioenvvars:
|
||||
environ["PLATFORMIO_SETTING_%s" % v] = "No"
|
||||
os.environ["PLATFORMIO_SETTING_%s" % v] = "No"
|
||||
|
||||
def platformio_teardown():
|
||||
for v in pioenvvars:
|
||||
_name = "PLATFORMIO_SETTING_%s" % v
|
||||
if _name in environ:
|
||||
del environ[_name]
|
||||
if _name in os.environ:
|
||||
del os.environ[_name]
|
||||
|
||||
request.addfinalizer(platformio_teardown)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture(scope="module")
|
||||
def clirunner():
|
||||
return CliRunner()
|
||||
|
||||
@@ -46,3 +45,15 @@ def validate_cliresult():
|
||||
assert not result.exception
|
||||
assert "error" not in result.output.lower()
|
||||
return decorator
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def isolated_pio_home(request, tmpdir_factory):
|
||||
home_dir = tmpdir_factory.mktemp(".platformio")
|
||||
os.environ['PLATFORMIO_HOME_DIR'] = str(home_dir)
|
||||
|
||||
def fin():
|
||||
del os.environ['PLATFORMIO_HOME_DIR']
|
||||
|
||||
request.addfinalizer(fin)
|
||||
return home_dir
|
||||
Reference in new issue
Block a user