def test_get_ApDnContainer(self):
        project = api.Project(
            api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject')))
        config = project.get_configuration('root.confml')
        dview = config.get_default_view()

        container = accesspoint_id_counter._get_ApDnContainer_(
            dview.get_feature("APs"), dview.get_feature("DNs"), True)

        self.assertEquals('Internet', container.get_all_dns()[0].get_name())
        self.assertEquals('1', container.get_all_dns()[0].get_id())
        self.assertEquals([
            'IAP11', 'IAP12', 'IAP13', None, None, None, None, None, None, None
        ],
                          container.get_all_dns()[0].get_iaps())

        self.assertEquals('MMS', container.get_all_dns()[1].get_name())
        self.assertEquals('2', container.get_all_dns()[1].get_id())
        self.assertEquals([
            'IAP21', 'IAP22', 'IAP23', 'IAP13', None, None, None, None, None,
            None
        ],
                          container.get_all_dns()[1].get_iaps())

        self.assertEquals('Operator', container.get_all_dns()[2].get_name())
        self.assertEquals('3', container.get_all_dns()[2].get_id())
        self.assertEquals([
            'IAP31', 'IAP32', 'IAP33', None, None, None, None, None, None, None
        ],
                          container.get_all_dns()[2].get_iaps())

        self.assertEquals('IAP11', container.get_all_aps()[0].get_name())
        self.assertEquals('1', container.get_all_aps()[0].get_id())
    def test_calc_ap_ids(self):
        project = api.Project(
            api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject')))
        config = project.get_configuration('root.confml')
        dview = config.get_default_view()

        container = accesspoint_id_counter._get_ApDnContainer_(
            dview.get_feature("APs"), dview.get_feature("DNs"), True)

        self.assertEquals('9', container.get_all_aps()[6].get_id())
    def test_get_apid_by_dnname_and_apname(self):
        project = api.Project(
            api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject')))
        config = project.get_configuration('root.confml')
        dview = config.get_default_view()

        container = accesspoint_id_counter._get_ApDnContainer_(
            dview.get_feature("APs"), dview.get_feature("DNs"), True)

        self.assertEquals(
            '2', container.get_apid_by_dnname_and_apname('Internet', 'IAP12'))
    def test_all_in_array(self):
        project = api.Project(
            api.Storage.open(os.path.join(ROOT_PATH, 'ruleproject')))
        config = project.get_configuration('root.confml')
        dview = config.get_default_view()

        container = accesspoint_id_counter._get_ApDnContainer_(
            dview.get_feature("APs"), dview.get_feature("DNs"), True)

        self.assertEquals(
            container.get_all_in_array(),
            [[
                'Internet', '1',
                [
                    'IAP11', 'IAP12', 'IAP13', None, None, None, None, None,
                    None, None
                ], ['1', '2', '7', None, None, None, None, None, None, None],
                ['1', '2', '3', None, None, None, None, None, None, None]
            ],
             [
                 'MMS', '2',
                 [
                     'IAP21', 'IAP22', 'IAP23', 'IAP13', None, None, None,
                     None, None, None
                 ], ['4', '8', '6', '7', None, None, None, None, None, None],
                 ['4', '5', '6', '3', None, None, None, None, None, None]
             ],
             [
                 'Operator', '3',
                 [
                     'IAP31', 'IAP32', 'IAP33', None, None, None, None, None,
                     None, None
                 ],
                 [None, None, '9', None, None, None, None, None, None, None],
                 [None, None, '7', None, None, None, None, None, None, None]
             ]])