def test_message_when_content_is_disabled(): content = "This is not part of the message" error_message = 'There has been an error.' message = HTTPCheck._include_content(False, error_message, content) assert message == error_message assert content not in message
def test_message_lenght_when_content_is_too_long(): max_lenght = http_check.MESSAGE_LENGTH try: http_check.MESSAGE_LENGTH = 25 too_long_content = 'this message is too long' error_message = 'There has been an error.' message = HTTPCheck._include_content(True, error_message, too_long_content) finally: http_check.MESSAGE_LENGTH = max_lenght assert len(message) == 25 assert error_message in message assert too_long_content not in message
def test_message_lenght_when_content_is_ok(): content = '''{ "HikariPool-1.pool.ConnectivityCheck" : { "healthy" : true }, "database" : { "healthy" : true, "message" : "Service located at jdbc ostgresql://pgbouncer-server.staging.net is alive. Version: 1.5" }, "deadlocks" : { "healthy" : true } "gateway" : { "healthy" : true, "message" : "Service located at https://apis.staging.eu.people-doc.com is alive." } }''' error_message = 'There has been an error.' message = HTTPCheck._include_content(True, error_message, content) assert len(message) < http_check.MESSAGE_LENGTH assert content in message assert error_message in message