Merge lp:~rvb/maas/update-sst into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 509
Proposed branch: lp:~rvb/maas/update-sst
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 99 lines (+7/-31)
2 files modified
src/maasserver/tests/test_js.py (+6/-30)
versions.cfg (+1/-1)
To merge this branch: bzr merge lp:~rvb/maas/update-sst
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+103130@code.launchpad.net

Commit message

bump sst version to 0.2.1.

Description of the change

This branch bumps the version of sst to 0.2.1. This version fixes bug 943155 which means that SST now supports the usage of "file:///". This branch cleans the code that created an http server to serve test html file (that was used to circumvent bug 943155. This way, no fixed port is used and this will allow for two js test to run concurrently.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

\o/

[1]

+ project_home = os.path.dirname(
+ os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

There's a slightly more succinct way of doing this:

        from os.path import join, pardir, dirname
        project_home = join(pardir, pardir, pardir, dirname(__file__))

Also, I tend to import from os.path, or path from os, though that's no
reason you should too. I'm too lazy to type or read os.path.thing all
the time :)

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> \o/
>
>
> [1]
>
> + project_home = os.path.dirname(
> + os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
>
> There's a slightly more succinct way of doing this:
>
> from os.path import join, pardir, dirname
> project_home = join(pardir, pardir, pardir, dirname(__file__))
>
> Also, I tend to import from os.path, or path from os, though that's no
> reason you should too. I'm too lazy to type or read os.path.thing all
> the time :)

Thanks for the review.

I like "dirname(dirname(dirname(dirname(__file__))))" better but I've moved project_home as a module level variable.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/tests/test_js.py'
2--- src/maasserver/tests/test_js.py 2012-04-16 10:00:51 +0000
3+++ src/maasserver/tests/test_js.py 2012-04-24 08:07:22 +0000
4@@ -18,9 +18,9 @@
5 import json
6 import logging
7 import os
8+from os.path import dirname
9 import SimpleHTTPServer
10 import SocketServer
11-import threading
12
13 from fixtures import Fixture
14 from pyvirtualdisplay import Display
15@@ -28,7 +28,6 @@
16 assert_text,
17 get_element,
18 go_to,
19- set_base_url,
20 start,
21 stop,
22 wait_for,
23@@ -89,31 +88,6 @@
24 log_error = lambda *args, **kwargs: None
25
26
27-class StaticServerFixture(Fixture):
28- """Setup an HTTP server that will serve static files.
29-
30- This is only required because SST forces us to request urls that start
31- with 'http://' (and thus does not allow us to use urls starting with
32- 'file:///').
33- """
34-
35- # Port used by the temporary http server used for testing.
36- TESTING_HTTP_PORT = 18463
37-
38- port = TESTING_HTTP_PORT
39-
40- def __init__(self):
41- self.server = ThreadingHTTPServer(
42- ('localhost', self.port), SilentHTTPRequestHandler)
43- self.server.daemon = True
44- self.server_thread = threading.Thread(target=self.server.serve_forever)
45-
46- def setUp(self):
47- super(StaticServerFixture, self).setUp()
48- self.server_thread.start()
49- self.addCleanup(self.server.shutdown)
50-
51-
52 class SSTFixture(Fixture):
53 """Setup a javascript-enabled testing browser instance with SST."""
54
55@@ -135,12 +109,14 @@
56 self.addCleanup(stop)
57
58
59+project_home = dirname(dirname(dirname(dirname(__file__))))
60+
61+
62 class TestYUIUnitTests(TestCase):
63
64 def setUp(self):
65 super(TestYUIUnitTests, self).setUp()
66 self.useFixture(DisplayFixture())
67- self.port = self.useFixture(StaticServerFixture()).port
68 self.useFixture(SSTFixture())
69
70 def _get_failed_tests_message(self, results):
71@@ -163,13 +139,13 @@
72 return ''.join(result)
73
74 def test_YUI3_unit_tests(self):
75- set_base_url('http://localhost:%d' % self.port)
76 # Find all the HTML files in BASE_PATH.
77 for fname in os.listdir(BASE_PATH):
78 if fname.endswith('.html'):
79 # Load the page and then wait for #suite to contain
80 # 'done'. Read the results in '#test_results'.
81- go_to("%s%s" % (BASE_PATH, fname))
82+ file_path = os.path.join(project_home, BASE_PATH, fname)
83+ go_to('file://%s' % file_path)
84 wait_for(assert_text, 'suite', 'done')
85 results = json.loads(get_element(id='test_results').text)
86 if results['failed'] != 0:
87
88=== modified file 'versions.cfg'
89--- versions.cfg 2012-04-18 15:14:17 +0000
90+++ versions.cfg 2012-04-24 08:07:22 +0000
91@@ -76,7 +76,7 @@
92
93 # Added by Buildout Versions at 2012-02-24 16:56:06.100791
94 PyVirtualDisplay = 0.0.9
95-sst = 0.1.0
96+sst = 0.2.1
97
98 # Required by:
99 # PyVirtualDisplay==0.0.9