# 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

    def test_bad_endpoint(self):
        cli = self._makeFUT([
            "--router_tablename=fred",
            "http://someendpoint",
        ])
        returncode = cli.run()
        assert returncode not in (None, 0)

    def test_invalid_endpoint(self):
        def err(*args, **kwargs):
            raise InvalidToken("You are unworthy")

        cli = self._makeFUT([
            "--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()

# 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


    def test_bad_endpoint(self):
        cli = self._makeFUT([
            "--router_tablename=fred",
            "http://someendpoint",
        ])
        returncode = cli.run()
        assert returncode not in (None, 0)

    def test_invalid_endpoint(self):
        def err(*args, **kwargs):
            raise InvalidToken("You are unworthy")

        cli = self._makeFUT([
            "--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