Merge lp:~terrycojones/txfluiddb/fix-tag-value-get-error into lp:txfluiddb

Proposed by Terry Jones
Status: Merged
Approved by: Tristan Seligmann
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~terrycojones/txfluiddb/fix-tag-value-get-error
Merge into: lp:txfluiddb
Diff against target: 106 lines (+49/-4)
3 files modified
txfluiddb/client.py (+1/-1)
txfluiddb/http.py (+2/-0)
txfluiddb/test/test_client.py (+46/-3)
To merge this branch: bzr merge lp:~terrycojones/txfluiddb/fix-tag-value-get-error
Reviewer Review Type Date Requested Status
Tristan Seligmann Approve
Review via email: mp+18212@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tristan Seligmann (mithrandi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txfluiddb/client.py'
2--- txfluiddb/client.py 2010-01-17 19:11:05 +0000
3+++ txfluiddb/client.py 2010-01-28 16:32:19 +0000
4@@ -543,7 +543,7 @@
5 def getTagValue(self, url):
6 def _parse((status, headers, page)):
7 # Let this raise a KeyError if there's no content-type header?
8- ct = headers['content-type']
9+ ct = headers['content-type'][0]
10 if ct == PRIMITIVE_CONTENT_TYPE:
11 return json.loads(page)
12 else:
13
14=== modified file 'txfluiddb/http.py'
15--- txfluiddb/http.py 2010-01-17 19:11:05 +0000
16+++ txfluiddb/http.py 2010-01-28 16:32:19 +0000
17@@ -27,12 +27,14 @@
18
19 class HTTPClientFactory(client.HTTPClientFactory):
20 protocol = HTTPPageGetter
21+
22
23 def page(self, page):
24 if self.waiting:
25 self.waiting = 0
26 self.deferred.callback((self.status, self.response_headers, page))
27
28+
29 def noPage(self, reason):
30 if self.waiting:
31 self.waiting = 0
32
33=== modified file 'txfluiddb/test/test_client.py'
34--- txfluiddb/test/test_client.py 2010-01-17 19:11:05 +0000
35+++ txfluiddb/test/test_client.py 2010-01-28 16:32:19 +0000
36@@ -474,9 +474,11 @@
37 return d
38
39
40-class TagValueTests(TestCase):
41+class TagValuesTests(TestCase):
42 """
43- Tests for L{TagValues}.
44+ Tests for L{TagValues}. Note that these are tests on the permissions
45+ associated with a set of tag values. For tests on individual tag values
46+ on objects, see the ObjectTests class.
47 """
48 def setUp(self):
49 self.endpoint = MockEndpoint('http://fluiddb.url/')
50@@ -656,7 +658,7 @@
51 """
52 value, contentType = response
53 self.endpoint.response = value
54- self.endpoint.responseHeaders = { 'content-type' : contentType, }
55+ self.endpoint.responseHeaders = { 'content-type' : [ contentType ], }
56 obj = Object(u'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
57 tag = Namespace(u'test').child(u'tag')
58 d = obj.get(self.endpoint, tag)
59@@ -690,6 +692,47 @@
60 return self.makeGetRequest(response).addCallback(_gotResponse)
61
62
63+ def test_getNone(self):
64+ """
65+ Retrieving a None value results in None.
66+ """
67+ response = (json.dumps(None), 'application/vnd.fluiddb.value+json')
68+ def _gotResponse(response):
69+ self.assertEqual(response, None)
70+ return self.makeGetRequest(response).addCallback(_gotResponse)
71+
72+
73+ def test_getTrue(self):
74+ """
75+ Retrieving a True value results in True.
76+ """
77+ response = (json.dumps(True), 'application/vnd.fluiddb.value+json')
78+ def _gotResponse(response):
79+ self.assertEqual(response, True)
80+ return self.makeGetRequest(response).addCallback(_gotResponse)
81+
82+
83+ def test_getFalse(self):
84+ """
85+ Retrieving a False value results in False.
86+ """
87+ response = (json.dumps(False), 'application/vnd.fluiddb.value+json')
88+ def _gotResponse(response):
89+ self.assertEqual(response, False)
90+ return self.makeGetRequest(response).addCallback(_gotResponse)
91+
92+
93+ def test_getStringSet(self):
94+ """
95+ Retrieving a set of strings results in the set of strings.
96+ """
97+ s = ['this', 'is', 'a', 'set', 'of', 'strings']
98+ response = (json.dumps(s), 'application/vnd.fluiddb.value+json')
99+ def _gotResponse(response):
100+ self.assertEqual(sorted(response), sorted(s))
101+ return self.makeGetRequest(response).addCallback(_gotResponse)
102+
103+
104 def test_getBlob(self):
105 """
106 Retrieving a binary value results in a C{Blob} object.

Subscribers

People subscribed via source and target branches

to all changes: