def runscope_webhook():
    app.logger.info("Received webhook: %s" % str(request.get_json()))
    valid = is_valid_error(request.get_json())
    if valid:
        # post that the api is down
        change_status_to_down(request.get_json())
        post_to_twitter(request.get_json())
    elif not is_error(request.get_json()):
        app.logger.info("test is passing, now checking if we have it set as down and need to set it as up")
        # check if we need to update the 'down' status to 'up'
        if not check_status(request.get_json()):
            # the status is down
            app.logger.info("the status is down and we need to set it as up")
            change_status_to_up(request.get_json())
            post_to_twitter_back_up(request.get_json())

    return "SUCCESS"
예제 #2
0
 def test_is_valid_error(self):
     with app.test_client() as c:
         rv = c.post('/runscope_webhook')
         is_valid_error(request.get_json())