587
|
1 |
#============================================================================
|
|
2 |
#Name : test_ant.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 |
""" amara.py module tests. """
|
|
21 |
|
|
22 |
|
|
23 |
import amara
|
|
24 |
from xmlhelper import recursive_node_scan
|
|
25 |
|
|
26 |
def test_amara():
|
588
|
27 |
"""test amara"""
|
|
28 |
xxx = amara.parse(r'<commentLog><branchInfo category="" error="kkk" file="tests/data/comments_test.txt" originator="sanummel" since="07-03-22">Add rofsfiles for usage in paged images</branchInfo></commentLog>')
|
|
29 |
assert str(xxx.commentLog.branchInfo) == 'Add rofsfiles for usage in paged images'
|
587
|
30 |
|
588
|
31 |
xxx = amara.parse(r'<commentLog><branchInfo>1</branchInfo><branchInfo>2</branchInfo></commentLog>')
|
|
32 |
for yyy in xxx.commentLog.branchInfo:
|
|
33 |
assert str(yyy) == '1'
|
587
|
34 |
break
|
|
35 |
|
|
36 |
myxml = """<DpComponent DpType="File" name="dp.cfg.xml" fileType="Binary" fileSubType="1" fileIndex="1" owner="SwUpdate" extract="true" signed="true" optional="true" crc="true" useCases="Refurbish,BackupRestore" variantPackage="true" include="true" EnableCRCVerification="true" parameters="test"/>"""
|
|
37 |
xcf = amara.parse(myxml)
|
|
38 |
assert xcf.DpComponent['name'] == 'dp.cfg.xml'
|
|
39 |
|
|
40 |
myxml2 = """<bomDelta><buildFrom>ido_raptor_mcl_abs_MCL.52.57</buildFrom><buildTo>mock</buildTo><content/></bomDelta>"""
|
|
41 |
xcf2 = amara.parse(myxml2)
|
|
42 |
assert xcf2.bomDelta[0].buildFrom[0] == "ido_raptor_mcl_abs_MCL.52.57"
|
|
43 |
|
|
44 |
print xcf.DpComponent.xml_attributes
|
|
45 |
|
|
46 |
doc = amara.create_document(u'bom')
|
|
47 |
s60_input_node = doc.xml_create_element(u'input')
|
|
48 |
s60_input_node.xml_append(doc.xml_create_element(u'name', content=(unicode("s60"))))
|
|
49 |
print s60_input_node.xml()
|
|
50 |
|
|
51 |
s60_input_source = s60_input_node.xml_create_element(u'source')
|
|
52 |
s60_input_source.xml_append(doc.xml_create_element(u'type', content=(unicode("grace"))))
|
|
53 |
print s60_input_source.xml()
|
|
54 |
|
|
55 |
doc = amara.create_document(u'bom')
|
|
56 |
doc.bom.xml_append(doc.xml_create_element(u'build', content=unicode("a")))
|
|
57 |
|
|
58 |
doc = amara.create_document(u'bomDelta')
|
|
59 |
content_node = doc.xml_create_element(u'content')
|
|
60 |
doc.bomDelta.xml_append(content_node)
|
|
61 |
content_node.xml_append(content_node.xml_create_element(u'b', content=unicode('a')))
|
|
62 |
assert doc.bomDelta.xml(indent=False) == '<bomDelta><content><b>a</b></content></bomDelta>'
|
|
63 |
|
|
64 |
recursive_node_scan(doc, 'a')
|
|
65 |
|
|
66 |
amara.create_document()
|
|
67 |
|
|
68 |
xcf3 = amara.parse(r'<VariantPackingList><Variant/></VariantPackingList>')
|
|
69 |
assert hasattr(xcf3.VariantPackingList.Variant,"FileList") == False
|
|
70 |
if not hasattr(xcf3.VariantPackingList.Variant,"FileList"):
|
|
71 |
xcf3.VariantPackingList.Variant.xml_append(xcf3.xml_create_element(u"FileList"))
|
|
72 |
xcf3.VariantPackingList.Variant.FileList.xml_append_fragment(doc.xml(omitXmlDeclaration=u"yes"))
|
|
73 |
|
|
74 |
xcf4 = amara.parse(r"<a><p name='1'/><p name='1'/></a>")
|
|
75 |
found = False
|
588
|
76 |
for p_path in xcf4.xml_xpath("//p"):
|
|
77 |
assert str(p_path.name) == '1'
|
587
|
78 |
found = True
|
|
79 |
assert found
|
|
80 |
|
|
81 |
#xcf5 = amara.parse(open(r'C:\USERS\helium\helium-dev-forbuilds\helium\tests\data\bom\build_model_bom.xml'))
|
|
82 |
#u'%s' % xcf5.bom.content.project.folder.task.synopsis
|