Add tests for api/server.py
some of the new tests require that we first build the documentation
This commit is contained in:
parent
32db249538
commit
1c977b79ef
3
Makefile
3
Makefile
@ -25,7 +25,8 @@ check:
|
|||||||
@echo "*** Running pylint ***"
|
@echo "*** Running pylint ***"
|
||||||
PYTHONPATH=$(PYTHONPATH):./src/ ./tests/pylint/runpylint.py
|
PYTHONPATH=$(PYTHONPATH):./src/ ./tests/pylint/runpylint.py
|
||||||
|
|
||||||
test:
|
# /api/docs/ tests require we have the documentation already built
|
||||||
|
test: docs
|
||||||
@echo "*** Running tests ***"
|
@echo "*** Running tests ***"
|
||||||
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \
|
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \
|
||||||
--cover-package=pylorax --cover-inclusive \
|
--cover-package=pylorax --cover-inclusive \
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
@ -53,6 +54,11 @@ class ServerTestCase(unittest.TestCase):
|
|||||||
def tearDownClass(self):
|
def tearDownClass(self):
|
||||||
shutil.rmtree(server.config["REPO_DIR"])
|
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):
|
def test_01_status(self):
|
||||||
"""Test the /api/v0/status route"""
|
"""Test the /api/v0/status route"""
|
||||||
status_dict = {"build":"devel", "api":"0", "db_version":"0", "schema_version":"0", "db_supported":False}
|
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")
|
recipes = data.get("recipes")
|
||||||
self.assertEqual(len(recipes), 1)
|
self.assertEqual(len(recipes), 1)
|
||||||
self.assertEqual(recipes[0], test_recipe)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user