tests: test html output for spack list
- make list test use SpackCommand - convert to pytest - add a test for HTML output
This commit is contained in:
parent
f476e60c01
commit
175de19f2d
1 changed files with 40 additions and 65 deletions
|
@ -22,84 +22,59 @@
|
||||||
# License along with this program; if not, write to the Free Software
|
# License along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import argparse
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import spack.cmd.list
|
|
||||||
|
from spack.main import SpackCommand
|
||||||
|
|
||||||
|
list = SpackCommand('list')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
def test_list():
|
||||||
def parser():
|
output = list()
|
||||||
"""Returns the parser for the module command"""
|
assert 'cloverleaf3d' in output
|
||||||
prs = argparse.ArgumentParser()
|
assert 'hdf5' in output
|
||||||
spack.cmd.list.setup_parser(prs)
|
|
||||||
return prs
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
def test_list_filter():
|
||||||
def pkg_names():
|
output = list('py-*')
|
||||||
pkg_names = []
|
assert 'py-numpy' in output
|
||||||
return pkg_names
|
assert 'perl-file-copy-recursive' not in output
|
||||||
|
|
||||||
|
output = list('py-')
|
||||||
|
assert 'py-numpy' in output
|
||||||
|
assert 'perl-file-copy-recursive' in output
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.mark.maybeslow
|
||||||
def mock_name_only(monkeypatch, pkg_names):
|
def test_list_search_description():
|
||||||
|
output = list('--search-description', 'xml')
|
||||||
def name_only(x):
|
assert 'expat' in output
|
||||||
pkg_names.extend(x)
|
|
||||||
|
|
||||||
monkeypatch.setattr(spack.cmd.list, 'name_only', name_only)
|
|
||||||
monkeypatch.setitem(spack.cmd.list.formatters, 'name_only', name_only)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('mock_name_only')
|
def test_list_tags():
|
||||||
class TestListCommand(object):
|
output = list('--tags', 'proxy-app')
|
||||||
|
assert 'cloverleaf3d' in output
|
||||||
|
assert 'hdf5' not in output
|
||||||
|
|
||||||
def test_list(self, parser, pkg_names):
|
|
||||||
|
|
||||||
args = parser.parse_args([])
|
def test_list_format_name_only():
|
||||||
spack.cmd.list.list(parser, args)
|
output = list('--format', 'name_only')
|
||||||
|
assert 'cloverleaf3d' in output
|
||||||
|
assert 'hdf5' in output
|
||||||
|
|
||||||
assert pkg_names
|
|
||||||
assert 'cloverleaf3d' in pkg_names
|
|
||||||
assert 'hdf5' in pkg_names
|
|
||||||
|
|
||||||
def test_list_filter(self, parser, pkg_names):
|
@pytest.mark.maybeslow
|
||||||
args = parser.parse_args(['py-*'])
|
def test_list_format_rst():
|
||||||
spack.cmd.list.list(parser, args)
|
output = list('--format', 'rst')
|
||||||
|
assert '.. _cloverleaf3d:' in output
|
||||||
|
assert '.. _hdf5:' in output
|
||||||
|
|
||||||
assert pkg_names
|
|
||||||
assert 'py-numpy' in pkg_names
|
|
||||||
assert 'perl-file-copy-recursive' not in pkg_names
|
|
||||||
|
|
||||||
args = parser.parse_args(['py-'])
|
@pytest.mark.maybeslow
|
||||||
spack.cmd.list.list(parser, args)
|
def test_list_format_html():
|
||||||
|
output = list('--format', 'html')
|
||||||
|
assert '<div class="section" id="cloverleaf3d">' in output
|
||||||
|
assert '<h1>cloverleaf3d' in output
|
||||||
|
|
||||||
assert pkg_names
|
assert '<div class="section" id="hdf5">' in output
|
||||||
assert 'py-numpy' in pkg_names
|
assert '<h1>hdf5' in output
|
||||||
assert 'perl-file-copy-recursive' in pkg_names
|
|
||||||
|
|
||||||
@pytest.mark.maybeslow
|
|
||||||
def test_list_search_description(self, parser, pkg_names):
|
|
||||||
args = parser.parse_args(['--search-description', 'xml'])
|
|
||||||
spack.cmd.list.list(parser, args)
|
|
||||||
|
|
||||||
assert pkg_names
|
|
||||||
assert 'expat' in pkg_names
|
|
||||||
|
|
||||||
def test_list_tags(self, parser, pkg_names):
|
|
||||||
args = parser.parse_args(['--tags', 'proxy-app'])
|
|
||||||
spack.cmd.list.list(parser, args)
|
|
||||||
|
|
||||||
assert pkg_names
|
|
||||||
assert 'cloverleaf3d' in pkg_names
|
|
||||||
assert 'hdf5' not in pkg_names
|
|
||||||
|
|
||||||
@pytest.mark.maybeslow
|
|
||||||
def test_list_formatter(self, parser, pkg_names):
|
|
||||||
# TODO: Test the output of the commands
|
|
||||||
args = parser.parse_args(['--format', 'name_only'])
|
|
||||||
spack.cmd.list.list(parser, args)
|
|
||||||
|
|
||||||
args = parser.parse_args(['--format', 'rst'])
|
|
||||||
spack.cmd.list.list(parser, args)
|
|
||||||
|
|
Loading…
Reference in a new issue