From ce719de6d17d9b5f4233c130a6586ce265b7fe03 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Tue, 17 Apr 2018 12:40:01 -0700 Subject: [VVP] adding 2 tests to increase sonar Added tests for frontend and config for sonar coverage Change-Id: I9a3648c84c6d673bd86232debbedb1bcfce0d253 Issue-ID: VVP-55 Signed-off-by: stark, steven --- imagescanner/imagescanner/tests/test_config.py | 46 ++++++++++++++++++++++++ imagescanner/imagescanner/tests/test_frontend.py | 45 +++++++++++++++++++++++ requirements.txt | 4 +++ tox.ini | 2 +- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 imagescanner/imagescanner/tests/test_config.py create mode 100644 imagescanner/imagescanner/tests/test_frontend.py create mode 100644 requirements.txt diff --git a/imagescanner/imagescanner/tests/test_config.py b/imagescanner/imagescanner/tests/test_config.py new file mode 100644 index 0000000..41dd446 --- /dev/null +++ b/imagescanner/imagescanner/tests/test_config.py @@ -0,0 +1,46 @@ +# ============LICENSE_START======================================================= +# org.onap.vvp/image-scanner +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# +import os +from .. import config +from pathlib import Path + + +def test_configuration(): + os.environ['IMAGESCANNER_LOGS_PATH'] = '.' + assert config.LOGS_PATH == Path('.') diff --git a/imagescanner/imagescanner/tests/test_frontend.py b/imagescanner/imagescanner/tests/test_frontend.py new file mode 100644 index 0000000..695961e --- /dev/null +++ b/imagescanner/imagescanner/tests/test_frontend.py @@ -0,0 +1,45 @@ +# ============LICENSE_START======================================================= +# org.onap.vvp/image-scanner +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# +from .. import frontend + + +def test_frontend_invalid(): + app = frontend.app + resp = app.test_client().get('/imagescanner/result/invalidlocation') + assert resp.status_code == 404 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..62f85d5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +celery[redis] +flask +requests +requests-aws diff --git a/tox.ini b/tox.ini index 56548a2..fa9b95b 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ commands = {envpython} --version pytest --version pytest --cov imagescanner --cov-report=xml --cov-report=term --verbose -deps = +deps = -rrequirements.txt flake8 pytest-cov pytest -- cgit 1.2.3-korg