Merge lp:~elopio/osqa-sst-helpers/temp-soup-integration into lp:~online-services-qa/osqa-sst-helpers/canonical-identity-provider

Proposed by Leo Arias
Status: Needs review
Proposed branch: lp:~elopio/osqa-sst-helpers/temp-soup-integration
Merge into: lp:~online-services-qa/osqa-sst-helpers/canonical-identity-provider
Prerequisite: lp:~elopio/osqa-sst-helpers/temp-soup-unit-tests
Diff against target: 109 lines (+25/-32)
3 files modified
sso_sst_helpers/selftests/integration/test_sst_api.html (+0/-8)
sso_sst_helpers/selftests/integration/test_sst_api.py (+21/-3)
sso_sst_helpers/selftests/unit/test_log_in.py (+4/-21)
To merge this branch: bzr merge lp:~elopio/osqa-sst-helpers/temp-soup-integration
Reviewer Review Type Date Requested Status
Vincent Ladeuil (community) Approve
Review via email: mp+132570@code.launchpad.net

Commit message

Use temp files for the integration tests.

Description of the change

Use temp files for the integration tests.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

49 + def go_to(self, string_html):
50 + page = tempfile.NamedTemporaryFile(delete=False)
51 + page.write(string_html)
52 + page.close()
53 + sst.actions.go_to('file://' + page.name)
54 + os.remove(page.name)

could be written:
50 + page = tempfile.NamedTemporaryFile(delete=False)
self.addCleanup(os.remove, page.name)

so that the remove will be done even if the test fails.

review: Approve

Unmerged revisions

41. By Leo Arias

Use TestSSTAPI as a base class.

40. By Leo Arias

Use temp files for the integration tests.

39. By Leo Arias

Merged with trunk.

38. By Leo Arias

Use temp files and beautiful soup for the unit tests.
Updated the name of u1testutils.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'sso_sst_helpers/selftests/integration/__init__.py'
2=== removed file 'sso_sst_helpers/selftests/integration/test_sst_api.html'
3--- sso_sst_helpers/selftests/integration/test_sst_api.html 2012-10-25 06:17:38 +0000
4+++ sso_sst_helpers/selftests/integration/test_sst_api.html 1970-01-01 00:00:00 +0000
5@@ -1,8 +0,0 @@
6-<html>
7-<head>
8- <title>Test SST API</title>
9-</head>
10-<body>
11- <h1>Test h1</h1>
12-</body>
13-</html>
14
15=== modified file 'sso_sst_helpers/selftests/integration/test_sst_api.py'
16--- sso_sst_helpers/selftests/integration/test_sst_api.py 2012-10-25 08:03:22 +0000
17+++ sso_sst_helpers/selftests/integration/test_sst_api.py 2012-11-01 15:19:36 +0000
18@@ -15,6 +15,7 @@
19 # with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 import os
22+import tempfile
23 import unittest
24
25 import sst.actions
26@@ -22,17 +23,34 @@
27
28 class TestSSTAPI(unittest.TestCase):
29
30+ TEST_PAGE_HTML = (
31+ """
32+ <html>
33+ <body>
34+ <h1>Test h1</h1>
35+ </body>
36+ </html>
37+ """
38+ )
39+
40 def setUp(self):
41 super(TestSSTAPI, self).setUp()
42- # TODO start in the virtual framebuffer.
43+ # TODO use the virtualframebuffer.
44 sst.actions.start()
45- current_path = os.path.dirname(os.path.abspath(__file__))
46- sst.actions.go_to('file:///{0}/test_sst_api.html'.format(current_path))
47 self.addCleanup(sst.actions.stop)
48
49+ def go_to(self, string_html):
50+ page = tempfile.NamedTemporaryFile(delete=False)
51+ page.write(string_html)
52+ page.close()
53+ sst.actions.go_to('file://' + page.name)
54+ os.remove(page.name)
55+
56 def test_assert_element_succeeds(self):
57+ self.go_to(self.TEST_PAGE_HTML)
58 sst.actions.assert_element(tag='h1', text='Test h1')
59
60 def test_assert_element_fails(self):
61+ self.go_to(self.TEST_PAGE_HTML)
62 with self.assertRaises(AssertionError):
63 sst.actions.assert_element(tag='h1', text='Test wrong h1')
64
65=== modified file 'sso_sst_helpers/selftests/unit/test_log_in.py'
66--- sso_sst_helpers/selftests/unit/test_log_in.py 2012-11-01 15:19:36 +0000
67+++ sso_sst_helpers/selftests/unit/test_log_in.py 2012-11-01 15:19:36 +0000
68@@ -14,17 +14,13 @@
69 # You should have received a copy of the GNU General Public License along
70 # with this program. If not, see <http://www.gnu.org/licenses/>.
71
72-import os
73-import tempfile
74-import unittest
75-
76 import bs4
77-import sst.actions
78
79 from sso_sst_helpers.actions import log_in
80-
81-
82-class TestLogInActions(unittest.TestCase):
83+from sso_sst_helpers.selftests.integration import test_sst_api
84+
85+
86+class TestLogInActions(test_sst_api.TestSSTAPI):
87
88 LOG_IN_PAGE_HTML = (
89 """
90@@ -37,19 +33,6 @@
91 """
92 )
93
94- def setUp(self):
95- super(TestLogInActions, self).setUp()
96- # TODO use HTMLUnit or the virtualframebuffer.
97- sst.actions.start()
98- self.addCleanup(sst.actions.stop)
99-
100- def go_to(self, string_html):
101- page = tempfile.NamedTemporaryFile(delete=False)
102- page.write(string_html)
103- page.close()
104- sst.actions.go_to('file://' + page.name)
105- os.remove(page.name)
106-
107 def test_assert_page(self):
108 self.go_to(self.LOG_IN_PAGE_HTML)
109 # Assertion should not fail.

Subscribers

People subscribed via source and target branches

to all changes: