def mk_tunnel_recipient(self, agent): # Verry hacky... medium = agent._get_state().medium backend = medium.agency._backends["tunnel"] key = agent.get_agent_id() route = backend.route return recipient.Recipient(key, route, backend.channel_type)
def testConstructDummyAgent(self): agent = self.ball.load(self.instance) self.assertIsInstance(agent, DummyAgent) self.assertTrue(self.ball.medium is not None) state = agent._get_state() self.assertIsInstance(state, guard.MutableState) self.assertEqual(5, state.value) self.assertIsInstance(state.resources, resource.Resources)
def testDefaultResources(self): agent = self.get_local('agent') totals = agent._get_state().resources.get_totals() self.assertTrue("host" in totals) self.assertTrue("bandwidth" in totals) self.assertTrue("epu" in totals) self.assertTrue("core" in totals) self.assertTrue("mem" in totals)
def testDefaultRequeriments(self): agent = self.get_local('agent') cats = agent._get_state().categories self.assertTrue("access" in cats) self.assertTrue("storage" in cats) self.assertTrue("address" in cats) self.assertEqual(cats["access"], Access.private) self.assertEqual(cats["address"], Address.fixed) self.assertEqual(cats["storage"], Storage.static)
def testStateChangingFunc(self): agent = self.ball.load(self.instance) self.assertFalse('var' in agent._get_state().__dict__) output, state = self.ball.call(None, agent.define_in_state, 'var', 4) self.assertEqual(4, state.var) self.assertTrue('var' in agent._get_state().__dict__)
def testDefaultRequeriments(self): agent = self.get_local('agent') cats = agent._get_state().categories self.assertTrue("access" in cats) self.assertTrue("storage" in cats) self.assertTrue("address" in cats)