|
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 """ |
|
18 Test the configuration |
|
19 """ |
|
20 import unittest |
|
21 import string |
|
22 import sys,os |
|
23 import __init__ |
|
24 |
|
25 from cone.public import api,exceptions,utils, container |
|
26 |
|
27 class TestBase(unittest.TestCase): |
|
28 # @test |
|
29 def test_create_base(self): |
|
30 base = api.Base("foo") |
|
31 self.assertTrue(base) |
|
32 |
|
33 def test_get_namespace(self): |
|
34 base= api.Base("foo") |
|
35 self.assertTrue(base) |
|
36 self.assertEquals(base.namespace,"") |
|
37 |
|
38 def test_properties(self): |
|
39 base= api.Base("foo") |
|
40 self.assertTrue(base) |
|
41 self.assertEquals(base.ref,"foo") |
|
42 self.assertEquals(base.fqr,"foo") |
|
43 self.assertEquals(base.get_fullref(),"foo") |
|
44 self.assertEquals(base.get_fullfqr(),"foo") |
|
45 |
|
46 def test_create_hiearchy(self): |
|
47 base= api.Base("foo") |
|
48 base._add(api.Base("bar")) |
|
49 self.assertTrue(base) |
|
50 self.assertEquals(base.bar.find_parent(type=api.Base),base) |
|
51 self.assertEquals(base.bar.namespace, 'foo') |
|
52 self.assertEquals(base.bar.fqr, 'foo.bar') |
|
53 self.assertEquals(base.bar.get_fullfqr(), 'foo.bar') |
|
54 |
|
55 def test_create_hiearchy_with_container(self): |
|
56 cont= api.Base("", container=True) |
|
57 base= api.Base("foo") |
|
58 base._add(api.Base("bar1")) |
|
59 base._add(api.Base("bar2")) |
|
60 base.bar2._add(api.Base("bar21")) |
|
61 cont._add(base) |
|
62 self.assertTrue(base) |
|
63 self.assertEquals(cont.foo.bar2.bar21.find_parent(container=True), cont) |
|
64 self.assertEquals(cont.foo.bar1.find_parent(type=api.Base),base) |
|
65 self.assertEquals(cont.foo.bar1.namespace, 'foo') |
|
66 self.assertEquals(cont.foo.bar2.bar21.namespace, 'foo.bar2') |
|
67 self.assertEquals(cont.foo.bar2.bar21.fqr, 'foo.bar2.bar21') |
|
68 |
|
69 def test_create_hiearchy_with_container_and_hidden_elem(self): |
|
70 cont= api.Base("", container=True) |
|
71 base= api.Base("foo") |
|
72 base._add(api.Base("bar1")) |
|
73 base._add(api.Base("_bar2")) |
|
74 base._bar2._add(api.Base("bar21")) |
|
75 cont._add(base) |
|
76 self.assertTrue(base) |
|
77 self.assertEquals(cont.foo._bar2.bar21.find_parent(container=True), cont) |
|
78 self.assertEquals(cont.foo.bar1.find_parent(type=api.Base),base) |
|
79 self.assertEquals(cont.foo._bar2.bar21.get_fullnamespace(), 'foo._bar2') |
|
80 self.assertEquals(cont.foo._bar2.bar21.get_fullfqr(), 'foo._bar2.bar21') |
|
81 self.assertEquals(cont.foo.bar1.namespace, 'foo') |
|
82 self.assertEquals(cont.foo._bar2.bar21.namespace, 'foo') |
|
83 self.assertEquals(cont.foo._bar2.bar21.fqr, 'foo.bar21') |
|
84 |
|
85 def test_create_hiearchy_with_append(self): |
|
86 cont= api.Base("", container=True) |
|
87 base= api.Base("foo") |
|
88 base._add(api.Base("bar1"),container.APPEND) |
|
89 base._add(api.Base("bar1"),container.APPEND) |
|
90 base.bar1[0]._add(api.Base("bar21")) |
|
91 cont._add(base) |
|
92 self.assertTrue(base) |
|
93 self.assertEquals(cont.foo.bar1[1].get_fullnamespace(),'foo') |
|
94 self.assertEquals(cont.foo.bar1[0].get_fullref(),'bar1[0]') |
|
95 self.assertEquals(cont.foo.bar1[1].get_fullref(),'bar1[1]') |
|
96 self.assertEquals(cont.foo.bar1[0].get_fullfqr(), 'foo.bar1[0]') |
|
97 self.assertEquals(cont.foo.bar1[1].get_fullfqr(), 'foo.bar1[1]') |
|
98 self.assertEquals(cont.foo.bar1[0].bar21.get_fullnamespace(), 'foo.bar1[0]') |
|
99 self.assertEquals(cont.foo.bar1[0].bar21.get_fullfqr(), 'foo.bar1[0].bar21') |
|
100 |
|
101 if __name__ == '__main__': |
|
102 unittest.main() |
|
103 |