[PATCH 03/13] Iface policy doesn't seem to exist.

Matthew W. S. Bell matthew at bells23.org.uk
Sat Apr 25 18:18:28 UTC 2009


From: Matthew W. S. Bell <mentor at engelbert.(none)>


Signed-off-by: Matthew W. S. Bell <matthew at bells23.org.uk>
---
 src/netconf/core.py             |    1 -
 src/netconf/ifaces/__init__.py  |    3 -
 src/tests/test_ifaces_policy.py |  199 ---------------------------------------
 3 files changed, 0 insertions(+), 203 deletions(-)
 delete mode 100644 src/tests/test_ifaces_policy.py

diff --git a/src/netconf/core.py b/src/netconf/core.py
index 2d8ed60..1643e6b 100644
--- a/src/netconf/core.py
+++ b/src/netconf/core.py
@@ -45,7 +45,6 @@ from netconf.fdreactor import BaseFdReactor, SignalCallbackFdReactor, \
     ProxyFdReactor
 from netconf.ctlsock import CtlsockListener, CtlsockReactor, CtlsockProcessor, \
     CtlsockDispatcher
-from netconf.ifaces import IfacePolicy
 from policy import Policy
 from pubsub import PubSub
 
diff --git a/src/netconf/ifaces/__init__.py b/src/netconf/ifaces/__init__.py
index baf56c1..af250d6 100644
--- a/src/netconf/ifaces/__init__.py
+++ b/src/netconf/ifaces/__init__.py
@@ -25,6 +25,3 @@ __version__ = "0.1~WIP"
 __author__ = "martin f. krafft"
 __copyright__ = "Copyright © martin f. krafft"
 __license__ = "GPL v2"
-
-
-from policy import IfacePolicy
diff --git a/src/tests/test_ifaces_policy.py b/src/tests/test_ifaces_policy.py
deleted file mode 100644
index db6995d..0000000
--- a/src/tests/test_ifaces_policy.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# vim:ft=python
-# -*- coding: utf-8 -*-
-#
-# tests.test_ifaces_policy — test basic policy decisions
-#
-# This file is part of netconf - http://netconf.alioth.debian.org
-#
-# Copyright © 2008 Jonathan Roes <jroes at jroes.net>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published by
-# the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA  02111-1307  USA
-#
-
-__version__ = "0.1~WIP"
-__author__ = "Jonathan Roes"
-__copyright__ = "Copyright © 2008 Jonathan Roes"
-__license__ = "GPL v2"
-
-import unittest
-from StringIO import StringIO
-
-from netconf.ifaces.policy import IfacePolicy
-from netconf.ifaces.cmdresult import *
-
-def raise_e(e): raise e
-
-class DummyCore(object):
-    def __init__(self):
-        pass
-
-class DummyCred(object):
-    def __init__(self, pid, uid, gid):
-        self.pid = pid
-        self.uid = uid
-        self.gid = gid
-
-class DummyConfigBroker(object):
-    def __init__(self, enihandler, dhcphandler):
-        self._enihandler = enihandler
-        self._dhcphandler = dhcphandler
-        self.calls = [ ]
-
-    def get_next_handler(self, iface, cmd, handler, result):
-        self.calls.append((iface, cmd, handler, result))
-        if iface == 'eth0' and cmd == 'IFUP':
-            if handler == None:
-                return self._enihandler
-            elif type(handler) == TrivialTests.DummyEniHandler and \
-                    result in ('UNKNOWNCOMMAND', 'UNKNOWNIFACE'):
-                return self._dhcphandler
-            elif type(handler) == TrivialTests.DummyDHCPHandler:
-                return None
-
-    def authorize_peer(self, iface, cmd, source, peer=None):
-        return True
-
-#Disabling test
-#class TrivialTests(unittest.TestCase):
-class TrivialTests(object):
-
-    class DummyEniHandler(object):
-        def __init__(self, call_func):
-            self.called = False
-            self._call_func = call_func
-            
-        def __call__(self, cmd):
-            self.called = True
-            self._call_func()
-
-        def attach_manip(self, manip):
-            return
-
-        family = ''
-
-    class DummyDHCPHandler(object):
-        def __init__(self, call_func):
-            self.called = False
-            self._call_func = call_func
-            
-        def __call__(self, cmd):
-            self.called = True
-            self._call_func()
-
-        def attach_manip(self, manip):
-            return
-
-        family = ''
-
-
-    def setUp(self):
-        self._iface = 'eth0'
-        self._core = DummyCore()
-
-    def _setupControlFlow(self, enihandler, dhcphandler):
-        self._control_flow = { 
-            self._iface: { 
-                'IFUP': { 
-                    None: {
-                        None: enihandler
-                        },
-                    enihandler: {
-                        ('UNKNOWNCOMMAND',): dhcphandler,
-                        ('UNKNOWNIFACE',): dhcphandler
-                        },
-                    dhcphandler: { }
-                    }
-                }
-            }
-        
-    
-    def testSingleSuccessful(self):
-        enihandler = TrivialTests.DummyEniHandler(lambda: None)
-        dhcphandler = TrivialTests.DummyDHCPHandler(lambda: None)
-        self._setupControlFlow(enihandler, dhcphandler)
-
-        self._config = DummyConfigBroker(enihandler, None)
-
-        self._policy = IfacePolicy(self._core, self._config)
-        self.assertRaises(SuccessResult,
-                          self._policy, self._iface, "IFUP", "netlink")
-        print self._config.calls
-        self.assertEqual(len(self._config.calls), 2)
-        self.assertEqual(self._config.calls[0], (self._iface, "IFUP", None, None))        
-        self.assertEqual(self._config.calls[1], (self._iface, "IFUP", enihandler, None))
-        self.assertTrue(enihandler.called)
-
-    def testFirstFailedSecondSuccessful(self):
-        enihandler = TrivialTests.DummyEniHandler(lambda: raise_e(UnknownCommandResult))
-        dhcphandler = TrivialTests.DummyDHCPHandler(lambda: None)
-        self._setupControlFlow(enihandler, dhcphandler)
-        self._config = DummyConfigBroker(enihandler, dhcphandler)
-
-        self._policy = IfacePolicy(self._core, self._config)
-        self.assertRaises(SuccessResult,
-                          self._policy, self._iface, "IFUP", "netlink")
-        print self._config.calls
-        self.assertEqual(len(self._config.calls), 3)
-        self.assertEqual(self._config.calls[0], 
-                         (self._iface, "IFUP", None, None))
-        self.assertEqual(self._config.calls[1], 
-                         (self._iface, "IFUP", enihandler, 'UNKNOWNCOMMAND'))
-        self.assertEqual(self._config.calls[2], 
-                         (self._iface, "IFUP", dhcphandler, None))
-
-        self.assertTrue(enihandler.called)
-        self.assertTrue(dhcphandler.called)
-
-    def testBothFailed(self):
-        enihandler = TrivialTests.DummyEniHandler( \
-            lambda: raise_e(UnknownCommandResult))
-        dhcphandler = TrivialTests.DummyDHCPHandler(lambda: raise_e(CmdResult))
-        self._setupControlFlow(enihandler, dhcphandler)
-        self._config = DummyConfigBroker(enihandler, dhcphandler)
-
-        result_callback = lambda e: self._results.append(e)
-
-        self._policy = IfacePolicy(self._core, self._config)
-        self._policy(self._iface, "IFUP", "netlink", result_callback)
-#        self.assertTrue(self._last_result, 
-                          
-        print self._config.calls
-        self.assertEqual(len(self._config.calls), 3)
-        self.assertEqual(self._config.calls[0], 
-                         (self._iface, "IFUP", None, None))
-        self.assertEqual(self._config.calls[1], 
-                         (self._iface, "IFUP", enihandler, 'UNKNOWNCOMMAND'))
-        self.assertEqual(self._config.calls[2], 
-                         (self._iface, "IFUP", dhcphandler, 'CMD'))
-
-        self.assertTrue(enihandler.called)
-        self.assertTrue(dhcphandler.called)
-
-    def testTwoInARowSuccessful(self):
-        """It should be possible to follow a successful result with another."""
-        enihandler = TrivialTests.DummyEniHandler(lambda: None)
-        dhcphandler = TrivialTests.DummyDHCPHandler(lambda: None)
-        self._setupControlFlow(enihandler, dhcphandler)
-
-        self._config = DummyConfigBroker(enihandler, None)
-
-        self._policy = IfacePolicy(self._core, self._config)
-        self.assertRaises(SuccessResult,
-                          self._policy, self._iface, "IFUP", "netlink")
-        print self._config.calls
-        self.assertEqual(len(self._config.calls), 2)
-        self.assertEqual(self._config.calls[0], (self._iface, "IFUP", None, None))        
-        self.assertEqual(self._config.calls[1], (self._iface, "IFUP", enihandler, None))
-        self.assertTrue(enihandler.called)
-
-- 
1.6.2.4




More information about the netconf-devel mailing list