Browse Source

Minor testing-related cleanup

* Move docs dependencies out of test-requirements.txt
* Eliminate python version specific test (py35)
* Re-order default envlist to shorten feedback cycle
* Minor whitespace changes
* Simplify versions unit test
* Add /.cache to .gitignore
* Include tests directory in basic format requirements, but not flake8
* Fix sample noauth-api-paste.ini config

Change-Id: I440f5c2d988098287f9914449f7103735f832192
changes/93/569193/1
Mark Burnett 4 years ago
parent
commit
b9dceb2a9a
6 changed files with 44 additions and 20 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      etc/promenade/noauth-api-paste.ini
  3. +0
    -3
      test-requirements.txt
  4. +15
    -0
      tests/unit/api/test_health_api.py
  5. +16
    -3
      tests/unit/api/test_versions.py
  6. +11
    -13
      tox.ini

+ 1
- 0
.gitignore View File

@ -7,6 +7,7 @@
/charts/*/requirements.lock
# Build & test artifacts
/.cache
/.eggs
/.helm-pid
/.tox


+ 1
- 1
etc/promenade/noauth-api-paste.ini View File

@ -17,7 +17,7 @@
[filter:noauth]
forged_roles = admin
paste.filter_factory = promenade.control.middleware:no_auth_filter_factory
paste.filter_factory = promenade.control.middleware:noauth_filter_factory
[app:promenade-api]
disable = keystone


+ 0
- 3
test-requirements.txt View File

@ -1,4 +1 @@
# Documentation
pytest
sphinx>=1.6.2
sphinx_rtd_theme==0.2.4

+ 15
- 0
tests/unit/api/test_health_api.py View File

@ -1,3 +1,17 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import falcon
from falcon import testing
import pytest
@ -10,6 +24,7 @@ from promenade.promenade import promenade
def client():
return testing.TestClient(promenade)
def test_get_health(client):
response = client.simulate_get('/api/v1.0/health')
assert response.status == falcon.HTTP_204

+ 16
- 3
tests/unit/api/test_versions.py View File

@ -1,3 +1,17 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import falcon
from falcon import testing
import pytest
@ -10,9 +24,8 @@ from promenade.promenade import promenade
def client():
return testing.TestClient(promenade)
def test_get_versions(client):
response = client.simulate_get('/versions')
assert response.status == falcon.HTTP_200
body = response.content.decode('utf-8')
assert '"path": "/api/v1.0"' in body
assert '"status": "stable"' in body
assert response.json == {'v1.0': {'path': '/api/v1.0', 'status': 'stable'}}

+ 11
- 13
tox.ini View File

@ -1,18 +1,13 @@
[tox]
envlist = py35,unit,bandit,lint,docs
envlist = lint,unit,bandit,docs
[testenv]
setenv=
[testenv:unit]
setenv =
PYTHONWARNING=all
commands=
pytest \
{posargs}
deps = -r{toxinidir}/requirements-frozen.txt
-r{toxinidir}/test-requirements.txt
[testenv:unit]
commands =
pytest tests/unit
pytest
[testenv:bandit]
deps = bandit==1.4.0
@ -20,7 +15,10 @@ commands =
bandit -r promenade
[testenv:docs]
whitelist_externals=rm
whitelist_externals = rm
deps =
sphinx>=1.6.2
sphinx_rtd_theme==0.2.4
commands =
rm -rf docs/build
python setup.py build_sphinx {posargs}
@ -28,12 +26,12 @@ commands =
[testenv:fmt]
deps = yapf==0.20.0
commands =
yapf -ir {toxinidir}/promenade
yapf -ir {toxinidir}/promenade {toxinidir}/tests
[testenv:freeze]
deps = -r{toxinidir}/requirements-direct.txt
recreate = True
whitelist_externals=sh
whitelist_externals = sh
commands=
sh -c "pip freeze | grep -v '^promenade' > {toxinidir}/requirements-frozen.txt"
@ -49,5 +47,5 @@ deps =
yapf==0.20.0
flake8==3.5.0
commands =
yapf -rd {toxinidir}/promenade
yapf -rd {toxinidir}/promenade {toxinidir}/tests
flake8 {toxinidir}/promenade

Loading…
Cancel
Save