Exemplo n.º 1
0
 def command_broker_timer_changed(self, kafka_obj_type: KafkaInterface):
     result = BrokerAndTopicValidator.extract_addr_and_topic(
         self.command_broker_edit.text())
     if result is not None:
         if self.command_producer is not None:
             self.command_producer.close()
         self.command_producer = kafka_obj_type(*result)
Exemplo n.º 2
0
 def _set_up_broker_fields(
     led: Led,
     edit: QLineEdit,
     timer: QTimer,
     timer_callback: Callable,
     kafka_obj_type: Type[KafkaInterface],
 ):
     led.turn_off()
     validator = BrokerAndTopicValidator()
     edit.setValidator(validator)
     validator.is_valid.connect(partial(validate_line_edit, edit))
     edit.textChanged.connect(lambda: timer.start(1000))
     timer.setSingleShot(True)
     timer.timeout.connect(partial(timer_callback, kafka_obj_type))
def test_GIVEN_valid_broker_and_topic_WHEN_validating_broker_topic_edit_THEN_validator_emits_correctly(
    test_input, expected
):
    validator = BrokerAndTopicValidator()
    validator.is_valid = Mock()
    assert validator.validate(test_input, 0) == expected