Skip to content

Instantly share code, notes, and snippets.

@tfhartmann
Last active December 28, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfhartmann/7553441 to your computer and use it in GitHub Desktop.
Save tfhartmann/7553441 to your computer and use it in GitHub Desktop.
nepho_nosetests
from cement.core import handler, hook, foundation
from cement.utils import test
from nepho import cli
from nepho.cli.base import Nepho

class MyTestApp(Nepho):
    class Meta:
        # Load the base Nepho cement controller
        app = cli.base.Nepho()

        # Subcontrollers for each functional component
        handler.register(cli.cloudlet.NephoCloudletController)
        handler.register(cli.blueprint.NephoBlueprintController)
        handler.register(cli.stack.NephoStackController)
        handler.register(cli.config.NephoConfigController)
        handler.register(cli.parameter.NephoParameterController)
        handler.register(cli.scope.NephoScopeController)

        hook.register('post_argument_parsing', cli.hooks.set_scope)
        hook.register('post_setup', cli.hooks.process_config)

        argv = []
        config_files = []


class MyTestCase(test.CementTestCase):
    app_class = MyTestApp

#    def test_nepho_default(self):
#        self.app.setup()
#        self.app.run()
#        self.app.close()

    def test_nepho_config_list(self):
        app = self.make_app(argv=['config', 'list'])
        app.setup()
        app.run()
        app.close()

And my errors :(

(nepho)[alaric@preator nepho (master)]$ nosetests -v
test_nepho_config_list (nepho_test.MyTestCase) ... usage: nepho <command> <action> [options]
nosetests: error: unrecognized arguments: config list
ERROR

======================================================================
ERROR: test_nepho_config_list (nepho_test.MyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/alaric/Projects/nepho/tests/nepho_test.py", line 37, in test_nepho_config_list
    app.run()
  File "/Users/alaric/.virtualenvs/nepho/lib/python2.7/site-packages/cement-2.1.4.dev20131029203905-py2.7.egg/cement/core/foundation.py", line 493, in run
    self.controller._dispatch()
  File "/Users/alaric/.virtualenvs/nepho/lib/python2.7/site-packages/cement-2.1.4.dev20131029203905-py2.7.egg/cement/core/controller.py", line 451, in _dispatch
    self._parse_args()
  File "/Users/alaric/.virtualenvs/nepho/lib/python2.7/site-packages/cement-2.1.4.dev20131029203905-py2.7.egg/cement/core/controller.py", line 432, in _parse_args
    self.app._parse_args()
  File "/Users/alaric/.virtualenvs/nepho/lib/python2.7/site-packages/cement-2.1.4.dev20131029203905-py2.7.egg/cement/core/foundation.py", line 647, in _parse_args
    self._parsed_args = self.args.parse(self.argv)
  File "/Users/alaric/.virtualenvs/nepho/lib/python2.7/site-packages/cement-2.1.4.dev20131029203905-py2.7.egg/cement/ext/ext_argparse.py", line 47, in parse
    return self.parse_args(arg_list)
  File "build/bdist.macosx-10.8-intel/egg/argparse.py", line 1706, in parse_args
    self.error(msg % ' '.join(argv))
  File "build/bdist.macosx-10.8-intel/egg/argparse.py", line 2362, in error
    self.exit(2, _('%s: error: %s\n') % (self.prog, message))
  File "build/bdist.macosx-10.8-intel/egg/argparse.py", line 2350, in exit
    _sys.exit(status)
SystemExit: 2

----------------------------------------------------------------------
Ran 1 test in 0.159s

FAILED (errors=1)

CLI Output

(nepho)[alaric@preator nepho (master)]$ nepho config list
--------------------------------------------------------------------------------
 archive_dir:  "/Users/alaric/.nepho/archive"
 cache_dir:  "/Users/alaric/.nepho/cache"
 cloudlet_clone_proto:  "https"
 cloudlet_dirs:  ['/Users/alaric/.nepho/cloudlets']
 cloudlet_registry_url:  "http://cloudlets.github.io/registry.yaml"
 local_config:  "/Users/alaric/.nepho/local/config.yaml"
 local_dir:  "/Users/alaric/.nepho/local"
 tmp_dir:  "/Users/alaric/.nepho/tmp"
--------------------------------------------------------------------------------
(nepho)[alaric@preator nepho (master)]$ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment