From c9d885a0a25f867b835c9e44c02fdda289bdf57f Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Wed, 13 Nov 2019 15:53:34 +0100 Subject: [PATCH] Tests for webui with build numbers --- tests/test_webinterface.py | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/test_webinterface.py diff --git a/tests/test_webinterface.py b/tests/test_webinterface.py new file mode 100644 index 0000000..c4f622c --- /dev/null +++ b/tests/test_webinterface.py @@ -0,0 +1,59 @@ +# encoding: utf-8 +# +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2019 Timm Fitschen (t.fitschen@indiscale.com) +# Copyright (C) 2019 IndiScale GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# ** end header +# +"""Created on 2019-11-12 + +@author: Timm Fitschen (t.fitschen@indiscale.com) +""" +import caosdb as c +from urllib import request +from urllib.error import HTTPError +import ssl +import re +import pytest + +def test_webinterface_version_build(): + url = c.get_config().get("Connection", "url") + + context = ssl.SSLContext() + context.verify_mode = ssl.CERT_NONE + + buildNumber = request.urlopen(url + "webinterface/version/build", + context=context).read().decode("utf8") + assert re.match(r"\d+", buildNumber) + +def test_webinterface(): + url = c.get_config().get("Connection", "url") + + context = ssl.SSLContext() + context.verify_mode = ssl.CERT_NONE + + buildNumber = request.urlopen(url + "webinterface/version/build", + context=context).read().decode("utf8") + + with pytest.raises(HTTPError) as e404: + request.urlopen(url + "webinterface/..", context=context) + assert e404.value.code == 404 + + + -- GitLab