| 1 | #!/usr/bin/env python2
 | 
| 2 | """
 | 
| 3 | web_test.py: Tests for web.py
 | 
| 4 | """
 | 
| 5 | from __future__ import print_function
 | 
| 6 | 
 | 
| 7 | import unittest
 | 
| 8 | 
 | 
| 9 | from soil import web  # module under test
 | 
| 10 | 
 | 
| 11 | 
 | 
| 12 | class WebTest(unittest.TestCase):
 | 
| 13 | 
 | 
| 14 |   def testParse(self):
 | 
| 15 |     print(web._ParsePullTime('real 19.99'))
 | 
| 16 | 
 | 
| 17 |   def testTemplates(self):
 | 
| 18 |     print(web.HTML_BODY_TOP_T.expand({'title': 'title & other'}))
 | 
| 19 | 
 | 
| 20 |     job = {
 | 
| 21 |         'job_num': '123',
 | 
| 22 |         'job_url': 'https://yo',
 | 
| 23 |         'git-branch': 'soil-staging',
 | 
| 24 |         'run_wwz_path': 'dev-minimal.wwz',
 | 
| 25 |         'index_run_url': '123/',
 | 
| 26 | 
 | 
| 27 |         'job-name': 'dev-minimal',
 | 
| 28 |         'start_time_str': '2:22',
 | 
| 29 |         'pull_time_str': '1:00',
 | 
| 30 |         'run_time_str': '2:00',
 | 
| 31 | 
 | 
| 32 |         'details-url': '1234/',
 | 
| 33 | 
 | 
| 34 |         'GITHUB_RUN_NUMBER': '1234',
 | 
| 35 | 
 | 
| 36 |         'run_tsv_path': 'tsv',
 | 
| 37 |         'run_json_path': 'json',
 | 
| 38 |         'run_wwz_path': 'wwz',
 | 
| 39 |         }
 | 
| 40 | 
 | 
| 41 |     jobs = [job]
 | 
| 42 | 
 | 
| 43 |     jobs.sort(key=web.ByGithubRun, reverse=True)
 | 
| 44 |     groups = web.GroupJobs(jobs, web.ByGithubRun)
 | 
| 45 | 
 | 
| 46 |     web.PrintIndexHtml('title', groups)
 | 
| 47 | 
 | 
| 48 |     web.PrintRunHtml('title', jobs)
 | 
| 49 | 
 | 
| 50 | 
 | 
| 51 | if __name__ == '__main__':
 | 
| 52 |   unittest.main()
 |