class RouterPBTestCases(TestCase): def setUp(self): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.routerpb_config = RouterPBConfig() # Instanciate RouterPB but will not launch a server # we only need the instance to access its .users attribute # for authentication self.routerpb_factory = RouterPB() self.routerpb_factory.setConfig(self.routerpb_config, persistenceTimer=False) # Provision a user and default route into RouterPB self.foo = User('u1', Group('test'), 'username', 'password') self.c1 = SmppClientConnector(id_generator()) self.defaultroute = DefaultRoute(self.c1) self.provision_user_defaultroute(user=self.foo, defaultroute=self.defaultroute) def provision_user_defaultroute(self, user, defaultroute=None): # This is normally done through jcli API (or any other high level API to come) # Using perspective_user_add() is just a shortcut for testing purposes if user.group not in self.routerpb_factory.groups: self.routerpb_factory.perspective_group_add( pickle.dumps(user.group)) self.routerpb_factory.perspective_user_add(pickle.dumps(user)) # provision route if defaultroute is not None: self.routerpb_factory.perspective_mtroute_add( pickle.dumps(defaultroute), 0)
class RouterPBTestCases(TestCase): def setUp(self): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.routerpb_config = RouterPBConfig() # Instanciate RouterPB but will not launch a server # we only need the instance to access its .users attribute # for authentication self.routerpb_factory = RouterPB(self.routerpb_config, persistenceTimer=False) # Provision a user and default route into RouterPB self.foo = User('u1', Group('test'), 'username', 'password') self.c1 = SmppClientConnector(id_generator()) self.defaultroute = DefaultRoute(self.c1) self.provision_user_defaultroute(user = self.foo, defaultroute = self.defaultroute) def provision_user_defaultroute(self, user, defaultroute = None): # This is normally done through jcli API (or any other high level API to come) # Using perspective_user_add() is just a shortcut for testing purposes if user.group not in self.routerpb_factory.groups: self.routerpb_factory.perspective_group_add(pickle.dumps(user.group, pickle.HIGHEST_PROTOCOL)) self.routerpb_factory.perspective_user_add(pickle.dumps(user, pickle.HIGHEST_PROTOCOL)) # provision route if defaultroute is not None: self.routerpb_factory.perspective_mtroute_add(pickle.dumps(defaultroute, pickle.HIGHEST_PROTOCOL), 0)