# Path: osprofiler/cmd/shell.py
# class OSProfilerShell(object):
#     def __init__(self, argv):
#     def _get_base_parser(self):
#     def _append_subcommands(self, parent_parser):
#     def _no_project_and_domain_set(self, args):
# def main(args=None):
# 
# Path: osprofiler/exc.py
# class CommandError(Exception):
# class LogInsightAPIError(Exception):
# class LogInsightLoginTimeout(Exception):
#     def __init__(self, message=None):
#     def __str__(self):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):


import io
import json
import os
import sys
import ddt
from unittest import mock
from osprofiler.cmd import shell
from osprofiler import exc
from osprofiler.tests import test

    def _test_with_command_error(self, cmd, expected_message):
        try:
            self.run_command(cmd)
        except exc.CommandError as actual_error:
            self.assertEqual(str(actual_error), expected_message)
        else:
            raise ValueError(
                "Expected: `osprofiler.exc.CommandError` is raised with "
                "message: '%s'." % expected_message)

    @mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
    def test_trace_show_no_selected_format(self, mock_get):
        mock_get.return_value = self._create_mock_notifications()
        msg = ("You should choose one of the following output formats: "
               "json, html or dot.")
        self._test_with_command_error(self._trace_show_cmd(), msg)

    @mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
    @ddt.data(None, {"info": {"started": 0, "finished": 1, "name": "total"},
                     "children": []})
    def test_trace_show_trace_id_not_found(self, notifications, mock_get):
        mock_get.return_value = notifications

        msg = ("Trace with UUID %s not found. Please check the HMAC key "
               "used in the command." % self.TRACE_ID)

        self._test_with_command_error(self._trace_show_cmd(), msg)

    def _create_mock_notifications(self):

# Path: osprofiler/cmd/shell.py
# class OSProfilerShell(object):
#     def __init__(self, argv):
#     def _get_base_parser(self):
#     def _append_subcommands(self, parent_parser):
#     def _no_project_and_domain_set(self, args):
# def main(args=None):
# 
# Path: osprofiler/exc.py
# class CommandError(Exception):
# class LogInsightAPIError(Exception):
# class LogInsightLoginTimeout(Exception):
#     def __init__(self, message=None):
#     def __str__(self):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):


# Path: osprofiler/tests/unit/cmd/test_shell.py
import io
import json
import os
import sys
import ddt
from unittest import mock
from osprofiler.cmd import shell
from osprofiler import exc
from osprofiler.tests import test


    def _test_with_command_error(self, cmd, expected_message):
        try:
            self.run_command(cmd)
        except exc.CommandError as actual_error:
            self.assertEqual(str(actual_error), expected_message)
        else:
            raise ValueError(
                "Expected: `osprofiler.exc.CommandError` is raised with "
                "message: '%s'." % expected_message)

    @mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
    def test_trace_show_no_selected_format(self, mock_get):
        mock_get.return_value = self._create_mock_notifications()
        msg = ("You should choose one of the following output formats: "
               "json, html or dot.")
        self._test_with_command_error(self._trace_show_cmd(), msg)

    @mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
    @ddt.data(None, {"info": {"started": 0, "finished": 1, "name": "total"},
                     "children": []})
    def test_trace_show_trace_id_not_found(self, notifications, mock_get):
        mock_get.return_value = notifications

        msg = ("Trace with UUID %s not found. Please check the HMAC key "
               "used in the command." % self.TRACE_ID)

        self._test_with_command_error(self._trace_show_cmd(), msg)

    def _create_mock_notifications(self):

        notifications = {