# Path: autopush/tests/test_integration.py
# def _get_vapid(key=None, payload=None, endpoint="http://localhost"):
#     if not payload:
#         payload = {"aud": endpoint,
#                    "exp": int(time.time()) + 86400,
#                    "sub": "mailto:admin@example.com"}
#     if not key:
#         key = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
#     vk = key.get_verifying_key()
#     auth = jws.sign(payload, key, algorithm="ES256").strip('=')
#     crypto_key = base64url_encode('\4' + vk.to_string())
#     return {"auth": auth,
#             "crypto-key": crypto_key,
#             "key": key}


import unittest
        import requests
        import requests
from mock import patch, Mock
from autopush.tests.test_integration import _get_vapid
        from autopush.utils import parse_user_agent
        from autopush.utils import extract_jwt
        from autopush.utils import get_amid
        from autopush.utils import get_ec2_instance_id
        from autopush.utils import get_ec2_instance_id




class TestUserAgentParser(unittest.TestCase):
    def _makeFUT(self, *args):
        return parse_user_agent(*args)

    def test_linux_extraction(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090807 Mandriva Linux/1.9.1.2-1.1mud2009.1 (2009.1) Firefox/3.5.2 FirePHP/0.3,gzip(gfe),gzip(gfe)')  # NOQA
        assert dd["ua_os_family"] == "Linux"
        assert raw["ua_os_family"] == "Mandriva"

    def test_windows_extraction(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)')  # NOQA
        assert dd["ua_os_family"] == "Windows"
        assert raw["ua_os_family"] == "Windows"

    def test_valid_os(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.1.1) Gecko/ Firefox/5.0.1')  # NOQA

# Path: autopush/tests/test_integration.py
# def _get_vapid(key=None, payload=None, endpoint="http://localhost"):
#     if not payload:
#         payload = {"aud": endpoint,
#                    "exp": int(time.time()) + 86400,
#                    "sub": "mailto:admin@example.com"}
#     if not key:
#         key = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
#     vk = key.get_verifying_key()
#     auth = jws.sign(payload, key, algorithm="ES256").strip('=')
#     crypto_key = base64url_encode('\4' + vk.to_string())
#     return {"auth": auth,
#             "crypto-key": crypto_key,
#             "key": key}


# Path: autopush/tests/test_utils.py
import unittest
        import requests
        import requests
from mock import patch, Mock
from autopush.tests.test_integration import _get_vapid
        from autopush.utils import parse_user_agent
        from autopush.utils import extract_jwt
        from autopush.utils import get_amid
        from autopush.utils import get_ec2_instance_id
        from autopush.utils import get_ec2_instance_id





class TestUserAgentParser(unittest.TestCase):
    def _makeFUT(self, *args):
        return parse_user_agent(*args)

    def test_linux_extraction(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090807 Mandriva Linux/1.9.1.2-1.1mud2009.1 (2009.1) Firefox/3.5.2 FirePHP/0.3,gzip(gfe),gzip(gfe)')  # NOQA
        assert dd["ua_os_family"] == "Linux"
        assert raw["ua_os_family"] == "Mandriva"

    def test_windows_extraction(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)')  # NOQA
        assert dd["ua_os_family"] == "Windows"
        assert raw["ua_os_family"] == "Windows"

    def test_valid_os(self):
        dd, raw = self._makeFUT('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.1.1) Gecko/ Firefox/5.0.1')  # NOQA

        assert dd["ua_os_family"] == "Mac OS X"