Пример #1
0
 def testUnconsumedSideEffects(self):
     agent = self.ball.load(self.instance)
     expectations = [
         testsuite.side_effect('AgencyAgent.get_time', 'result'),
         testsuite.side_effect('AgencyAgent.get_time', 'result2')]
     self.assertRaises(ReplayError, self.ball.call, expectations,
                       agent.call_side_effect)
Пример #2
0
 def testManangerMethod(self):
     m = self.ball.generate_manager(self.instance, DummyManager)
     manager = self.ball.load(m)
     address = recipient.Agent(agent_id=self.ball.descriptor.doc_id,
                               route=self.ball.descriptor.shard)
     args = (
         testsuite.message(payload=dict(level=0, joining_agent=address)), )
     expected = [
         testsuite.side_effect('AgencyAgent.get_own_address', address),
         testsuite.side_effect('AgencyManager.announce', args=args)]
     output, state = self.ball.call(expected, manager.initiate)
Пример #3
0
    def testCallDependency(self):
        expected = [
            testsuite.side_effect('AgencyAgent.get_mode',
                                  ExecMode.test, (SomeInterface, ))]
        out, _ = self.ball.call(expected, self.agent.dependency, SomeInterface)
        self.assertEqual(out, ExecMode.test)


        expected = [
            testsuite.side_effect('AgencyAgent.get_mode',
                                  ExecMode.production, (SomeInterface, ))]
        out, _ = self.ball.call(expected, self.agent.dependency, SomeInterface)
        self.assertEqual(out, ExecMode.production)
Пример #4
0
 def testCallingSideEffect(self):
     agent = self.ball.load(self.instance)
     expectations = [
         testsuite.side_effect('AgencyAgent.get_time', 'result')]
     output, state = self.ball.call(expectations, agent.call_side_effect)
     self.assertEqual('result', output)
     self.assertEqual('result', state.time)
Пример #5
0
 def testMixin(self):
     expected = [
         testsuite.side_effect('AgencyAgent.get_mode',
                               ExecMode.test, (MixinInterface, ))]
     out, _ = self.ball.call(
         expected, self.agent.dependency, MixinInterface)
     self.assertEqual(out, ExecMode.test)
Пример #6
0
 def testWorksSameForImmutable(self):
     agent = self.ball.load(self.instance)
     output, state = self.ball.call(None, agent.perform_async_job)
     expectations = [
         testsuite.side_effect('AgencyAgent.get_time', 'result')]
     output, state = self.ball.call(expectations, agent.some_immutable)
     self.assertFalse('var' in state.__dict__)
     self.assertFiberTriggered(output, fiber.TriggerType.succeed, 'var')
     self.assertFiberCalls(output, agent.define_in_state, args=('result', ))
Пример #7
0
 def testCallUndefined(self):
     expected = [
         testsuite.side_effect('AgencyAgent.get_mode',
                               ExecMode.simulation, (SomeInterface, ))]
     self.assertRaises(dependency.UndefinedDependency, self.ball.call,
                       expected, self.agent.dependency, SomeInterface)
Пример #8
0
 def testCallUnknown(self):
     expected = [
         testsuite.side_effect('AgencyAgent.get_mode',
                               ExecMode.test, (UnknownInterface, ))]
     self.assertRaises(dependency.UndefinedDependency, self.ball.call,
                       expected, self.agent.dependency, UnknownInterface)