from piper import build
from piper.db import core as db
from piper.cli import cmd_piper

import mock


class TestEntry(object):
    @mock.patch('piper.cli.cmd_piper.CLIBase')
    def test_calls(self, clibase):
        self.mock = mock.Mock()
        cmd_piper.entry(self.mock)
        clibase.assert_called_once_with(
            'piper',
            (build.ExecCLI, db.DbCLI),
            args=self.mock
        )
        clibase.return_value.entry.assert_called_once_with()

    @mock.patch('piper.cli.cmd_piper.CLIBase')
    def test_return_value(self, clibase):
        ret = cmd_piper.entry()
        assert ret is clibase.return_value.entry.return_value

@@ -80,16 +80,50 @@
 md_piper
+%0Afrom piper.cli.cli import CLIBase
 %0A%0Aimport
@@ -687,8 +687,275 @@
 n_value%0A
+%0A%0Aclass TestEntryIntegration(object):%0A    def test_db_init(self):%0A        args = %5B'db', 'init'%5D%0A        cli = CLIBase('piper', (db.DbCLI,), args=args)%0A%0A        db.DbCLI.db = mock.Mock()%0A        cli.entry()%0A        db.DbCLI.db.init.assert_called_once_with(cli.config)%0A

Add integration test for db init