diff --git a/Makefile b/Makefile index e27641cb..61edec2b 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ check: @echo "*** Running pylint ***" PYTHONPATH=$(PYTHONPATH):./src/ ./tests/pylint/runpylint.py -test: +# /api/docs/ tests require we have the documentation already built +test: docs @echo "*** Running tests ***" PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \ --cover-package=pylorax --cover-inclusive \ diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index 83b38162..ceeb89b6 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +import os import shutil import tempfile from threading import Lock @@ -53,6 +54,11 @@ class ServerTestCase(unittest.TestCase): def tearDownClass(self): shutil.rmtree(server.config["REPO_DIR"]) + def test_00_hello(self): + """Test /""" + resp = self.server.get("/") + self.assertEqual(resp.data, 'Hello, World!') + def test_01_status(self): """Test the /api/v0/status route""" status_dict = {"build":"devel", "api":"0", "db_version":"0", "schema_version":"0", "db_supported":False} @@ -484,3 +490,15 @@ class ServerTestCase(unittest.TestCase): recipes = data.get("recipes") self.assertEqual(len(recipes), 1) self.assertEqual(recipes[0], test_recipe) + + def test_api_docs(self): + """Test the /api/docs/""" + resp = self.server.get("/api/docs/") + doc_str = open(os.path.abspath(joinpaths(os.path.dirname(__file__), "../../docs/html/index.html"))).read() + self.assertEqual(doc_str, resp.data) + + def test_api_docs_with_existing_path(self): + """Test the /api/docs/modules.html""" + resp = self.server.get("/api/docs/modules.html") + doc_str = open(os.path.abspath(joinpaths(os.path.dirname(__file__), "../../docs/html/modules.html"))).read() + self.assertEqual(doc_str, resp.data)