コード例 #1
0
 def test_validity_dict_valid(self):
     """
     Test: The return values
     When: Different dicts are supplied to check_validity_dict (all true, mixed, all false)
     """
     self.assertTrue(process.check_validity_dict(self.true_validity_dict))
     self.assertFalse(process.check_validity_dict(self.mixed_validity_dict))
     self.assertFalse(process.check_validity_dict(self.false_validity_dict))
コード例 #2
0
 def test_validity_dict_log_when_false(self, mock_err_log, mock_dict_to_str):
     """
     Test: A logging error is called with output of dict_to_string
     When: check_validity_dict returns false
     """
     msg = 'Test string'
     mock_dict_to_str.return_value = msg
     self.assertFalse(process.check_validity_dict(self.false_validity_dict))
     mock_err_log.assert_called_once_with(msg)
コード例 #3
0
def validate_data_ready(message):
    """
    Assert a message is ready to be passed to the /DataReady queue
    :param message: A message object to be validated
    :return: True if valid
    """
    validity_dict = {
        'run_number': validators.validate_run_number(message.run_number),
        'instrument': validators.validate_instrument(message.instrument),
        'rb_number': validators.validate_rb_number(message.rb_number),
        'started_by': isinstance(message.started_by, int),
        'file_path': isinstance(message.data, str),
        'facility': isinstance(message.facility, str)
    }
    return check_validity_dict(validity_dict)