def test_birth_bad_config_json(self): """ Test birth with an invalid JSON configuration document. @param self Object reference. """ config_id = datetime.now().microsecond configuration = """{"TOFconversionFactor":BADJSON""" result = birth(self.__panel, config_id, "MapPyPrint", 1, configuration) # Check the status specifies an error. self.validate_status(result, "error")
def test_birth_bad_version(self): """ Test birth with a mismatched MAUS version. @param self Object reference. """ config_id = datetime.now().microsecond configuration = """{"maus_version":"BAD"}""" result = birth(self.__panel, config_id, "MapPyPrint", 1, configuration) # Check the status specifies an error. self.validate_status(result, "error")
def test_birth_pool_exception(self): """ Test birth where the pool throws an exception. @param self Object reference. """ # Configure so that the pool throws an exception. self.__panel.consumer.pool.set_async_success(False) config_id = datetime.now().microsecond configuration = """{"maus_version":"%s"}""" % self.__version result = birth(self.__panel, config_id, "MapPyPrint", 1, configuration) # Check the status specifies an error. self.validate_status(result, "error")
def test_birth(self): """ Test birth. @param self Object reference. """ config_id = datetime.now().microsecond transform = "MapPyPrint" configuration = """{"TOFconversionFactor":%s, "maus_version":"%s"}""" \ % (config_id, self.__version) result = birth(self.__panel, config_id, transform, 1, configuration) # Check the status and that the configuration has been # updated. self.validate_status(result) self.validate_configuration(configuration, transform, config_id) # Check expected function and arguments were passed: self.assertEquals(process_birth, self.__panel.consumer.pool.result.func, "An unexpected function was passed to be invoked") (check_set, check_config_id, check_transform, check_config, check_run_number) = \ self.__panel.consumer.pool.result.arguments self.assertTrue(isinstance(check_set, set), "Expected a set to be passed") self.assertEquals(check_config_id, config_id, "Unexpected config_id was passed to be invoked") self.assertEquals(check_transform, transform, "Unexpected transform was passed to be invoked") self.assertEquals(check_config, configuration, "Unexpected configuration was passed to be invoked") self.assertEquals(check_run_number, 1) # Check that another birth with the same ID is a no-op. Use # different transform name and configuration to be sure. result = birth(self.__panel, config_id, transform, 1, configuration) # Check the status and configuration. self.validate_status(result, "ok") self.validate_configuration(configuration, transform, config_id)