Files
deb-python-dcos/integrations/cli/test_subcommand.py
José Armando García Sancio 838da66e2f dcos-97 Implements installing a subcommand
There is quite a bit going on in this commit. Here is a high level
description of all of the changes:

* Improved the README to include information for running the
  integrations tests now that we have subcommand management support.
* Change the clean script to also delete the build directory.
* Removed requirement on the DCOS_PATH environment variable. We now
  assume the DCOS CLI installation directory based on the location of
  the dcos cli binary
* Adds support for installing subcommand from python wheels. The
  packages are install under the 'subcommands' directory.
* Extended the `dcos help` to look into the 'subcommands'
  directory for the excutables that extend the cli.
* Fix the root `dcos` executable to not use the DCOS_PATH environment
  variable to discover subcommand. It now discovers subcommand based
  on the location of the root (`dcos`) executable.
* Adds `dcos subcommand` for managing the installation, listing and
  the removal of subcommands.
* Adds dependencies on pkginfo and virtualenv. We need pkginfo to query
  information about the package. We need virtualenv to create
  virtual environment for each subcommand installed.
2015-03-11 17:05:41 -07:00

75 lines
1.6 KiB
Python

import json
import os
import pytest
from common import exec_command
@pytest.fixture
def package():
return os.environ['DCOS_TEST_WHEEL']
def test_list_empty_subcommand():
_list_subcommands(0)
def test_install_package(package):
_install_subcommand(package)
_list_subcommands(1)
_uninstall_subcommand('dcos-helloworld')
def test_install_existing_package(package):
_install_subcommand(package)
_install_subcommand(package)
_list_subcommands(1)
_uninstall_subcommand('dcos-helloworld')
def test_list_subcommand(package):
_install_subcommand(package)
_list_subcommands(1)
_uninstall_subcommand('dcos-helloworld')
def test_uninstall_missing_subcommand(package):
_uninstall_subcommand('missing-package')
def test_uninstall_helloworld(package):
_install_subcommand(package)
_list_subcommands(1)
_uninstall_subcommand('dcos-helloworld')
_list_subcommands(0)
def _list_subcommands(size):
returncode, stdout, stderr = exec_command(['dcos', 'subcommand', 'list'])
result = json.loads(stdout.decode('utf-8'))
assert returncode == 0
assert len(result) == size
assert stderr == b''
return result
def _install_subcommand(package):
returncode, stdout, stderr = exec_command(
['dcos', 'subcommand', 'install', package])
assert returncode == 0
assert stdout == b''
assert stderr == b''
def _uninstall_subcommand(package):
returncode, stdout, stderr = exec_command(
['dcos', 'subcommand', 'uninstall', package])
assert returncode == 0
assert stdout == b''
assert stderr == b''