def test_all(app: Application): commands = app.all() assert isinstance(commands["help"], Command) app.add(FooCommand()) assert len(app.all("foo")) == 1
def test_add(app: Application): foo = FooCommand() app.add(foo) commands = app.all() assert [commands["foo bar"]] == [foo] foo1 = Foo1Command() app.add(foo1) commands = app.all() assert [commands["foo bar"], commands["foo bar1"]] == [foo, foo1]
def test_all(self): """ Application.get_all() returns all comands of the application """ application = Application() commands = application.all() self.assertEqual( "HelpCommand", commands["help"].__class__.__name__, msg=".all() returns the registered commands" ) application.add(FooCommand()) self.assertEqual(1, len(application.all("foo")), msg=".all() take a namespace as first argument")
def test_all(self): """ Application.get_all() returns all comands of the application """ application = Application() commands = application.all() self.assertEqual('HelpCommand', commands['help'].__class__.__name__, msg='.all() returns the registered commands') application.add(FooCommand()) self.assertEqual(1, len(application.all('foo')), msg='.all() take a namespace as first argument')
def test_add(self): """ Application.add() and .addCommands() register commands """ application = Application() foo = FooCommand() application.add(foo) self.assertEqual(foo, application.all()["foo:bar"], msg=".add() registers a command") application = Application() foo, foo1 = FooCommand(), Foo1Command() application.add_commands([foo, foo1]) commands = application.all() self.assertEqual( [foo, foo1], [commands["foo:bar"], commands["foo:bar1"]], msg=".add_commands() registers a list of commands" )
def test_add(self): """ Application.add() and .addCommands() register commands """ application = Application() foo = FooCommand() application.add(foo) self.assertEqual(foo, application.all()['foo:bar'], msg='.add() registers a command') application = Application() foo, foo1 = FooCommand(), Foo1Command() application.add_commands([foo, foo1]) commands = application.all() self.assertEqual([foo, foo1], [commands['foo:bar'], commands['foo:bar1']], msg='.add_commands() registers a list of commands')
def test_constructor(self): """ Application.__init__() behaves properly """ application = Application('foo', 'bar') self.assertEqual('foo', application.get_name(), msg='__init__() takes the application name as its first argument') self.assertEqual('bar', application.get_version(), msg='__init__() takes the application version as its second argument') self.assertEqual(['help', 'list'].sort(), list(application.all().keys()).sort(), msg='__init__() registered the help and list commands by default')
def test_constructor(self): """ Application.__init__() behaves properly """ application = Application("foo", "bar") self.assertEqual( "foo", application.get_name(), msg="__init__() takes the application name as its first argument" ) self.assertEqual( "bar", application.get_version(), msg="__init__() takes the application version as its second argument" ) self.assertEqual( ["help", "list"].sort(), list(application.all().keys()).sort(), msg="__init__() registered the help and list commands by default", )