From 5b0d662007a4cb19a746063e630fd0c3f28b4562 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 7 Nov 2017 12:00:35 -0800 Subject: [PATCH] Add basic API Server testing framework --- tests/pylorax/test_server.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/pylorax/test_server.py diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py new file mode 100644 index 00000000..a6b5f539 --- /dev/null +++ b/tests/pylorax/test_server.py @@ -0,0 +1,40 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +import os +import unittest + +from flask import json +from pylorax.api.server import server + + +class ServerTestCase(unittest.TestCase): + + @classmethod + def setUpClass(self): + server.config['TESTING'] = True + self.server = server.test_client() + + @classmethod + def tearDownClass(self): + pass + + def test_status(self): + """Test the /api/v0/status route""" + status_dict = {"build":"devel", "api":"0", "db_version":"0", "schema_version":"0", "db_supported":False} + resp = self.server.get("/api/v0/status") + data = json.loads(resp.data) + self.assertEqual(data, status_dict)