587
|
1 |
#============================================================================
|
|
2 |
#Name : test_escapeddict.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 |
#===============================================================================
|
588
|
19 |
"""test escaped dict """
|
|
20 |
|
628
|
21 |
# pylint: disable=R0201
|
587
|
22 |
|
|
23 |
import logging
|
|
24 |
import unittest
|
|
25 |
|
|
26 |
import escapeddict
|
|
27 |
|
|
28 |
|
588
|
29 |
_logger = logging.getLogger('test.escapeddict')
|
587
|
30 |
|
|
31 |
|
|
32 |
class EscapedDictTest(unittest.TestCase):
|
|
33 |
""" Acceptance tests for escapeddict.py """
|
|
34 |
def test_escape(self):
|
588
|
35 |
"""test escape"""
|
587
|
36 |
testdict = escapeddict.EscapedDict({'key1': 'value1', 'key2': 'value2 ${key1}'})
|
|
37 |
for key in testdict.keys():
|
588
|
38 |
_logger.info(testdict[key])
|
587
|
39 |
assert testdict['key1'] == 'value1'
|
|
40 |
assert testdict['key2'] == 'value2 value1'
|
|
41 |
|
|
42 |
def test_escape_no_value_present(self):
|
588
|
43 |
"""test escape no value present"""
|
587
|
44 |
testdict = escapeddict.EscapedDict({'key1': 'value1', 'key2': 'value2 ${key_not_present} ${key1}'})
|
|
45 |
for key in testdict.keys():
|
|
46 |
print testdict[key]
|
|
47 |
assert testdict['key1'] == 'value1'
|
|
48 |
assert testdict['key2'] == 'value2 ${key_not_present} value1'
|
|
49 |
|
|
50 |
def test_escape_value_as_list(self):
|
588
|
51 |
"""test escape value as list"""
|
587
|
52 |
testdict = escapeddict.EscapedDict({'key1': 'value1', 'key2': ['value2', '${key1}']})
|
|
53 |
for key in testdict.keys():
|
|
54 |
print testdict[key]
|
|
55 |
assert testdict['key1'] == 'value1'
|
|
56 |
assert testdict['key2'] == ['value2', 'value1'] |