|
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 import unittest |
|
19 import string |
|
20 import sys |
|
21 import os |
|
22 import shutil |
|
23 import __init__ |
|
24 |
|
25 from cone.public import api, exceptions |
|
26 from cone.confml import model as confmlmodel |
|
27 from cone.carbon import persistentjson, model, mapping |
|
28 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
29 |
|
30 class TestGetMapper(unittest.TestCase): |
|
31 def test_get_mapper(self): |
|
32 mapper = model.get_mapper('confml') |
|
33 self.assertTrue(isinstance(mapper, mapping.Carbon2confml)) |
|
34 |
|
35 def test_get_mapper_from_object(self): |
|
36 s = model.CarbonSetting("test") |
|
37 mapper = s._get_mapper('confml') |
|
38 self.assertTrue(isinstance(mapper, mapping.Carbon2confml)) |
|
39 |
|
40 |
|
41 class TestCarbon2confml(unittest.TestCase): |
|
42 def test_map_carbon_configuration(self): |
|
43 mapper = model.get_mapper('confml') |
|
44 c1 = model.CarbonConfiguration("test") |
|
45 c2 = mapper.configuration(c1) |
|
46 self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) |
|
47 c2 = mapper.map_object(c1) |
|
48 self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) |
|
49 |
|
50 def test_map_carbon_featurelist(self): |
|
51 mapper = model.get_mapper('confml') |
|
52 c1 = model.FeatureList(name="test") |
|
53 c2 = mapper.configuration(c1) |
|
54 self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) |
|
55 c2 = mapper.map_object(c1) |
|
56 self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) |
|
57 |
|
58 def test_map_carbon_configuration_with_data(self): |
|
59 mapper = model.get_mapper('confml') |
|
60 c1 = model.CarbonConfiguration("test") |
|
61 c1.name = "test.confml" |
|
62 c1.namespace = "com.nokia" |
|
63 c2 = mapper.map_object(c1) |
|
64 self.assertTrue(isinstance(c2, confmlmodel.ConfmlConfiguration)) |
|
65 self.assertEquals(c2.name, "test") |
|
66 self.assertEquals(c2.namespace, "com.nokia") |
|
67 self.assertEquals(c2.path, "test") |
|
68 |
|
69 def test_map_carbon_setting_with_data(self): |
|
70 mapper = model.get_mapper('confml') |
|
71 c1 = model.CarbonSetting("test") |
|
72 c2 = mapper.map_object(c1) |
|
73 self.assertTrue(isinstance(c2, confmlmodel.ConfmlSetting)) |
|
74 self.assertEquals(c2.name, "test") |
|
75 self.assertEquals(c2.ref, "test") |
|
76 |
|
77 def test_map_carbon_setting_with_data(self): |
|
78 mapper = model.get_mapper('confml') |
|
79 c1 = model.CarbonSetting("test") |
|
80 c2 = mapper.map_object(c1) |
|
81 self.assertTrue(isinstance(c2, confmlmodel.ConfmlSetting)) |
|
82 self.assertEquals(c2.name, "test") |
|
83 self.assertEquals(c2.ref, "test") |
|
84 |
|
85 def test_map_carbon_int_setting_with_data(self): |
|
86 mapper = model.get_mapper('confml') |
|
87 c1 = model.CarbonIntSetting("test") |
|
88 c2 = mapper.map_object(c1) |
|
89 self.assertTrue(isinstance(c2, confmlmodel.ConfmlIntSetting)) |
|
90 self.assertEquals(c2.name, "test") |
|
91 self.assertEquals(c2.ref, "test") |
|
92 |
|
93 def test_map_carbon_setting_with_data(self): |
|
94 mapper = model.get_mapper('confml') |
|
95 c1 = model.CarbonBooleanSetting("test") |
|
96 c2 = mapper.map_object(c1) |
|
97 self.assertTrue(isinstance(c2, confmlmodel.ConfmlBooleanSetting)) |
|
98 self.assertEquals(c2.name, "test") |
|
99 self.assertEquals(c2.ref, "test") |
|
100 |
|
101 def test_map_carbon_setting_with_data(self): |
|
102 mapper = model.get_mapper('confml') |
|
103 c1 = model.CarbonSelectionSetting("test") |
|
104 c2 = mapper.map_object(c1) |
|
105 self.assertTrue(isinstance(c2, confmlmodel.ConfmlSelectionSetting)) |
|
106 self.assertEquals(c2.name, "test") |
|
107 self.assertEquals(c2.ref, "test") |