def test_phone_call_iter(self): handler = self._make_phone_call() r = runners.HierarchicalRunner(handler) transitions = list(r.run_iter('call')) self.assertEqual(('talk', 'hangup'), transitions[-1]) self.assertEqual(("begin", 'phone'), transitions[0]) talk_talk = 0 for transition in transitions: if transition == ("talk", "talk"): talk_talk += 1 self.assertGreater(talk_talk, 0)
def test_phone_dialer_iter(self): dialer, number_calling = self._make_phone_dialer() self.assertEqual(0, len(number_calling)) r = runners.HierarchicalRunner(dialer) transitions = list(r.run_iter('dial')) self.assertEqual(('talk', 'hangup'), transitions[-1]) self.assertEqual( len(number_calling), sum(1 if new_state == 'accumulate' else 0 for (old_state, new_state) in transitions)) self.assertEqual(10, len(number_calling))
def test_phone_call(self): handler = self._make_phone_call() r = runners.HierarchicalRunner(handler) r.run('call') self.assertTrue(handler.terminated)