From f4b5e6e1ea17df5f0fb1d75145a8914c135dc965 Mon Sep 17 00:00:00 2001 From: Sofya Ignatova Date: Mon, 29 Jun 2020 12:13:37 -0700 Subject: [PATCH 1/2] Add tests for server --- server-example/requirements.txt | 1 + server-example/test_app.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 server-example/test_app.py diff --git a/server-example/requirements.txt b/server-example/requirements.txt index 4ff2cec..1a4763b 100644 --- a/server-example/requirements.txt +++ b/server-example/requirements.txt @@ -1,2 +1,3 @@ Flask>1.1 pybadges +pytest diff --git a/server-example/test_app.py b/server-example/test_app.py new file mode 100644 index 0000000..83c418b --- /dev/null +++ b/server-example/test_app.py @@ -0,0 +1,13 @@ +import pytest + +import app + +@pytest.fixture +def client(): + with app.app.test_client() as client: + yield client + +def test_image(client): + rv = client.get("/") + assert b'build' in rv.data + assert b'passing' in rv.data \ No newline at end of file From 6e35a0af0236a4694229b0acefe1063dba2f5307 Mon Sep 17 00:00:00 2001 From: Sofya Ignatova Date: Mon, 29 Jun 2020 14:00:54 -0700 Subject: [PATCH 2/2] Fix from feedback --- noxfile.py | 10 +++++++--- server-example/requirements-test.txt | 2 ++ server-example/requirements.txt | 1 - server-example/test_app.py | 19 ++++++++++++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 server-example/requirements-test.txt diff --git a/noxfile.py b/noxfile.py index d111040..12a4738 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,6 +22,7 @@ def _run_tests(session): 'py.test', '--quiet', 'tests', + 'server-example', *session.posargs ) @@ -33,24 +34,27 @@ def lint(session): serious code quality issues. """ session.install('flake8') - session.run('flake8', - 'pypadges,tests') + session.run('flake8', 'pybadges') + session.run('flake8', 'tests') + session.run('flake8', 'server-example') @nox.session def unit(session): """Run the unit test suite.""" session.install('-e', '.[dev]') + session.install('-r', 'server-example/requirements-test.txt') _run_tests(session) -@nox.session(python=['3.4', '3.5', '3.6', '3.7']) +@nox.session(python=['3.4', '3.5', '3.6', '3.7', '3.8']) @nox.parametrize('install', ['Jinja2==2.9.0', 'Pillow==5.0.0', 'requests==2.9.0', 'xmldiff==2.4']) def compatibility(session, install): """Run the unit test suite with each support library and Python version.""" session.install('-e', '.[dev]') + session.install('-r', 'server-example/requirements-test.txt') session.install(install) _run_tests(session) diff --git a/server-example/requirements-test.txt b/server-example/requirements-test.txt new file mode 100644 index 0000000..26b77f6 --- /dev/null +++ b/server-example/requirements-test.txt @@ -0,0 +1,2 @@ +-r requirements.txt +pytest diff --git a/server-example/requirements.txt b/server-example/requirements.txt index 1a4763b..4ff2cec 100644 --- a/server-example/requirements.txt +++ b/server-example/requirements.txt @@ -1,3 +1,2 @@ Flask>1.1 pybadges -pytest diff --git a/server-example/test_app.py b/server-example/test_app.py index 83c418b..36587b4 100644 --- a/server-example/test_app.py +++ b/server-example/test_app.py @@ -1,3 +1,20 @@ +# Copyright 2020 The pybadge Authors +# +# 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 +# +# https://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. + +"Tests for app" + + import pytest import app @@ -10,4 +27,4 @@ def client(): def test_image(client): rv = client.get("/") assert b'build' in rv.data - assert b'passing' in rv.data \ No newline at end of file + assert b'passing' in rv.data