コード例 #1
0
        abort(400)

    temperature = request.json['temperature']
    id = request.json['id']

    if temperature < 10 or temperature > 100:
        abort(400)

    print("Starting to send message")
    publish_temperature(channel, temperature, id)

    return jsonify({'result': 'success'}), 201


@app.route('/')
def hello():
    """Renders a sample page."""
    return "Hello World!"


if __name__ == '__main__':
    import os
    HOST = os.environ.get('SERVER_HOST', 'localhost')
    try:
        PORT = int(os.environ.get('SERVER_PORT', '5555'))
    except ValueError:
        PORT = 5555
    app.run(HOST, PORT)
    print("Terminating app")
    cleanup(connection)
コード例 #2
0
def test_cleanup_removes_tar_gz_files(remove_mock, glob_mock):
    glob_mock.return_value = 'a'
    publish.cleanup()
    assert call('a') in remove_mock.mock_calls
    assert call('github_request.json') in remove_mock.mock_calls
コード例 #3
0
def test_cleanup(remove_mock):
    publish.cleanup()
    assert remove_mock.call_count > 0