Merge lp:~nskaggs/help-app/functional-test-template-improvements into lp:help-app

Proposed by Nicholas Skaggs
Status: Work in progress
Proposed branch: lp:~nskaggs/help-app/functional-test-template-improvements
Merge into: lp:help-app
Diff against target: 276 lines (+96/-56)
9 files modified
HACKING (+1/-1)
Makefile (+4/-3)
internals/run-functional-tests (+4/-0)
internals/run-unit-tests (+2/-2)
internals/tests/build_utils.py (+49/-0)
internals/tests/functional/help_app/tests/__init__.py (+9/-3)
internals/tests/functional/help_app/tests/test_app.py (+5/-8)
internals/tests/functional/help_app/tests/test_web.py (+13/-0)
internals/tests/unit/test_links.py (+9/-39)
To merge this branch: bzr merge lp:~nskaggs/help-app/functional-test-template-improvements
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Ubuntu Help app developers Pending
Review via email: mp+261626@code.launchpad.net

Commit message

Improve functional test templates; incorporate with build, fix layout

Description of the change

Improve functional test templates; incorporate with build, fix layout

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

It's unclear to me why the unit tests fail atm.

Revision history for this message
Daniel Holbach (dholbach) wrote :

The import of build_utils seems to work for the functional tests, but not for the unit tests for some reason.

Unmerged revisions

161. By Nicholas Skaggs

merge daniel's fixes

160. By Nicholas Skaggs

rollback 159

159. By Nicholas Skaggs

wip

158. By Nicholas Skaggs

fix unit tests, +x functional script

157. By Nicholas Skaggs

add new script to run functional tests, rename unit test script, flake8, update makefile

156. By Nicholas Skaggs

split to test_app and test_web

155. By Nicholas Skaggs

working with buildrunner

154. By Nicholas Skaggs

name run-other-tests properly, run before tests

153. By Nicholas Skaggs

merge trunk

152. By Daniel Holbach

attempt for functional tests to use BuildRunner

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING'
2--- HACKING 2015-05-28 19:34:12 +0000
3+++ HACKING 2015-06-10 14:17:00 +0000
4@@ -171,7 +171,7 @@
5 sudo apt-get install oxideqt-chromedriver
6 sudo apt-add-repository ppa:canonical-platform-qa/selenium
7 sudo apt-get update
8- sudo apt-get install python3-selenium
9+ sudo apt-get install python3-selenium xvfb
10
11 Run the tests:
12
13
14=== modified file 'Makefile'
15--- Makefile 2015-05-13 14:54:51 +0000
16+++ Makefile 2015-06-10 14:17:00 +0000
17@@ -43,7 +43,7 @@
18 @echo ' '
19 @echo 'Usage: '
20 @echo ' make web (re)generate the (online) web site '
21- @echo ' make app (re)generate the (offline) content '
22+ @echo ' make app (re)generate the (offline) content '
23 @echo ' for the phone app ("html" is an '
24 @echo ' alias) '
25 @echo ' make click generate click for the phone app '
26@@ -56,8 +56,9 @@
27 @echo ' '
28
29 check:
30- cd $(INTERNALS_DIR); ./run-tests
31- cd $(INTERNALS_DIR); ./run-other-tests
32+ cd $(INTERNALS_DIR); ./run-code-tests
33+ cd $(INTERNALS_DIR); ./run-unit-tests
34+ cd $(INTERNALS_DIR); ./run-functional-tests
35
36 translations:
37 cd $(INTERNALS_DIR); ./generate-translations
38
39=== renamed file 'internals/run-other-tests' => 'internals/run-code-tests'
40=== added file 'internals/run-functional-tests'
41--- internals/run-functional-tests 1970-01-01 00:00:00 +0000
42+++ internals/run-functional-tests 2015-06-10 14:17:00 +0000
43@@ -0,0 +1,4 @@
44+#!/bin/sh -e
45+
46+cd tests/functional
47+autopilot3-sandbox-run help_app
48\ No newline at end of file
49
50=== renamed file 'internals/run-tests' => 'internals/run-unit-tests'
51--- internals/run-tests 2015-03-19 13:22:42 +0000
52+++ internals/run-unit-tests 2015-06-10 14:17:00 +0000
53@@ -4,9 +4,9 @@
54 import sys
55 import unittest
56
57-from pelicanconf import TOP_LEVEL_DIR
58+from pelicanconf import INTERNALS_DIR
59
60-test_directory = os.path.join(TOP_LEVEL_DIR, 'internals/tests')
61+test_directory = os.path.join(INTERNALS_DIR, 'tests/unit')
62 test_filename = 'test_*'
63 if len(sys.argv) > 1:
64 test_filename = sys.argv[1]
65
66=== added file 'internals/tests/__init__.py'
67=== added file 'internals/tests/build_utils.py'
68--- internals/tests/build_utils.py 1970-01-01 00:00:00 +0000
69+++ internals/tests/build_utils.py 2015-06-10 14:17:00 +0000
70@@ -0,0 +1,49 @@
71+import os
72+import shutil
73+import subprocess
74+import tempfile
75+
76+import sys
77+sys.path.insert(0, '../..')
78+
79+from pelicanconf import TOP_LEVEL_DIR
80+import pelicanconf
81+
82+
83+def clean_tempdir(tempdir):
84+ if os.path.exists(tempdir):
85+ shutil.rmtree(tempdir)
86+
87+
88+class BuildRunner():
89+ def __init__(self, build):
90+ self.tempdir = tempfile.mkdtemp()
91+ self.env = {}
92+ self.build = build
93+ self.html_files = []
94+ self.rc = None
95+ if self.build == 'app':
96+ self.env = {'APP_DIR': self.tempdir}
97+ if self.build == 'web':
98+ self.env = {'OUTPUTDIR_WEB': self.tempdir}
99+ self.pwd = os.getcwd()
100+ top_level_dir = os.path.join(os.path.dirname(pelicanconf.__file__),
101+ TOP_LEVEL_DIR)
102+ os.chdir(top_level_dir)
103+ self.run_build()
104+ self.find_html_files()
105+ self.html_path = os.path.commonprefix(self.html_files)
106+
107+ def run_build(self):
108+ self.rc = subprocess.call(['make', '-es', self.build], env=self.env)
109+ os.chdir(self.pwd)
110+
111+ def find_html_files(self):
112+ for dirpath, dirnames, filenames in os.walk(self.tempdir):
113+ self.html_files.extend([os.path.join(dirpath, fn)
114+ for fn in filenames
115+ if fn.endswith('.html')])
116+
117+ def __del__(self):
118+ os.chdir(self.pwd)
119+ clean_tempdir(self.tempdir)
120
121=== added file 'internals/tests/functional/__init__.py'
122=== modified file 'internals/tests/functional/help_app/tests/__init__.py'
123--- internals/tests/functional/help_app/tests/__init__.py 2015-05-28 20:32:09 +0000
124+++ internals/tests/functional/help_app/tests/__init__.py 2015-06-10 14:17:00 +0000
125@@ -1,7 +1,6 @@
126 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
127
128 """ Autopilot tests """
129-
130 import os
131 import subprocess
132
133@@ -16,6 +15,11 @@
134 from autopilot import platform
135 from autopilot.testcase import AutopilotTestCase
136
137+import sys
138+sys.path.insert(0, '..')
139+
140+from build_utils import BuildRunner
141+
142 CURRENT_ARCHITECTURE = subprocess.check_output(
143 ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
144 CHROMEDRIVER_EXEC_PATH = \
145@@ -69,7 +73,8 @@
146
147 def setUp(self):
148 super(HelpAppTest, self).setUp()
149- self.app = HelpApp(self.launch_app('../../../../../build/app/www'))
150+ self.build_runner = BuildRunner('web')
151+ self.app = HelpApp(self.launch_app(self.build_runner.html_path))
152 self.driver = self.launch_webdriver()
153
154
155@@ -79,5 +84,6 @@
156
157 def setUp(self):
158 super(HelpWebTest, self).setUp()
159- self.app = HelpApp(self.launch_app('../../../../../build/web/www'))
160+ self.build_runner = BuildRunner('app')
161+ self.app = HelpApp(self.launch_app(self.build_runner.html_path))
162 self.driver = self.launch_webdriver()
163
164=== renamed file 'internals/tests/functional/help_app/tests/test_app_launch.py' => 'internals/tests/functional/help_app/tests/test_app.py'
165--- internals/tests/functional/help_app/tests/test_app_launch.py 2015-05-28 20:32:09 +0000
166+++ internals/tests/functional/help_app/tests/test_app.py 2015-06-10 14:17:00 +0000
167@@ -1,16 +1,13 @@
168 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
169
170-from help_app.tests import HelpAppTest, HelpWebTest
171+from help_app.tests import HelpAppTest
172 from testtools.matchers import NotEquals
173
174
175-class LaunchTestApp(HelpAppTest):
176-
177- def test_basic_launch(self):
178- self.assertThat(self.app, NotEquals(None))
179-
180-
181-class LaunchTestWeb(HelpWebTest):
182+class TestApp(HelpAppTest):
183+ def setUp(self):
184+ super(TestApp, self).setUp()
185+ self.assertEquals(self.app.build_runner.rc, 0)
186
187 def test_basic_launch(self):
188 self.assertThat(self.app, NotEquals(None))
189
190=== added file 'internals/tests/functional/help_app/tests/test_web.py'
191--- internals/tests/functional/help_app/tests/test_web.py 1970-01-01 00:00:00 +0000
192+++ internals/tests/functional/help_app/tests/test_web.py 2015-06-10 14:17:00 +0000
193@@ -0,0 +1,13 @@
194+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
195+
196+from help_app.tests import HelpWebTest
197+from testtools.matchers import NotEquals
198+
199+
200+class TestWeb(HelpWebTest):
201+ def setUp(self):
202+ super(TestWeb, self).setUp()
203+ self.assertEquals(self.app.build_runner.rc, 0)
204+
205+ def test_basic_launch(self):
206+ self.assertThat(self.app, NotEquals(None))
207
208=== added directory 'internals/tests/unit'
209=== renamed file 'internals/tests/test_files.py' => 'internals/tests/unit/test_files.py'
210=== renamed file 'internals/tests/test_links.py' => 'internals/tests/unit/test_links.py'
211--- internals/tests/test_links.py 2015-05-13 12:32:34 +0000
212+++ internals/tests/unit/test_links.py 2015-06-10 14:17:00 +0000
213@@ -1,51 +1,21 @@
214 import codecs
215 from html.parser import HTMLParser
216 import os
217-import shutil
218-import subprocess
219 import tempfile
220 from unittest import TestCase
221
222 from translations.utils import (
223 link_is_anchor,
224 link_is_local,
225- use_top_level_dir,
226-)
227-
228-
229-def clean_tempdir(tempdir):
230- if os.path.exists(tempdir):
231- shutil.rmtree(tempdir)
232-
233-
234-class BuildRunner():
235- def __init__(self, build):
236- self.tempdir = tempfile.mkdtemp()
237- self.env = {}
238- self.build = build
239- self.html_files = []
240- self.rc = None
241- if self.build == 'app':
242- self.env = {'APP_DIR': self.tempdir}
243- if self.build == 'web':
244- self.env = {'OUTPUTDIR_WEB': self.tempdir}
245- self.pwd = use_top_level_dir()
246- self.run_build()
247- self.find_html_files()
248-
249- def run_build(self):
250- self.rc = subprocess.call(['make', '-es', self.build], env=self.env)
251- os.chdir(self.pwd)
252-
253- def find_html_files(self):
254- for dirpath, dirnames, filenames in os.walk(self.tempdir):
255- self.html_files.extend([os.path.join(dirpath, fn)
256- for fn in filenames
257- if fn.endswith('.html')])
258-
259- def __del__(self):
260- os.chdir(self.pwd)
261- clean_tempdir(self.tempdir)
262+)
263+
264+import sys
265+sys.path.insert(0, '..')
266+
267+from build_utils import (
268+ BuildRunner,
269+ clean_tempdir,
270+)
271
272
273 class MyHTMLParser(HTMLParser):
274
275=== renamed file 'internals/tests/test_markdown.py' => 'internals/tests/unit/test_markdown.py'
276=== renamed file 'internals/tests/test_translations.py' => 'internals/tests/unit/test_translations.py'

Subscribers

People subscribed via source and target branches