Merge lp:~salgado/lazr.restful/bug-507447 into lp:lazr.restful

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/lazr.restful/bug-507447
Merge into: lp:lazr.restful
Diff against target: 71 lines (+32/-2)
4 files modified
HACKING.txt (+1/-1)
src/lazr/restful/tests/test_utils.py (+29/-0)
src/lazr/restful/tests/test_webservice.py (+0/-1)
src/lazr/restful/utils.py (+2/-0)
To merge this branch: bzr merge lp:~salgado/lazr.restful/bug-507447
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+17395@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

Fix get_current_browser_request to not raise an AttributeError when
there's no interaction setup

Revision history for this message
Henning Eggers (henninge) wrote :

Thank you for this fix. Only suggestion I'd have is to split up the test into two methods.

test_get_current_browser_request_no_interaction
test_get_current_browser_request

Cheers,
Henning

review: Approve (code)
Revision history for this message
Guilherme Salgado (salgado) wrote :

On Fri, 2010-01-15 at 11:12 +0000, Henning Eggers wrote:
> Review: Approve code
> Thank you for this fix. Only suggestion I'd have is to split up the test into two methods.
>
> test_get_current_browser_request_no_interaction
> test_get_current_browser_request
>

Yeah, that'd be a nice and trivial change, so, done.

Thanks!

lp:~salgado/lazr.restful/bug-507447 updated
98. By Guilherme Salgado

Split the new test into two

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'HACKING.txt'
--- HACKING.txt 2009-03-25 17:56:54 +0000
+++ HACKING.txt 2010-01-15 14:15:22 +0000
@@ -22,7 +22,7 @@
22These are guidelines for hacking on the lazr.restful project. But first,22These are guidelines for hacking on the lazr.restful project. But first,
23please see the common hacking guidelines at:23please see the common hacking guidelines at:
2424
25 http://dev.launchpad.net/Hacking25 https://dev.launchpad.net/HackingLazrLibraries
2626
2727
28Getting help28Getting help
2929
=== added file 'src/lazr/restful/tests/test_utils.py'
--- src/lazr/restful/tests/test_utils.py 1970-01-01 00:00:00 +0000
+++ src/lazr/restful/tests/test_utils.py 2010-01-15 14:15:22 +0000
@@ -0,0 +1,29 @@
1# Copyright 2010 Canonical Ltd. All rights reserved.
2
3"""Test for lazr.restful.utils."""
4
5__metaclass__ = type
6
7import unittest
8
9from zope.publisher.browser import TestRequest
10from zope.security.management import (
11 endInteraction, newInteraction, queryInteraction)
12
13from lazr.restful.utils import get_current_browser_request
14
15
16class TestUtils(unittest.TestCase):
17
18 def test_get_current_browser_request_no_interaction(self):
19 # When there's no interaction setup, get_current_browser_request()
20 # returns None.
21 self.assertEquals(None, queryInteraction())
22 self.assertEquals(None, get_current_browser_request())
23
24 def test_get_current_browser_request(self):
25 # When there is an interaction, it returns the interaction's request.
26 request = TestRequest()
27 newInteraction(request)
28 self.assertEquals(request, get_current_browser_request())
29 endInteraction()
030
=== modified file 'src/lazr/restful/tests/test_webservice.py'
--- src/lazr/restful/tests/test_webservice.py 2010-01-11 18:27:43 +0000
+++ src/lazr/restful/tests/test_webservice.py 2010-01-15 14:15:22 +0000
@@ -28,7 +28,6 @@
28from lazr.restful.testing.webservice import (28from lazr.restful.testing.webservice import (
29 create_web_service_request, WebServiceTestPublication)29 create_web_service_request, WebServiceTestPublication)
30from lazr.restful.testing.tales import test_tales30from lazr.restful.testing.tales import test_tales
31from lazr.restful.utils import get_current_browser_request
3231
3332
34def get_resource_factory(model_interface, resource_interface):33def get_resource_factory(model_interface, resource_interface):
3534
=== modified file 'src/lazr/restful/utils.py'
--- src/lazr/restful/utils.py 2010-01-14 10:00:38 +0000
+++ src/lazr/restful/utils.py 2010-01-15 14:15:22 +0000
@@ -223,6 +223,8 @@
223 from zope.security.management import queryInteraction223 from zope.security.management import queryInteraction
224 from zope.publisher.interfaces.http import IHTTPApplicationRequest224 from zope.publisher.interfaces.http import IHTTPApplicationRequest
225 interaction = queryInteraction()225 interaction = queryInteraction()
226 if interaction is None:
227 return None
226 requests = [228 requests = [
227 participation229 participation
228 for participation in interaction.participations230 for participation in interaction.participations

Subscribers

People subscribed via source and target branches