|
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 try: |
|
33 pkg_resources.require('ConeContentPlugin') |
|
34 except pkg_resources.DistributionNotFound: |
|
35 import __init__ |
|
36 |
|
37 from contentplugin import contentmlparser |
|
38 |
|
39 class TestConfmlRefs(unittest.TestCase): |
|
40 |
|
41 def test_is_confml_ref_of_plain_string(self): |
|
42 self.assertFalse(contentmlparser.ConfmlRefs.is_confml_ref('foo.bar')) |
|
43 |
|
44 def test_is_confml_ref_of_variable_string(self): |
|
45 self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${foo.bar}')) |
|
46 |
|
47 def test_is_confml_ref_of_variable_string_with_dollar(self): |
|
48 self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${features.foo$bar}')) |
|
49 |
|
50 def test_get_confml_ref_with_normal_ref(self): |
|
51 self.assertEquals(contentmlparser.ConfmlRefs.get_confml_ref('${features.foo.bar}'), 'features.foo.bar') |
|
52 |
|
53 def test_get_confml_ref_with_invalid_ref(self): |
|
54 self.assertEquals(contentmlparser.ConfmlRefs.get_confml_ref('${features.foo.bar'), None) |
|
55 |
|
56 def test_get_two_confml_refs(self): |
|
57 self.assertTrue(contentmlparser.ConfmlRefs.is_ref_like('ab.cd')) |
|
58 self.assertTrue(contentmlparser.ConfmlRefs.is_confml_ref('${features.foo.bar}/${features.foo.bar2}')) |
|
59 self.assertEquals(contentmlparser.ConfmlRefs.get_confml_refs('${features.foo.bar}/${features.foo.bar2}'), ['features.foo.bar', 'features.foo.bar2']) |
|
60 self.assertEquals(contentmlparser.ConfmlRefs.get_confml_refs('${features.foo.bar}/${features.foo.bar}'), ['features.foo.bar']) |
|
61 |
|
62 |
|
63 if __name__ == '__main__': |
|
64 unittest.main() |