Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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__)
Exemplo n.º 6
0
 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)