>>> from __future__ import print_function
>>> from cpe.cpe import CPE
>>> from cpe.cpe2_2 import CPE2_2
>>> from cpe.comp.cpecomp import CPEComponent

----------------------------------
Test for _get_attribute_values(self)
----------------------------------

TEST:
>>> str = 'cpe:/a:mozilla:firefox:2.0.0.6::osx:zh-tw'
>>> c = CPE2_2(str)
>>> att = CPEComponent.ATT_VENDOR
>>> c.get_attribute_values(att)
['mozilla']
>>> att = CPEComponent.ATT_LANGUAGE
>>> c.get_attribute_values(att)
['zh-tw']


-----------------------------------------------
Test for __getitem__(self, i)
-----------------------------------------------

- TEST: good index
>>> str = 'cpe:/a:mozilla:firefox:2.0.0.6::osx:zh-tw'
>>> c = CPE2_2(str)
>>> c[1]
CPEComponent2_2(mozilla)

- TEST: bad index
>>> str = 'cpe:/a:mozilla:firefox:2.0.0.6::osx:zh-tw'
>>> c = CPE2_2(str)
>>> c[8]  #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
IndexError: Component index of CPE name out of range

- TEST: bad index
>>> str = 'cpe:/'
>>> c = CPE2_2(str)
>>> c[0]  #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
IndexError: Component index of CPE name out of range


-----------------------------------------------
Test for __new__(cls, cpe_str, *args, **kwargs)
-----------------------------------------------

- TEST: an empty hardware part, and no OS or application part.
>>> str = 'cpe:/'
>>> c = CPE2_2(str)

- TEST: an operation system. The CPE Name below designates all Professional editions of Microsoft Windows XP, regardless of service pack level.
>>> str = 'cpe:/o:microsoft:windows_xp:::pro'
>>> c = CPE2_2(str)

- TEST: an application
>>> str = 'cpe:/a:acme:product:1.0:update2:-:en-us'
>>> c = CPE2_2(str)

- TEST: an application
>>> str = 'cpe:/a:acme:product:1.0:update2::en-us'
>>> c = CPE2_2(str)

- TEST: an application
>>> str = 'cpe:/a:acme:product:1.0:update2:pro:en-us'
>>> c = CPE2_2(str)

- TEST: an application. The vendor Best Software may not have a qualified DNS name, so a CPE Name for their application ABC123 would be as follows:
>>> str = 'cpe:/a:best_software:abc123'
>>> c = CPE2_2(str)

- TEST: For applications that do not have a vendor or organization associated
with them, this component  should use a developer's name. Note that multi-word names should use underscores instead of spaces.
>>> str = 'cpe:/a:jon_smith:tool_name:1.2.3'
>>> c = CPE2_2(str)

- TEST: an application. Multi-word product names and designations should be
spelled out in full, replacing spaces with underscores.
The example below shows how this would look for the Zone Labs ZoneAlarm
Internet Security Suite version 7.0.
>>> str = 'cpe:/a:zonelabs:zonealarm_internet_security_suite:7.0'
>>> c = CPE2_2(str)

- TEST: The following example denotes Adobe Reader version 8.1
>>> str = 'cpe:/a:adobe:reader:8.1'
>>> c = CPE2_2(str)

- TEST: The following example denotes Red Hat Enterprise Linux 4.0 Update 4.
>>> str = 'cpe:/o:redhat:enterprise_linux:4:update4'
>>> c = CPE2_2(str)

- TEST: CPE Name of Red Hat operating system with initial release of
Enterprise Linux 4
>>> str = 'cpe:/o:redhat:enterprise_linux:4:ga'
>>> c = CPE2_2(str)

- TEST: an operating system
>>> str = 'cpe:/o:microsoft:windows_2000::sp4:pro'
>>> c = CPE2_2(str)

- TEST: an application
>>> str = 'cpe:/a:mozilla:firefox:2.0.0.6::osx:zh-tw'
>>> c = CPE2_2(str)

- TEST: This example name below represents a typical CPE Name that refers to
the Microsoft Windows 2000 operating system, all editions and update levels.
>>> str = 'cpe:/o:microsoft:windows_2000'
>>> c = CPE2_2(str)

- TEST: This example CPE Name below identifies Microsoft?s Windows XP operating
system, Professional Edition, update level "Service Pack 2".
>>> str = 'cpe:/o:microsoft:windows_xp::sp2:pro'
>>> c = CPE2_2(str)

- TEST: This example name below refers to Red Hat Enterprise Linux 3 Advanced
Server.
>>> str = 'cpe:/o:redhat:enterprise_linux:3::as'
>>> c = CPE2_2(str)

- TEST: This example specifies an application, specifically the Apache
Foundation HTTP server version 2.0.52.
>>> str = 'cpe:/a:apache:httpd:2.0.52'
>>> c = CPE2_2(str)

- TEST: This example name below refers to a particular web browser, regardless
of any hardware or particular OS on which it is running.
>>> str = 'cpe:/a:microsoft:ie:6.0'
>>> c = CPE2_2(str)

- TEST: This example name below refers to a Cisco model 3825 integrated
services router.
>>> str = 'cpe:/h:cisco:router:3825'
>>> c = CPE2_2(str)

- TEST: The example name below identifies a particular laptop computer hardware
platform. The vendor is Dell Computer, the product line name is "Inspiron",
and the version (or model in this example) number is 8500.
>>> str = 'cpe:/h:dell:inspiron:8500'
>>> c = CPE2_2(str)

- TEST: The CPE Name below shows an example for a virtual hardware platform.
>>> str = 'cpe:/h:emc:vmware_esx:2.5'
>>> c = CPE2_2(str)

- TEST: bad URI syntax
>>> str = 'baduri'
>>> c = CPE2_2(str) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
ValueError: Malformed CPE name: validation of parts failed

- TEST: URI with whitespaces
>>> str = 'cpe:/con espacios'
>>> c = CPE2_2(str) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
ValueError: Malformed CPE name: it must not have whitespaces


----------------------------------
Test for __len__(self)
----------------------------------

- TEST: a CPE name without components
>>> str = "cpe:/"
>>> c = CPE2_2(str)
>>> len(c)
0

- TEST: a CPE name with some full components
>>> str = "cpe:/a:i4s:javas"
>>> c = CPE2_2(str)
>>> len(c)
3

- TEST: a CPE name with some empty components
>>> str = "cpe:/a:i4s:::javas"
>>> c = CPE2_2(str)
>>> len(c)
5

- TEST: a CPE name with all components
>>> str = "cpe:/a:acme:product:1.0:update2:-:en-us"
>>> c = CPE2_2(str)
>>> len(c)
7


----------------------------------
Test for __str__(self)
----------------------------------

TEST: not negate components
>>> str = 'cpe:/a:acme:product:1.0:update2:-:en-us'
>>> c = CPE2_2(str)
>>> print(c)
CPE v2.2: cpe:/a:acme:product:1.0:update2:-:en-us
