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
=== modified file 'txfluiddb/client.py'
--- txfluiddb/client.py 2010-01-17 19:11:05 +0000
+++ txfluiddb/client.py 2010-01-28 16:32:19 +0000
@@ -543,7 +543,7 @@
543 def getTagValue(self, url):543 def getTagValue(self, url):
544 def _parse((status, headers, page)):544 def _parse((status, headers, page)):
545 # Let this raise a KeyError if there's no content-type header?545 # Let this raise a KeyError if there's no content-type header?
546 ct = headers['content-type']546 ct = headers['content-type'][0]
547 if ct == PRIMITIVE_CONTENT_TYPE:547 if ct == PRIMITIVE_CONTENT_TYPE:
548 return json.loads(page)548 return json.loads(page)
549 else:549 else:
550550
=== modified file 'txfluiddb/http.py'
--- txfluiddb/http.py 2010-01-17 19:11:05 +0000
+++ txfluiddb/http.py 2010-01-28 16:32:19 +0000
@@ -27,12 +27,14 @@
2727
28class HTTPClientFactory(client.HTTPClientFactory):28class HTTPClientFactory(client.HTTPClientFactory):
29 protocol = HTTPPageGetter29 protocol = HTTPPageGetter
30
30 31
31 def page(self, page):32 def page(self, page):
32 if self.waiting:33 if self.waiting:
33 self.waiting = 034 self.waiting = 0
34 self.deferred.callback((self.status, self.response_headers, page))35 self.deferred.callback((self.status, self.response_headers, page))
3536
37
36 def noPage(self, reason):38 def noPage(self, reason):
37 if self.waiting:39 if self.waiting:
38 self.waiting = 040 self.waiting = 0
3941
=== modified file 'txfluiddb/test/test_client.py'
--- txfluiddb/test/test_client.py 2010-01-17 19:11:05 +0000
+++ txfluiddb/test/test_client.py 2010-01-28 16:32:19 +0000
@@ -474,9 +474,11 @@
474 return d474 return d
475475
476476
477class TagValueTests(TestCase):477class TagValuesTests(TestCase):
478 """478 """
479 Tests for L{TagValues}.479 Tests for L{TagValues}. Note that these are tests on the permissions
480 associated with a set of tag values. For tests on individual tag values
481 on objects, see the ObjectTests class.
480 """482 """
481 def setUp(self):483 def setUp(self):
482 self.endpoint = MockEndpoint('http://fluiddb.url/')484 self.endpoint = MockEndpoint('http://fluiddb.url/')
@@ -656,7 +658,7 @@
656 """658 """
657 value, contentType = response659 value, contentType = response
658 self.endpoint.response = value660 self.endpoint.response = value
659 self.endpoint.responseHeaders = { 'content-type' : contentType, }661 self.endpoint.responseHeaders = { 'content-type' : [ contentType ], }
660 obj = Object(u'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')662 obj = Object(u'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
661 tag = Namespace(u'test').child(u'tag')663 tag = Namespace(u'test').child(u'tag')
662 d = obj.get(self.endpoint, tag)664 d = obj.get(self.endpoint, tag)
@@ -690,6 +692,47 @@
690 return self.makeGetRequest(response).addCallback(_gotResponse)692 return self.makeGetRequest(response).addCallback(_gotResponse)
691693
692694
695 def test_getNone(self):
696 """
697 Retrieving a None value results in None.
698 """
699 response = (json.dumps(None), 'application/vnd.fluiddb.value+json')
700 def _gotResponse(response):
701 self.assertEqual(response, None)
702 return self.makeGetRequest(response).addCallback(_gotResponse)
703
704
705 def test_getTrue(self):
706 """
707 Retrieving a True value results in True.
708 """
709 response = (json.dumps(True), 'application/vnd.fluiddb.value+json')
710 def _gotResponse(response):
711 self.assertEqual(response, True)
712 return self.makeGetRequest(response).addCallback(_gotResponse)
713
714
715 def test_getFalse(self):
716 """
717 Retrieving a False value results in False.
718 """
719 response = (json.dumps(False), 'application/vnd.fluiddb.value+json')
720 def _gotResponse(response):
721 self.assertEqual(response, False)
722 return self.makeGetRequest(response).addCallback(_gotResponse)
723
724
725 def test_getStringSet(self):
726 """
727 Retrieving a set of strings results in the set of strings.
728 """
729 s = ['this', 'is', 'a', 'set', 'of', 'strings']
730 response = (json.dumps(s), 'application/vnd.fluiddb.value+json')
731 def _gotResponse(response):
732 self.assertEqual(sorted(response), sorted(s))
733 return self.makeGetRequest(response).addCallback(_gotResponse)
734
735
693 def test_getBlob(self):736 def test_getBlob(self):
694 """737 """
695 Retrieving a binary value results in a C{Blob} object.738 Retrieving a binary value results in a C{Blob} object.

Subscribers

People subscribed via source and target branches

to all changes: