>>> from __future__ import print_function
>>> from cpe.cpe import CPE
>>> from cpe.cpe1_1 import CPE1_1
>>> from cpe.comp.cpecomp import CPEComponent

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

TEST: (version 1.1) not negate components
>>> str = 'cpe:///microsoft:ie:6.0'
>>> c = CPE(str)
>>> att = CPEComponent.ATT_VENDOR
>>> c.get_attribute_values(att)
['microsoft']

TEST: CPE Name with multiple parts and elements
>>> str = 'cpe://sun:sunos:5.9/bea:weblogic:8.1;mysql:server:5.0'
>>> c = CPE(str)
>>> att = CPEComponent.ATT_VENDOR
>>> c.get_attribute_values(att)
['sun', 'bea', 'mysql']


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

- TEST: good index
>>> str = 'cpe:///sun_microsystem:sun@os:5.9:#update'
>>> c = CPE1_1(str)
>>> c[1]
CPEComponent1_1(sun@os)

- TEST: bad index
>>> str = 'cpe:///sun_microsystem:sun@os:5.9:#update'
>>> c = CPE1_1(str)
>>> c[6]  #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
IndexError: Component index of CPE name out of range

- TEST: bad index
>>> str = 'cpe://'
>>> c = CPE1_1(str)
>>> c[6]  #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 = CPE1_1(str)

- TEST: an application part
>>> str = 'cpe://microsoft:windows:2000'
>>> c = CPE1_1(str)

- TEST: an OS part with an application part
>>> str = 'cpe://redhat:enterprise_linux:3:as/apache:httpd:2.0.52'
>>> c = CPE1_1(str)

- TEST: an hardware part with OS part
>>> str = 'cpe:/cisco::3825/cisco:ios:12.3:enterprise'
>>> c = CPE1_1(str)

- TEST: an application part
>>> str = 'cpe:///microsoft:ie:6.0'
>>> c = CPE1_1(str)

- TEST: OS part with operator OR (two subcomponents)
>>> str = 'cpe://microsoft:windows:xp!vista'
>>> c = CPE1_1(str)

- TEST: OS part with operator NOT (a subcomponent)
>>> str = 'cpe://microsoft:windows:~xp'
>>> c = CPE1_1(str)

- TEST: OS part with two elements in application part
>>> str = 'cpe://sun:sunos:5.9/bea:weblogic:8.1;mysql:server:5.0'
>>> c = CPE1_1(str)

- TEST: CPE with special characters
>>> str = 'cpe:///sun_microsystem:sun@os:5.9:#update'
>>> c = CPE1_1(str)

- TEST: bad URI syntax
>>> str = 'baduri'
>>> c = CPE1_1(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 = CPE1_1(str) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
ValueError: Malformed CPE name: it must not have whitespaces

- TEST: two operators in a subcomponent
>>> str = 'cpe://microsoft:windows:~2000!2007'
>>> c = CPE1_1(str) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
ValueError: not correct value '~2000!2007'


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

- TEST: a CPE name with empty parts
>>> str = "cpe:///"
>>> c = CPE1_1(str)
>>> len(c)
0

- TEST: a CPE name with two parts (hw and os) and
some elements empty and with values
>>> str = "cpe:/cisco::3825/cisco:ios:12.3:enterprise"
>>> c = CPE1_1(str)
>>> len(c)
7

- TEST: a CPE name with a application part and
a component with two subcomponents
>>> str = "cpe:///adobe:acrobat:6.0:std!pro"
>>> c = CPE1_1(str)
>>> len(c)
4


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

TEST: not negate components
>>> str = 'cpe:///microsoft:ie:6.0'
>>> c = CPE1_1(str)
>>> print(c)
CPE v1.1: cpe:///microsoft:ie:6.0

TEST: negate components
>>> str = 'cpe://microsoft:windows:~xp'
>>> c = CPE1_1(str)
>>> print(c)
CPE v1.1: cpe://microsoft:windows:~xp
