Merge lp:~dholbach/help-app/1428677 into lp:~ubuntu-touch-coreapps-drivers/help-app/trunk

Proposed by Daniel Holbach
Status: Merged
Merged at revision: 86
Proposed branch: lp:~dholbach/help-app/1428677
Merge into: lp:~ubuntu-touch-coreapps-drivers/help-app/trunk
Prerequisite: lp:~dholbach/help-app/1428678
Diff against target: 121 lines (+87/-1)
3 files modified
HACKING (+14/-0)
edit-here/Makefile (+1/-1)
edit-here/tests/test_links.py (+72/-0)
To merge this branch: bzr merge lp:~dholbach/help-app/1428677
Reviewer Review Type Date Requested Status
Ubuntu Core Apps Drivers Pending
Review via email: mp+252302@code.launchpad.net

This proposal supersedes a proposal from 2015-03-09.

To post a comment you must log in.
lp:~dholbach/help-app/1428677 updated
87. By Daniel Holbach

remove unused code

88. By Daniel Holbach

explain what we do in terms of testing

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

+1, Just a small comment.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'HACKING'
--- HACKING 2015-03-09 12:01:16 +0000
+++ HACKING 2015-03-09 16:09:32 +0000
@@ -57,6 +57,7 @@
57    ├── content57    ├── content
58    │   └── pages ← Here is the place to edit the content.58    │   └── pages ← Here is the place to edit the content.
59    ├── po ← Translations.59    ├── po ← Translations.
60    ├── tests ← Code for automated testing goes here.
60    └── themes ← Themes files, both templates and css/js.61    └── themes ← Themes files, both templates and css/js.
61       ├── phone ← Phone/device app theme.62       ├── phone ← Phone/device app theme.
62       └── web ← Online build (.ubuntu.com) theme.63       └── web ← Online build (.ubuntu.com) theme.
@@ -131,6 +132,19 @@
131http://www.w3.org/International/questions/qa-apache-lang-neg for publishing132http://www.w3.org/International/questions/qa-apache-lang-neg for publishing
132this on the web.133this on the web.
133134
135Testing
136-------
137
138We love automated testing! We added a couple of test cases to
139
140 ./edit-here/tests/
141
142and it would be great if you added more. We want to run these tests
143whenever we build the package or publish the docs or whatever else. Just
144to make sure that everything works fine. To run the test suite, run:
145
146 make check
147
134148
135Code, bugs, etc.149Code, bugs, etc.
136----------------150----------------
137151
=== modified file 'edit-here/Makefile'
--- edit-here/Makefile 2015-03-09 16:09:32 +0000
+++ edit-here/Makefile 2015-03-06 14:32:59 +0000
@@ -61,7 +61,7 @@
61 @echo ' '61 @echo ' '
6262
63check:63check:
64 ./run-tests && echo true64 ./run-tests
6565
66web:66web:
67 ./generate-translations67 ./generate-translations
6868
=== added file 'edit-here/tests/test_links.py'
--- edit-here/tests/test_links.py 1970-01-01 00:00:00 +0000
+++ edit-here/tests/test_links.py 2015-03-09 16:09:32 +0000
@@ -0,0 +1,72 @@
1import codecs
2from html.parser import HTMLParser
3import os
4import shutil
5import subprocess
6import tempfile
7from unittest import TestCase
8import urllib.parse
9
10
11def require_build(build):
12 tempdir = tempfile.mkdtemp()
13 ret = subprocess.call(['make', '-es', build],
14 env={'OUTPUTDIR': tempdir})
15 return (ret, tempdir)
16
17
18def clean_tempdir(tempdir):
19 if os.path.exists(tempdir):
20 shutil.rmtree(tempdir)
21
22
23class MyHTMLParser(HTMLParser):
24 links = []
25
26 def handle_starttag(self, tag, attrs):
27 if tag == "a":
28 for name, value in attrs:
29 if name == "href":
30 url = urllib.parse.urlparse(value)
31 if not url.netloc or url.netloc == 'localhost':
32 self.links += [value]
33
34 def reload(self):
35 links = self.links
36 self.links = []
37 return links
38
39
40class HelpTestCase(TestCase):
41 def __init__(self, *args):
42 self.pwd = os.getcwd()
43 self.htmlparser = MyHTMLParser()
44 TestCase.__init__(self, *args)
45
46 def __del__(self):
47 os.chdir(self.pwd)
48
49 def _test_local_links(self, build):
50 (ret, tempdir) = require_build(build)
51 if ret:
52 return False
53 for dirpath, dirnames, filenames in os.walk(tempdir):
54 for fn in filenames:
55 full_fn = os.path.join(dirpath, fn)
56 os.chdir(dirpath)
57 if full_fn.endswith('.html'):
58 html = codecs.open(full_fn, encoding='utf-8').read()
59 self.htmlparser.feed(html)
60 links = self.htmlparser.reload()
61 for link in links:
62 rel_path = os.path.relpath(link, full_fn)
63 path = os.path.normpath(os.path.join(full_fn, rel_path))
64 self.assertTrue(os.path.exists(path))
65 clean_tempdir(tempdir)
66 return True
67
68 def test_local_phone_links(self):
69 return self._test_local_links('html')
70
71 def test_local_web_links(self):
72 return self._test_local_links('web')

Subscribers

People subscribed via source and target branches