# Path: firelet/cli.py
# def cli_args(mockargs=None):
# def give_help():    # pragma: no cover
# def help(s=None):
# def to_int(s):
# def deletion(table):
# def max_len(li):
# def prettyprint(li):
# def say(s):
# def open_fs(repodir):
# def main(mockargs=None):    # pragma: no cover
# 
# Path: firelet/flcore.py
# class DemoGitFireSet(GitFireSet):
#     """Based on GitFireSet. Provide a demo version without real network interaction.
#     The status of the simulated remote hosts is kept on files.
#     """
#     def __init__(self, repodir):
#         GitFireSet.__init__(self, repodir=repodir)
#         self.SSHConnector = MockSSHConnector
#         self.SSHConnector.repodir = repodir
#         self._demo_rulelist = defaultdict(list)


from logging import getLogger
from firelet import cli
from firelet.flcore import DemoGitFireSet
from testingutils import show
import os.path
import pytest
        return cli.say.output_history

    def test_basic(self, repodir):
        assert os.path.isfile(os.path.join(repodir, 'firelet_test.ini')), \
            os.listdir(repodir)
        out = self.run(repodir, '')
        assert len(out) > 5
        assert out[0].startswith('Firelet')

    def test_list(self, repodir):
        for x in ('rule', 'host', 'hostgroup', 'service', 'network'):
            out = self.run(repodir, x, 'list', '')
            assert len(out) > 3, \
                "Short or no output from cli %s list: %s" % (x, repr(out))

    def test_versioning(self, repodir):
        deb(show('started'))
        self.run(repodir, 'save_needed', '-q')
        assert cli.say.output_history == ['No'], "No save needed here" + cli.say.hist()

        self.run(repodir, 'version', 'list', '-q') # no versions
        assert cli.say.output_history == [], "No versions expected" + cli.say.hist()

        self.run(repodir, 'rule', 'disable', '2', '-q')
        assert cli.say.output_history == ['Rule 2 disabled.']

        self.run(repodir, 'save_needed', '-q')
        assert cli.say.last == 'Yes', "Save needed"

        self.run(repodir, 'save', 'test1', '-q') # save 1

# Path: firelet/cli.py
# def cli_args(mockargs=None):
# def give_help():    # pragma: no cover
# def help(s=None):
# def to_int(s):
# def deletion(table):
# def max_len(li):
# def prettyprint(li):
# def say(s):
# def open_fs(repodir):
# def main(mockargs=None):    # pragma: no cover
# 
# Path: firelet/flcore.py
# class DemoGitFireSet(GitFireSet):
#     """Based on GitFireSet. Provide a demo version without real network interaction.
#     The status of the simulated remote hosts is kept on files.
#     """
#     def __init__(self, repodir):
#         GitFireSet.__init__(self, repodir=repodir)
#         self.SSHConnector = MockSSHConnector
#         self.SSHConnector.repodir = repodir
#         self._demo_rulelist = defaultdict(list)


# Path: tests/test_cli.py
from logging import getLogger
from firelet import cli
from firelet.flcore import DemoGitFireSet
from testingutils import show
import os.path
import pytest

        return cli.say.output_history

    def test_basic(self, repodir):
        assert os.path.isfile(os.path.join(repodir, 'firelet_test.ini')), \
            os.listdir(repodir)
        out = self.run(repodir, '')
        assert len(out) > 5
        assert out[0].startswith('Firelet')

    def test_list(self, repodir):
        for x in ('rule', 'host', 'hostgroup', 'service', 'network'):
            out = self.run(repodir, x, 'list', '')
            assert len(out) > 3, \
                "Short or no output from cli %s list: %s" % (x, repr(out))

    def test_versioning(self, repodir):
        deb(show('started'))
        self.run(repodir, 'save_needed', '-q')
        assert cli.say.output_history == ['No'], "No save needed here" + cli.say.hist()

        self.run(repodir, 'version', 'list', '-q') # no versions
        assert cli.say.output_history == [], "No versions expected" + cli.say.hist()

        self.run(repodir, 'rule', 'disable', '2', '-q')
        assert cli.say.output_history == ['Rule 2 disabled.']

        self.run(repodir, 'save_needed', '-q')
        assert cli.say.last == 'Yes', "Save needed"

        self.run(repodir, 'save', 'test1', '-q') # save 1

        assert cli.say.output_history == ['Configuration saved. Message: "test1"']