Skip to content

Commit

Permalink
add functional test on report title
Browse files Browse the repository at this point in the history
  • Loading branch information
rizsotto committed Sep 14, 2014
1 parent 9d34030 commit aadb503
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion analyzer/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ def assembly_report(opts, *fragments):
import datetime

if 'html_title' not in opts or opts['html_title'] is None:
opts['html_title'] = opts['prefix'] + ' - analyzer results'
opts['html_title'] = os.path.basename(opts['prefix']) +\
' - analyzer results'

output = os.path.join(opts['out_dir'], 'index.html')
with open(output, 'w') as handle:
Expand Down
36 changes: 36 additions & 0 deletions tests/functional/beye/test_from_cdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,39 @@ def test_broken_does_not_creates_failure_reports(self):
exit_code, output = run_beye(
outdir, ['--input', cdb, '--no-failure-reports'])
self.assertFalse(os.path.isdir(os.path.join(outdir, 'failures')))


class TitleTest(unittest.TestCase):

def assertTitleEqual(self, directory, expected):
import re
patterns = [
re.compile(r'<title>(?P<page>.*)</title>'),
re.compile(r'<h1>(?P<head>.*)</h1>')]
result = dict()

index = os.path.join(directory, 'result', 'index.html')
with open(index, 'r') as handler:
for line in handler.readlines():
for regex in patterns:
match = regex.match(line.strip())
if match:
result.update(match.groupdict())
break
self.assertEqual(result['page'], result['head'])
self.assertEqual(result['page'], expected)

def test_default_title_in_report(self):
with fixtures.TempDir() as tmpdir:
cdb = prepare_broken_cdb(tmpdir)
outdir = os.path.join(tmpdir, 'result')
exit_code, output = run_beye(outdir, ['--input', cdb])
self.assertTitleEqual(tmpdir, 'src - analyzer results')

def test_given_title_in_report(self):
with fixtures.TempDir() as tmpdir:
cdb = prepare_broken_cdb(tmpdir)
outdir = os.path.join(tmpdir, 'result')
exit_code, output = run_beye(
outdir, ['--input', cdb, '--html-title', 'this is the title'])
self.assertTitleEqual(tmpdir, 'this is the title')

0 comments on commit aadb503

Please sign in to comment.