コード例 #1
0
ファイル: test_application.py プロジェクト: meschac38700/cleo
def test_all(app: Application):
    commands = app.all()

    assert isinstance(commands["help"], Command)

    app.add(FooCommand())

    assert len(app.all("foo")) == 1
コード例 #2
0
ファイル: test_application.py プロジェクト: meschac38700/cleo
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]
コード例 #3
0
ファイル: test_application.py プロジェクト: onema/cleo
    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")
コード例 #4
0
    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')
コード例 #5
0
ファイル: test_application.py プロジェクト: onema/cleo
    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"
        )
コード例 #6
0
    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')
コード例 #7
0
    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')
コード例 #8
0
ファイル: test_application.py プロジェクト: onema/cleo
    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",
        )