Skip to content
Browse files

[coverage] Relocate html coverage report to a dedicated app

  • Loading branch information...
lovett committed Jun 3, 2019
1 parent 55dbb9b commit 595bf382bf37e05ea4e7a8d532f15adfe5d74957
Showing with 82 additions and 3 deletions.
  1. +2 −1 .gitignore
  2. +1 −0 .rsync-filter
  3. +2 −2 Makefile
  4. +25 −0 apps/coverage/
  5. +52 −0 apps/coverage/
@@ -9,7 +9,8 @@ medley.conf
@@ -32,3 +32,4 @@
- /.pylintrc
- /pytest.ini
- /.pytest_cache
- /apps/coverage
@@ -153,14 +153,14 @@ $(REQUIREMENTS_FILES): dummy
# into a master .coverage file at the project root.
# Two reports are generated: a plain-text version for the command line
# and an HTML version stored in the htmlcov directory.
# and an HTML version stored in the static directory of the coverage app.
# The merging process will remove the intermediate .coverage files,
# making this rule ineligible for skipping.
coverage: $(addprefix .coverage., $(APPS) $(PLUGINS) $(PARSERS))
coverage combine $(COVERAGE_DIR)
coverage report
coverage html
coverage html -d apps/coverage/static

# Run the tests for everything.
@@ -0,0 +1,25 @@
"""Display Medley's test coverage report."""

import cherrypy

class Controller:
"""Dispatch application requests based on HTTP verb."""

name = "Coverage"

def GET():
"""Redirect to the coverage report.
The coverage report is the index.html file in this apps's
static directory.

redirect_url = cherrypy.engine.publish(

raise cherrypy.HTTPRedirect(redirect_url)
@@ -0,0 +1,52 @@
Test suite for the coverage app

import unittest
import mock
from testing.assertions import ResponseAssertions
from testing import helpers
from testing.cptestcase import BaseCherryPyTestCase
import apps.coverage.main

class TestCoverage(BaseCherryPyTestCase, ResponseAssertions):
Tests for the coverage application controller

def setUpClass(cls):
"""Start a faux cherrypy server"""

def tearDownClass(cls):
"""Shut down the faux server"""

def test_allow(self):
"""Verify the controller's supported HTTP methods"""
response = self.request("/", method="HEAD")
self.assertAllowedMethods(response, ("GET",))

def test_redirect(self, publish_mock):
"""The controller's sole job is to redirect to the report."""

def side_effect(*args, **_):
"""Side effects local function"""
if args[0] == "url:internal":
return ["/static/index.html"]

return mock.DEFAULT

publish_mock.side_effect = side_effect

response = self.request("/")
self.assertEqual(response.code, 303)
self.assertIn("/static/index.html", response.headers.get("Location"))

if __name__ == "__main__":

0 comments on commit 595bf38

Please sign in to comment.
You can’t perform that action at this time.