# Path: autopush/exceptions.py
# class ItemNotFound(Exception):
#     """Signals missing DynamoDB Item data"""


import unittest
import autopush.tests
from mock import Mock, patch
from cryptography.fernet import InvalidToken
from autopush.exceptions import ItemNotFound
        from autopush.diagnostic_cli import EndpointDiagnosticCLI
        from autopush.diagnostic_cli import run_endpoint_diagnostic_cli
        from autopush.diagnostic_cli import EndpointDiagnosticCLI
            "--router_tablename=fred",
            "http://something/wpush/v1/indecipherable_token"])
        cli._conf = Mock()
        cli._conf.parse_endpoint.side_effect = err
        returncode = cli.run()
        assert returncode == "Invalid Token"

    def test_invalid_db(self):
        cli = self._makeFUT([
            "--router_tablename=fred",
            "http://something/wpush/v1/indecipherable_token"])
        cli._conf = Mock()
        cli._conf.parse_endpoint.return_value = dict(
            uaid="adsf", chid="adsf"
        )
        cli.db.router.get_uaid = Mock()
        cli.db.router.get_uaid.side_effect = ItemNotFound
        returncode = cli.run()
        assert returncode == "Not Found"

    @patch("autopush.diagnostic_cli.Message")
    @patch("autopush.diagnostic_cli.AutopushConfig")
    @patch("autopush.diagnostic_cli.DatabaseManager.from_config")
    def test_successfull_lookup(self, mock_db_cstr, mock_conf_class, mock_msg):
        mock_conf_class.return_value = mock_conf = Mock()
        mock_conf.parse_endpoint.return_value = dict(
            uaid="asdf", chid="asdf")

        mock_db_cstr.return_value = mock_db = Mock()
        mock_db.router.get_uaid.return_value = mock_item = FakeDict()

# Path: autopush/exceptions.py
# class ItemNotFound(Exception):
#     """Signals missing DynamoDB Item data"""


# Path: autopush/tests/test_diagnostic_cli.py
import unittest
import autopush.tests
from mock import Mock, patch
from cryptography.fernet import InvalidToken
from autopush.exceptions import ItemNotFound
        from autopush.diagnostic_cli import EndpointDiagnosticCLI
        from autopush.diagnostic_cli import run_endpoint_diagnostic_cli
        from autopush.diagnostic_cli import EndpointDiagnosticCLI

            "--router_tablename=fred",
            "http://something/wpush/v1/indecipherable_token"])
        cli._conf = Mock()
        cli._conf.parse_endpoint.side_effect = err
        returncode = cli.run()
        assert returncode == "Invalid Token"

    def test_invalid_db(self):
        cli = self._makeFUT([
            "--router_tablename=fred",
            "http://something/wpush/v1/indecipherable_token"])
        cli._conf = Mock()
        cli._conf.parse_endpoint.return_value = dict(
            uaid="adsf", chid="adsf"
        )
        cli.db.router.get_uaid = Mock()
        cli.db.router.get_uaid.side_effect = ItemNotFound
        returncode = cli.run()
        assert returncode == "Not Found"

    @patch("autopush.diagnostic_cli.Message")
    @patch("autopush.diagnostic_cli.AutopushConfig")
    @patch("autopush.diagnostic_cli.DatabaseManager.from_config")
    def test_successfull_lookup(self, mock_db_cstr, mock_conf_class, mock_msg):
        mock_conf_class.return_value = mock_conf = Mock()
        mock_conf.parse_endpoint.return_value = dict(
            uaid="asdf", chid="asdf")

        mock_db_cstr.return_value = mock_db = Mock()
        mock_db.router.get_uaid.return_value = mock_item = FakeDict()

        mock_item._data = {}