blob: d20f496e8b6e6a8f9b3f3dfc48d992edd57d24df [file] [log] [blame]
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for debug_routes.py."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import httplib
from werkzeug import exceptions
import pytest
import main
import debug_routes
# pylint: disable=redefined-outer-name,unused-argument,protected-access
@pytest.fixture
def client():
main.app.testing = True
return main.app.test_client()
def TestExonerateLoginRequired(client):
assert client.post('/exonerate').status_code == httplib.UNAUTHORIZED
def TestExonerateOnlyPost(client):
assert client.get('/exonerate').status_code == httplib.METHOD_NOT_ALLOWED
def TestBadSchema(client):
with pytest.raises(exceptions.BadRequest):
debug_routes._ValidateSchema(debug_routes._EXONERATE_SCHEMA, {
'cl': 1234,
'internal': True,
'build_id': 42,
})
def TestGoodSchema(client):
debug_routes._ValidateSchema(debug_routes._EXONERATE_SCHEMA, {
'cl': 1234,
'patch': 1,
'internal': True,
'build_id': 42,
})