[tests/config] Add tests for helptexts
Ensure that each theme is listed in the helptext and that there is a helptext entry for every module.
This commit is contained in:
parent
4f7666533c
commit
9a350ddc2a
2 changed files with 26 additions and 1 deletions
|
@ -4,6 +4,7 @@ This module provides configuration information (loaded modules,
|
|||
module parameters, etc.) to all other components
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import textwrap
|
||||
import importlib
|
||||
|
@ -26,7 +27,7 @@ class print_usage(argparse.Action):
|
|||
self.print_themes()
|
||||
else:
|
||||
parser.print_help()
|
||||
parser.exit()
|
||||
sys.exit(0)
|
||||
|
||||
def print_themes(self):
|
||||
print(textwrap.fill(", ".join(bumblebee.theme.themes()),
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
# pylint: disable=C0103,C0111
|
||||
|
||||
import unittest
|
||||
import mock
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
from bumblebee.config import Config
|
||||
from bumblebee.theme import themes
|
||||
from bumblebee.engine import all_modules
|
||||
|
||||
class TestConfig(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -25,4 +33,20 @@ class TestConfig(unittest.TestCase):
|
|||
"name": x.split(":")[1],
|
||||
} for x in self.someAliasModules])
|
||||
|
||||
@mock.patch("sys.stdout", new_callable=StringIO)
|
||||
@mock.patch("sys.exit")
|
||||
def test_list_themes(self, exit, stdout):
|
||||
cfg = Config(["-l", "themes"])
|
||||
result = stdout.getvalue()
|
||||
for theme in themes():
|
||||
self.assertTrue(theme in result)
|
||||
|
||||
@mock.patch("sys.stdout", new_callable=StringIO)
|
||||
@mock.patch("sys.exit")
|
||||
def test_list_modules(self, exit, stdout):
|
||||
cfg = Config(["-l", "modules"])
|
||||
result = stdout.getvalue()
|
||||
for module in all_modules():
|
||||
self.assertTrue(module["name"] in result)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Reference in a new issue