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
|
3
|
18 |
import os
|
0
|
19 |
|
3
|
20 |
from cone.public import api
|
0
|
21 |
from ruleplugin.evals import accesspoint_id_counter
|
|
22 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
23 |
|
|
24 |
class TestAPIDC(unittest.TestCase):
|
|
25 |
def test_get_ApDnContainer(self):
|
|
26 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
27 |
config = project.get_configuration('root.confml')
|
|
28 |
dview = config.get_default_view()
|
|
29 |
|
3
|
30 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
31 |
|
|
32 |
self.assertEquals('Internet', container.get_all_dns()[0].get_name())
|
|
33 |
self.assertEquals('1', container.get_all_dns()[0].get_id())
|
3
|
34 |
self.assertEquals(['IAP11', 'IAP12', 'IAP13', 'WIAP16', None, None, None, None, None, None],
|
|
35 |
container.get_all_dns()[0].get_iaps())
|
0
|
36 |
|
|
37 |
self.assertEquals('MMS', container.get_all_dns()[1].get_name())
|
|
38 |
self.assertEquals('2', container.get_all_dns()[1].get_id())
|
3
|
39 |
self.assertEquals(['IAP21', 'IAP22', 'IAP23', None, None, None, None, None, None, None],
|
|
40 |
container.get_all_dns()[1].get_iaps())
|
0
|
41 |
|
|
42 |
self.assertEquals('Operator', container.get_all_dns()[2].get_name())
|
|
43 |
self.assertEquals('3', container.get_all_dns()[2].get_id())
|
3
|
44 |
self.assertEquals(['IAP31', 'IAP32', 'IAP33', None, None, None, None, None, None, None],
|
|
45 |
container.get_all_dns()[2].get_iaps())
|
0
|
46 |
|
3
|
47 |
self.assertEquals('WIAP16', container.get_all_aps()[0].get_name())
|
|
48 |
self.assertEquals('5', container.get_all_aps()[0].get_id())
|
0
|
49 |
|
|
50 |
def test_get_apid_by_apname(self):
|
|
51 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
52 |
config = project.get_configuration('root.confml')
|
|
53 |
dview = config.get_default_view()
|
|
54 |
|
3
|
55 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
56 |
|
|
57 |
self.assertEquals('1', container.get_apid_by_apname('IAP11'))
|
|
58 |
self.assertEquals('2', container.get_apid_by_apname('IAP12'))
|
|
59 |
self.assertEquals('7', container.get_apid_by_apname('IAP13'))
|
|
60 |
|
|
61 |
def test_get_dnid_by_dnname(self):
|
|
62 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
63 |
config = project.get_configuration('root.confml')
|
|
64 |
dview = config.get_default_view()
|
|
65 |
|
3
|
66 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
67 |
|
|
68 |
self.assertEquals('1', container.get_dnid_by_dnname('Internet'))
|
|
69 |
self.assertEquals('2', container.get_dnid_by_dnname('MMS'))
|
|
70 |
self.assertEquals('3', container.get_dnid_by_dnname('Operator'))
|
|
71 |
|
|
72 |
|
|
73 |
def test_get_apid_by_dnname_and_apname(self):
|
|
74 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
75 |
config = project.get_configuration('root.confml')
|
|
76 |
dview = config.get_default_view()
|
|
77 |
|
3
|
78 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
79 |
|
|
80 |
self.assertEquals('2', container.get_apid_by_dnname_and_apname('Internet', 'IAP12'))
|
|
81 |
|
|
82 |
def test_calc_ap_ids(self):
|
|
83 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
84 |
config = project.get_configuration('root.confml')
|
|
85 |
dview = config.get_default_view()
|
|
86 |
|
3
|
87 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
|
88 |
|
|
89 |
self.assertEquals('6', container.get_all_aps()[6].get_id())
|
|
90 |
self.assertEquals('5', container.get_all_aps()[0].get_id())
|
0
|
91 |
|
|
92 |
def test_all_in_array(self):
|
|
93 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
94 |
config = project.get_configuration('root.confml')
|
|
95 |
dview = config.get_default_view()
|
|
96 |
|
3
|
97 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
98 |
|
3
|
99 |
self.assertEquals(container.get_all_in_array(),
|
|
100 |
[
|
|
101 |
['Internet', '1',
|
|
102 |
['IAP11', 'IAP12', 'IAP13', 'WIAP16', None, None, None, None, None, None],
|
|
103 |
['1', '2', '7', '5', None, None, None, None, None, None],
|
|
104 |
['1', '2', '3', '4', None, None, None, None, None, None]],
|
|
105 |
['MMS', '2',
|
|
106 |
['IAP21', 'IAP22', 'IAP23', None, None, None, None, None, None, None],
|
|
107 |
['4', '8', '6', None, None, None, None, None, None, None],
|
|
108 |
['5', '6', '7', None, None, None, None, None, None, None]],
|
|
109 |
['Operator', '3',
|
|
110 |
['IAP31', 'IAP32', 'IAP33', None, None, None, None, None, None, None],
|
|
111 |
[None, None, '9', None, None, None, None, None, None, None],
|
|
112 |
[None, None, '8', None, None, None, None, None, None, None]]
|
|
113 |
]
|
|
114 |
)
|
0
|
115 |
|
|
116 |
def test_get_next_free_id(self):
|
|
117 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
118 |
config = project.get_configuration('root.confml')
|
|
119 |
dview = config.get_default_view()
|
3
|
120 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
121 |
|
|
122 |
self.assertEquals("4", accesspoint_id_counter._get_next_free_id_(container.get_all_dns()))
|
|
123 |
self.assertEquals("10", accesspoint_id_counter._get_next_free_id_(container.get_all_aps()))
|
|
124 |
|
|
125 |
def test_get_apindex_by_apname(self):
|
|
126 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject')))
|
|
127 |
config = project.get_configuration('root.confml')
|
|
128 |
dview = config.get_default_view()
|
|
129 |
|
3
|
130 |
container = accesspoint_id_counter._get_ApDnContainer_(dview.get_feature("WLAN_APs"), dview.get_feature("APs"), dview.get_feature("DNs"))
|
0
|
131 |
|
3
|
132 |
self.assertEquals("5", container.get_apindex_by_apname("IAP21"))
|
0
|
133 |
self.assertEquals("1", container.get_apindex_by_apname("IAP11"))
|
|
134 |
|
|
135 |
|
|
136 |
if __name__ == "__main__":
|
|
137 |
unittest.main()
|