0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import unittest
|
|
18 |
import os, shutil
|
|
19 |
import sys
|
|
20 |
import pkg_resources
|
|
21 |
try:
|
|
22 |
from cElementTree import ElementTree
|
|
23 |
except ImportError:
|
|
24 |
try:
|
|
25 |
from elementtree import ElementTree
|
|
26 |
except ImportError:
|
|
27 |
try:
|
|
28 |
from xml.etree import cElementTree as ElementTree
|
|
29 |
except ImportError:
|
|
30 |
from xml.etree import ElementTree
|
|
31 |
|
|
32 |
from contentplugin import contentmlparser
|
|
33 |
|
|
34 |
class TestConfmlRefs(unittest.TestCase):
|
|
35 |
|
|
36 |
def test_is_confml_ref_of_plain_string(self):
|
|
37 |
self.assertFalse(contentmlparser.ConfmlRefs.is_confml_ref('foo.bar'))
|
|
38 |
|
|
39 |
def test_is_confml_ref_of_variable_string(self):
|
|
40 |
self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${foo.bar}'))
|
|
41 |
|
|
42 |
def test_is_confml_ref_of_variable_string_with_dollar(self):
|
|
43 |
self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${features.foo$bar}'))
|
|
44 |
|
|
45 |
def test_get_confml_ref_with_normal_ref(self):
|
|
46 |
self.assertEquals(contentmlparser.ConfmlRefs.get_confml_ref('${features.foo.bar}'), 'features.foo.bar')
|
|
47 |
|
|
48 |
def test_get_confml_ref_with_invalid_ref(self):
|
|
49 |
self.assertEquals(contentmlparser.ConfmlRefs.get_confml_ref('${features.foo.bar'), None)
|
|
50 |
|
|
51 |
def test_get_two_confml_refs(self):
|
|
52 |
self.assertTrue(contentmlparser.ConfmlRefs.is_ref_like('ab.cd'))
|
|
53 |
self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${features.foo.bar}/${features.foo.bar2}'))
|
|
54 |
self.assertEquals(contentmlparser.ConfmlRefs.get_confml_refs('${features.foo.bar}/${features.foo.bar2}'), ['features.foo.bar', 'features.foo.bar2'])
|
|
55 |
self.assertEquals(contentmlparser.ConfmlRefs.get_confml_refs('${features.foo.bar}/${features.foo.bar}'), ['features.foo.bar'])
|
|
56 |
|
|
57 |
|
|
58 |
if __name__ == '__main__':
|
|
59 |
unittest.main()
|