587
|
1 |
#============================================================================
|
|
2 |
#Name : test_ccm_4pn.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Test cases for ccm python toolkit.
|
|
21 |
|
|
22 |
"""
|
628
|
23 |
# pylint: disable=R0201
|
588
|
24 |
|
587
|
25 |
import unittest
|
|
26 |
import ccm
|
|
27 |
import logging
|
|
28 |
|
|
29 |
|
588
|
30 |
_logger = logging.getLogger('test.ccm')
|
587
|
31 |
|
|
32 |
|
|
33 |
class FourPartNameTest(unittest.TestCase):
|
|
34 |
""" Unit test case for testing four part name of a ccm project """
|
|
35 |
def testSimpleFourPartNameParsing(self):
|
|
36 |
"""Test the parsing of a simple four part name"""
|
|
37 |
strfpn = "simple.test-myversion1:ascii:mydb#1"
|
|
38 |
fpn = ccm.FourPartName(strfpn)
|
|
39 |
assert fpn.name == "simple.test"
|
|
40 |
assert fpn.version == "myversion1"
|
|
41 |
assert fpn.type == "ascii"
|
|
42 |
assert fpn.instance == "mydb#1"
|
|
43 |
assert strfpn == str(fpn)
|
|
44 |
assert strfpn == fpn.objectname
|
|
45 |
|
|
46 |
def testSpacesFourPartNameParsing(self):
|
|
47 |
"""Test the parsing of a four part name that contains spaces"""
|
|
48 |
strfpn = "simple test.ext - myversion1 :ascii:mydb#1"
|
|
49 |
fpn = ccm.FourPartName(strfpn)
|
|
50 |
assert fpn.name == "simple test.ext "
|
|
51 |
assert fpn.version == " myversion1 "
|
|
52 |
assert fpn.type == "ascii"
|
|
53 |
assert fpn.instance == "mydb#1"
|
|
54 |
assert strfpn == str(fpn)
|
|
55 |
assert strfpn == fpn.objectname
|
|
56 |
|
|
57 |
def testHyphenedFourPartNameParsing(self):
|
|
58 |
"""Test the parsing of a hyphened four part name"""
|
|
59 |
strfpn = "simple-test.ext-myversion1:ascii:mydb#1"
|
|
60 |
fpn = ccm.FourPartName(strfpn)
|
|
61 |
assert fpn.name == "simple-test.ext"
|
|
62 |
assert fpn.version == "myversion1"
|
|
63 |
assert fpn.type == "ascii"
|
|
64 |
assert fpn.instance == "mydb#1"
|
|
65 |
assert strfpn == str(fpn)
|
|
66 |
assert strfpn == fpn.objectname
|
|
67 |
|
|
68 |
def testReleasedefParsing(self):
|
|
69 |
"""Test the parsing of a releasedef four part name"""
|
|
70 |
strfpn = "myproject:myversion1:releasedef:mydb#1"
|
|
71 |
fpn = ccm.FourPartName(strfpn)
|
|
72 |
assert fpn.name == "myproject"
|
|
73 |
assert fpn.version == "myversion1"
|
|
74 |
assert fpn.type == "releasedef"
|
|
75 |
assert fpn.instance == "mydb#1"
|
|
76 |
assert strfpn == str(fpn)
|
|
77 |
assert strfpn == fpn.objectname
|
|
78 |
|
|
79 |
def testEquality(self):
|
|
80 |
"""Test equality and same familly function"""
|
|
81 |
# testing different name
|
|
82 |
fpn1 = ccm.FourPartName("simple.test-myversion1:ascii:mydb#1")
|
|
83 |
fpn2 = ccm.FourPartName("simple.testx-myversion1:ascii:mydb#1")
|
|
84 |
assert fpn1 != fpn2
|
|
85 |
assert not fpn1.is_same_family(fpn2), "Should not be from the same family"
|
|
86 |
# testing different version
|
|
87 |
fpn2 = ccm.FourPartName("simple.test-myversion2:ascii:mydb#1")
|
|
88 |
assert fpn1 != fpn2
|
|
89 |
assert fpn1.is_same_family(fpn2), "Should be from the same family"
|
|
90 |
# testing different type
|
|
91 |
fpn2 = ccm.FourPartName("simple.test-myversion1:ascii2:mydb#1")
|
|
92 |
assert fpn1 != fpn2
|
|
93 |
assert not fpn1.is_same_family(fpn2), "Should not be from the same family"
|
|
94 |
# testing different instance
|
|
95 |
fpn2 = ccm.FourPartName("simple.test-myversion1:ascii:mydb#2")
|
|
96 |
assert fpn1 != fpn2
|
|
97 |
assert not fpn1.is_same_family(fpn2), "Should not be from the same family"
|
|
98 |
|
|
99 |
def testConvert(self):
|
588
|
100 |
""" Test task displayname tranformation"""
|
587
|
101 |
fpn = ccm.FourPartName("Task mydb#123")
|
|
102 |
assert fpn.type == "task"
|
|
103 |
# Test folder displayname tranformation
|
|
104 |
fpn = ccm.FourPartName("Folder mydb#123")
|
|
105 |
assert fpn.type == "folder"
|
|
106 |
# Test Release tag displayname tranformation
|
|
107 |
fpn = ccm.FourPartName("mc/integration")
|
|
108 |
assert fpn.name == "mc"
|
|
109 |
assert fpn.version == "integration"
|
|
110 |
assert fpn.type == "releasedef"
|
|
111 |
assert fpn.instance == "1"
|
|
112 |
|
|
113 |
fpn = ccm.FourPartName("BTHID/3.2_2007_wk03")
|
|
114 |
assert fpn.name == "BTHID"
|
|
115 |
assert fpn.version == "3.2_2007_wk03"
|
|
116 |
assert fpn.type == "releasedef"
|
|
117 |
assert fpn.instance == "1"
|
|
118 |
|
|
119 |
fpn = ccm.FourPartName("DRM_0.9")
|
|
120 |
assert fpn.name == "none"
|
|
121 |
assert fpn.version == "DRM_0.9"
|
|
122 |
assert fpn.type == "releasedef"
|
|
123 |
assert fpn.instance == "1"
|
|
124 |
|
|
125 |
try:
|
|
126 |
fpn = ccm.FourPartName("task mydb#123")
|
|
127 |
assert False, "Should raise InvalidFourPartNameException when parsing'task mydb#123'"
|
588
|
128 |
except ccm.InvalidFourPartNameException:
|
587
|
129 |
pass
|
|
130 |
|
|
131 |
try:
|
|
132 |
fpn = ccm.FourPartName("folder mydb#123")
|
|
133 |
assert False, "Should raise InvalidFourPartNameException when parsing'folder mydb#123'"
|
588
|
134 |
except ccm.InvalidFourPartNameException:
|
587
|
135 |
pass
|
|
136 |
|
|
137 |
|
|
138 |
class InvalidFourPartNameExceptionTest(unittest.TestCase):
|
|
139 |
""" Unit test case for testing invalid four part name of a ccm project """
|
|
140 |
def testOutput(self):
|
|
141 |
""" Test the exception shows the arguments. """
|
|
142 |
ex = ccm.InvalidFourPartNameException('foo')
|
|
143 |
assert str(ex) == 'foo'
|
|
144 |
|
|
145 |
|
|
146 |
if __name__ == "__main__":
|
|
147 |
unittest.main()
|