예제 #1
0
    def test_missing_attributes(self):
        f = RoutePolicy(device=self.device)

        f.maker.outputs[ShowRouteMapAll] = \
            {'':RoutePolicyOutput.showRouteMapAll}

        f.learn()
        with self.assertRaises(KeyError):
            vlan_access_map_value=(f.info['test']['statements']\
                ['20']['actions']['clause']['True'])
예제 #2
0
    def test_sample(self):

        f = RoutePolicy(device=self.device)

        f.maker.outputs[ShowRouteMapAll] = \
            {'':RoutePolicyOutput.showRouteMapAll}

        f.learn()

        self.assertEqual(f.info, RoutePolicyOutput.RoutePolicy['info'])
예제 #3
0
    def test_selective_attribute(self):

        f = RoutePolicy(device=self.device,
                        attributes=['info[(.*)][statements]'])

        f.maker.outputs[ShowRouteMapAll] = \
            {'':RoutePolicyOutput.showRouteMapAll}

        f.learn()

        self.assertIn('10', f.info['test']['statements'])
        self.assertNotIn('20', f.info['test']['statements'])
예제 #4
0
    def test_ignored(self):

        f = RoutePolicy(device=self.device)
        g = RoutePolicy(device=self.device)


        f.maker.outputs[ShowRouteMapAll] = \
            {'':RoutePolicyOutput.showRouteMapAll}

        g.maker.outputs[ShowRouteMapAll] = \
            {'':RoutePolicyOutput.showRouteMapAll}

        f.learn()
        g.learn()

        f.s = 2

        self.assertNotEqual(f, g)
        # Verify diff now
        diff = f.diff(g)
        sorted_diff = str(diff)
        sorted_result = ('+s: 2')
        self.assertEqual(sorted_diff, sorted_result)