Update a complex test for platform install command

This commit is contained in:
Ivan Kravets
2016-09-14 23:26:51 +03:00
parent 92e69a60f4
commit 3b6bda825b

View File

@ -68,56 +68,52 @@ def test_install_uknown_version(clirunner, validate_cliresult):
def test_complex(clirunner, validate_cliresult): def test_complex(clirunner, validate_cliresult):
items = [ with clirunner.isolated_filesystem():
"teensy", os.environ["PLATFORMIO_HOME_DIR"] = os.getcwd()
"https://github.com/platformio/platform-teensy/archive/develop.zip" try:
] result = clirunner.invoke(
for item in items: cli_platform.platform_install,
with clirunner.isolated_filesystem(): ["teensy", "--with-package", "framework-arduinoteensy"])
os.environ["PLATFORMIO_HOME_DIR"] = os.getcwd() validate_cliresult(result)
try: assert all([
result = clirunner.invoke(cli_platform.platform_install, s in result.output
[item]) for s in ("teensy", "Downloading", "Unpacking")
validate_cliresult(result) ])
assert all([
s in result.output
for s in ("teensy", "Downloading", "Unpacking")
])
# show platform information # show platform information
result = clirunner.invoke(cli_platform.platform_show, result = clirunner.invoke(cli_platform.platform_show, ["teensy"])
["teensy"]) validate_cliresult(result)
validate_cliresult(result) assert "teensy" in result.output
assert "teensy" in result.output
# list platforms # list platforms
result = clirunner.invoke(cli_platform.platform_list, result = clirunner.invoke(cli_platform.platform_list,
["--json-output"]) ["--json-output"])
validate_cliresult(result) validate_cliresult(result)
list_result = json.loads(result.output) list_result = json.loads(result.output)
assert isinstance(list_result, list) assert isinstance(list_result, list)
assert len(list_result) == 1 assert len(list_result) == 1
assert list_result[0]["name"] == "teensy" assert list_result[0]["name"] == "teensy"
assert list_result[0]["packages"] == [] assert list_result[0]["packages"] == ["framework-arduinoteensy"]
# try to install again # try to install again
result = clirunner.invoke(cli_platform.platform_install, result = clirunner.invoke(cli_platform.platform_install,
["teensy"]) ["teensy"])
validate_cliresult(result) validate_cliresult(result)
assert "is already installed" in result.output assert "is already installed" in result.output
# try to update # try to update
for _ in range(2):
result = clirunner.invoke(cli_platform.platform_update) result = clirunner.invoke(cli_platform.platform_update)
validate_cliresult(result) validate_cliresult(result)
assert "teensy" in result.output assert "teensy" in result.output
# assert "Up-to-date" in result.output assert "Up-to-date" in result.output
assert "Out-of-date" not in result.output
# try to uninstall # try to uninstall
result = clirunner.invoke(cli_platform.platform_uninstall, result = clirunner.invoke(cli_platform.platform_uninstall,
["teensy"]) ["teensy"])
validate_cliresult(result) validate_cliresult(result)
for folder in ("platforms", "packages"): for folder in ("platforms", "packages"):
assert len(os.listdir(join(util.get_home_dir(), assert len(os.listdir(join(util.get_home_dir(), folder))) == 0
folder))) == 0 finally:
finally: del os.environ["PLATFORMIO_HOME_DIR"]
del os.environ["PLATFORMIO_HOME_DIR"]