# Path: uamobile/willcom.py
# class WillcomUserAgent(UserAgent):
#     name = 'WILLCOM'
#     carrier = 'WILLCOM'
#     short_carrier = 'W'
# 
#     def __init__(self, *args, **kwds):
#         super(WillcomUserAgent, self).__init__(*args, **kwds)
#         self.serialnumber = None
#         self.model_version = None
#         self.browser_version = None
# 
#     def get_flash_version(self):
#         """
#         returns Flash Lite version.
#         """
#         return None
#     flash_version = property(get_flash_version)
# 
#     def supports_cookie(self):
#         # TODO
#         # I'm not sure All WILLCOM phones can handle HTTP cookie.
#         return True
# 
#     def make_display(self):
#         """
#         create a new Display object.
#         """
#         return Display()
# 
#     def is_willcom(self):
#         return True
# 
#     def is_airhphone(self):
#         return True
# 
# Path: uamobile/factory/willcom.py
# class WillcomUserAgentFactory(AbstractUserAgentFactory):
#     device_class = WillcomUserAgent
#     parser       = CachingWillcomUserAgentParser()


from tests import msg
from uamobile import *
from uamobile.willcom import WillcomUserAgent
from uamobile.factory.willcom import WillcomUserAgentFactory

    for ip, expected in (
        ('210.230.128.224', True),
        ('61.198.128.0', False),
        ):
        yield func, ip, expected

def test_extra_ip():
    ctxt1 = Context(extra_willcom_ips=['192.168.0.0/24'])
    ua = detect({'HTTP_USER_AGENT': 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.7.17.000000/0.1/C100) Opera 7.0',
                 'REMOTE_ADDR'    : '192.168.0.1',
                 },
                context=ctxt1)
    assert ua.is_willcom()
    assert ua.is_bogus() is False

    ctxt2 = Context(extra_willcom_ips=[])
    ua = detect({'HTTP_USER_AGENT': 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.7.17.000000/0.1/C100) Opera 7.0',
                 'REMOTE_ADDR'    : '192.168.0.1',
                 },
                context=ctxt2)
    assert ua.is_willcom()
    assert ua.is_bogus() is True


def test_my_factory():
    class MyWillcomUserAgent(WillcomUserAgent):
        def get_my_attr(self):
            return self.environ.get('HTTP_X_DOCOMO_UID')


# Path: uamobile/willcom.py
# class WillcomUserAgent(UserAgent):
#     name = 'WILLCOM'
#     carrier = 'WILLCOM'
#     short_carrier = 'W'
# 
#     def __init__(self, *args, **kwds):
#         super(WillcomUserAgent, self).__init__(*args, **kwds)
#         self.serialnumber = None
#         self.model_version = None
#         self.browser_version = None
# 
#     def get_flash_version(self):
#         """
#         returns Flash Lite version.
#         """
#         return None
#     flash_version = property(get_flash_version)
# 
#     def supports_cookie(self):
#         # TODO
#         # I'm not sure All WILLCOM phones can handle HTTP cookie.
#         return True
# 
#     def make_display(self):
#         """
#         create a new Display object.
#         """
#         return Display()
# 
#     def is_willcom(self):
#         return True
# 
#     def is_airhphone(self):
#         return True
# 
# Path: uamobile/factory/willcom.py
# class WillcomUserAgentFactory(AbstractUserAgentFactory):
#     device_class = WillcomUserAgent
#     parser       = CachingWillcomUserAgentParser()


# Path: tests/test_willcom.py
from tests import msg
from uamobile import *
from uamobile.willcom import WillcomUserAgent
from uamobile.factory.willcom import WillcomUserAgentFactory


    for ip, expected in (
        ('210.230.128.224', True),
        ('61.198.128.0', False),
        ):
        yield func, ip, expected

def test_extra_ip():
    ctxt1 = Context(extra_willcom_ips=['192.168.0.0/24'])
    ua = detect({'HTTP_USER_AGENT': 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.7.17.000000/0.1/C100) Opera 7.0',
                 'REMOTE_ADDR'    : '192.168.0.1',
                 },
                context=ctxt1)
    assert ua.is_willcom()
    assert ua.is_bogus() is False

    ctxt2 = Context(extra_willcom_ips=[])
    ua = detect({'HTTP_USER_AGENT': 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.7.17.000000/0.1/C100) Opera 7.0',
                 'REMOTE_ADDR'    : '192.168.0.1',
                 },
                context=ctxt2)
    assert ua.is_willcom()
    assert ua.is_bogus() is True


def test_my_factory():
    class MyWillcomUserAgent(WillcomUserAgent):
        def get_my_attr(self):
            return self.environ.get('HTTP_X_DOCOMO_UID')


    class MyWillcomUserAgentFactory(WillcomUserAgentFactory):