Exemple #1
0
 def test_switch_start_protocol_sends_bootstrap_telex_under_correct_conditions(self):
     s_should_send = Switch(seed_ipp=faripp)
     s_should_send.send = Mock()
     s_should_send.startProtocol()
     assert s_should_send.send.called
     s_should_not_send = Switch()
     s_should_not_send.ipp = selfipp
     s_should_not_send.send = Mock()
     s_should_not_send.startProtocol()
     assert not s_should_not_send.send.called
Exemple #2
0
 def test_switch_send_writes_to_transport_iff_the_telex_is_not_empty(self):
     s = Switch()
     s.ipp = selfipp
     s.transport = Mock()
     s.transport.write = Mock()
     empty_tel = Telex()
     s.send(telex=empty_tel, to=End(faripp))
     assert not s.transport.write.called
     tel = Telex(other_dict={'+foo':'bar'})
     s.send(telex=tel, to=End(faripp))
     s.transport.write.assert_called_with(tel.dumps(), faripp)
Exemple #3
0
 def test_end_handler_sends_list_of_ends_to_original_sender(self):
     switch = Switch()
     switch.ipp = selfipp
     switch.ends.add(End(faripp))
     switch.send = Mock()
     self.t(self.seeking_far, self.from_end, switch)
     assert switch.send.called
     tel = switch.send.call_args[-1]['telex']
     assert isinstance(tel, Telex)
     assert ippstr(faripp) in tel['.see']
     assert switch.send.call_args[-1]['to'] == self.from_end