# Path: uamobile/ezweb.py
# class EZwebUserAgent(UserAgent):
#     carrier = 'EZweb'
#     short_carrier = 'E'
# 
#     def get_flash_version(self):
#         """
#         returns Flash Lite version.
#         """
#         from uamobile.data.flash.ezweb import DATA
#         try:
#             return DATA[self.model]
#         except KeyError:
#             return '2.0'
#     flash_version = property(get_flash_version)
# 
#     def supports_cookie(self):
#         return True
# 
#     def make_display(self):
#         """
#         create a Display object.
#         """
#         env = self.environ
#         try:
#             width, height = map(int, env['HTTP_X_UP_DEVCAP_SCREENPIXELS'].split(',', 1))
#         except (KeyError, ValueError), e:
#             width = None
#             height = None
# 
#         try:
#             color = env['HTTP_X_UP_DEVCAP_ISCOLOR'] == '1'
#         except KeyError:
#             color = False
# 
#         try:
#             sd = env['HTTP_X_UP_DEVCAP_SCREENDEPTH'].split(',', 1)
#             depth = sd[0] and (2 ** int(sd[0])) or 0
#         except (KeyError, ValueError):
#             depth = None
# 
#         return Display(width=width, height=height, color=color, depth=depth)
# 
#     def is_ezweb(self):
#         return True
# 
#     def get_serialnumber(self):
#         """
#         return the EZweb subscriber ID.
#         if no subscriber ID is available, returns None.
#         """
#         try:
#             return self.environ['HTTP_X_UP_SUBNO']
#         except KeyError:
#             return None
#     serialnumber = property(get_serialnumber)
# 
#     def is_xhtml_compliant(self):
#         """
#         returns whether it's XHTML compliant or not.
#         """
#         return self.xhtml_compliant
# 
#     def is_win(self):
#         """
#         returns whether the agent is CDMA 1X WIN or not.
#         """
#         return self.device_id[2:3] == '3'
# 
#     def is_wap1(self):
#         return not self.is_wap2()
# 
#     def is_wap2(self):
#         return self.xhtml_compliant
# 
# Path: uamobile/factory/ezweb.py
# class EZwebUserAgentFactory(AbstractUserAgentFactory):
#     device_class = EZwebUserAgent
#     parser       = CachingEZwebUserAgentParser()


from tests import msg
from uamobile import *
from uamobile.ezweb import EZwebUserAgent
from uamobile.factory.ezweb import EZwebUserAgentFactory

    env = dict(base_env)
    env['HTTP_X_UP_DEVCAP_SCREENDEPTH'] = 'spam'
    ua = detect(env)
    assert ua.display.width == 240
    assert ua.display.height == 268
    assert ua.display.color
    assert ua.display.depth is None

def test_useragent_ezweb():
    def inner(useragent, version, model, device_id, server, xhtml_compliant, comment, is_wap1, is_wap2, is_win):
        ua = detect({'HTTP_USER_AGENT':useragent})
        assert ua.carrier == 'EZweb'
        assert ua.short_carrier == 'E'
        assert ua.is_docomo() == False
        assert ua.is_ezweb()
        assert ua.is_softbank() == False
        assert ua.is_vodafone() == False
        assert ua.is_jphone() == False
        assert ua.is_willcom() == False
        assert ua.model == model, msg(ua, ua.model, model)
        assert ua.version == version, msg(ua, ua.version, version)
        assert ua.device_id == device_id, msg(ua, ua.device_id, device_id)
        assert ua.server == server, msg(ua, ua.server, server)
        assert ua.comment == comment, msg(ua, ua.comment, comment)
        assert ua.is_xhtml_compliant() == xhtml_compliant
        assert ua.is_wap1() == is_wap1
        assert ua.is_wap2() == is_wap2
        assert ua.is_win() == is_win
        assert ua.display is not None

# Path: uamobile/ezweb.py
# class EZwebUserAgent(UserAgent):
#     carrier = 'EZweb'
#     short_carrier = 'E'
# 
#     def get_flash_version(self):
#         """
#         returns Flash Lite version.
#         """
#         from uamobile.data.flash.ezweb import DATA
#         try:
#             return DATA[self.model]
#         except KeyError:
#             return '2.0'
#     flash_version = property(get_flash_version)
# 
#     def supports_cookie(self):
#         return True
# 
#     def make_display(self):
#         """
#         create a Display object.
#         """
#         env = self.environ
#         try:
#             width, height = map(int, env['HTTP_X_UP_DEVCAP_SCREENPIXELS'].split(',', 1))
#         except (KeyError, ValueError), e:
#             width = None
#             height = None
# 
#         try:
#             color = env['HTTP_X_UP_DEVCAP_ISCOLOR'] == '1'
#         except KeyError:
#             color = False
# 
#         try:
#             sd = env['HTTP_X_UP_DEVCAP_SCREENDEPTH'].split(',', 1)
#             depth = sd[0] and (2 ** int(sd[0])) or 0
#         except (KeyError, ValueError):
#             depth = None
# 
#         return Display(width=width, height=height, color=color, depth=depth)
# 
#     def is_ezweb(self):
#         return True
# 
#     def get_serialnumber(self):
#         """
#         return the EZweb subscriber ID.
#         if no subscriber ID is available, returns None.
#         """
#         try:
#             return self.environ['HTTP_X_UP_SUBNO']
#         except KeyError:
#             return None
#     serialnumber = property(get_serialnumber)
# 
#     def is_xhtml_compliant(self):
#         """
#         returns whether it's XHTML compliant or not.
#         """
#         return self.xhtml_compliant
# 
#     def is_win(self):
#         """
#         returns whether the agent is CDMA 1X WIN or not.
#         """
#         return self.device_id[2:3] == '3'
# 
#     def is_wap1(self):
#         return not self.is_wap2()
# 
#     def is_wap2(self):
#         return self.xhtml_compliant
# 
# Path: uamobile/factory/ezweb.py
# class EZwebUserAgentFactory(AbstractUserAgentFactory):
#     device_class = EZwebUserAgent
#     parser       = CachingEZwebUserAgentParser()


# Path: tests/test_ezweb.py
from tests import msg
from uamobile import *
from uamobile.ezweb import EZwebUserAgent
from uamobile.factory.ezweb import EZwebUserAgentFactory


    env = dict(base_env)
    env['HTTP_X_UP_DEVCAP_SCREENDEPTH'] = 'spam'
    ua = detect(env)
    assert ua.display.width == 240
    assert ua.display.height == 268
    assert ua.display.color
    assert ua.display.depth is None

def test_useragent_ezweb():
    def inner(useragent, version, model, device_id, server, xhtml_compliant, comment, is_wap1, is_wap2, is_win):
        ua = detect({'HTTP_USER_AGENT':useragent})
        assert ua.carrier == 'EZweb'
        assert ua.short_carrier == 'E'
        assert ua.is_docomo() == False
        assert ua.is_ezweb()
        assert ua.is_softbank() == False
        assert ua.is_vodafone() == False
        assert ua.is_jphone() == False
        assert ua.is_willcom() == False
        assert ua.model == model, msg(ua, ua.model, model)
        assert ua.version == version, msg(ua, ua.version, version)
        assert ua.device_id == device_id, msg(ua, ua.device_id, device_id)
        assert ua.server == server, msg(ua, ua.server, server)
        assert ua.comment == comment, msg(ua, ua.comment, comment)
        assert ua.is_xhtml_compliant() == xhtml_compliant
        assert ua.is_wap1() == is_wap1
        assert ua.is_wap2() == is_wap2
        assert ua.is_win() == is_win
        assert ua.display is not None

        assert ua.supports_cookie() == True