Permalink
Browse files

Remove append() for now. Will rewrite.

  • Loading branch information...
1 parent 6a72955 commit 653d01615a1ec755c747a91c142ec2b1e7344feb Toru Maesaka committed May 4, 2011
Showing with 8 additions and 43 deletions.
  1. +2 −20 kyototycoon/kt_http.py
  2. +0 −17 tests/t_simple.py
  3. +2 −2 tests/t_tsv.py
  4. +4 −4 tests/t_utils.py
View
@@ -137,23 +137,6 @@ def replace(self, key, value, expire):
body = rv.read()
return rv.status == 201
- def append(self, key, value, expire):
- if key is None: return False
-
- if not isinstance(value, str):
- value = str(value)
-
- key = urllib.quote(key.encode('UTF-8'))
- value = urllib.quote(value)
-
- request_body = 'key\t%s\nvalue\t%s\n' % (key, value)
- self.conn.request('POST', '/rpc/append', body=request_body,
- headers=KT_HTTP_HEADER)
-
- rv = self.conn.getresponse()
- body = rv.read()
- return rv.status == 200
-
def increment(self, key, delta, expire):
if key is None: return False
@@ -224,9 +207,8 @@ def _rest_put(self, key, value, expire):
body = rv.read()
return rv.status
- # TODO (tmaesaka): Allow using callbacks for these.
- def _pack_data(self, data):
+ def _pickle_packer(self, data):
return pickle.dumps(data, self.pickle_protocol)
- def _unpack_data(self, data):
+ def _pickle_unpacker(self, data):
return pickle.loads(data)
View
@@ -76,23 +76,6 @@ def test_replace(self):
self.assertTrue(self.kt_handle.replace('apple', 121))
self.assertEqual(self.kt_handle.get('apple'), '121')
- def test_append(self):
- self.assertTrue(self.kt_handle.clear())
-
- # Nothing to Append to. So, create a new record.
- self.assertTrue(self.kt_handle.append('key', 'tail'))
- self.assertEqual(self.kt_handle.get('key'), 'tail')
-
- # Test append on existing record.
- self.assertTrue(self.kt_handle.set('key', 'abc'))
- self.assertTrue(self.kt_handle.append('key', 'def'))
- self.assertTrue(self.kt_handle.append('key', 'ghi'))
- self.assertEqual(self.kt_handle.get('key'), 'abcdefghi')
- self.assertFalse(self.kt_handle.append(None, 'value'))
-
- self.assertTrue(self.kt_handle.append('key', 123))
- self.assertEqual(self.kt_handle.get('key'), 'abcdefghi123')
-
def test_add(self):
self.assertTrue(self.kt_handle.clear())
self.assertTrue(self.kt_handle.set('stewie', 'griffin'))
View
@@ -19,8 +19,8 @@ def test_tsv_rpc(self):
value = 'tabs\tin\tvalue'
self.assertTrue(self.kt_handle.clear())
- self.assertTrue(self.kt_handle.append(key, value))
- self.assertEqual(self.kt_handle.get(key), value)
+ self.assertEqual(self.kt_handle.increment(key, 1024), 1024)
+
if __name__ == '__main__':
unittest.main()
View
@@ -15,15 +15,15 @@ def setUp(self):
def test_packer(self):
str = 'hello world sir'
- buf = self.kt_core._pack_data(str)
+ buf = self.kt_core._pickle_packer(str)
assert buf != str
- ret = self.kt_core._unpack_data(buf)
+ ret = self.kt_core._pickle_unpacker(buf)
self.assertEqual(str, ret)
num = 777
- buf = self.kt_core._pack_data(num)
+ buf = self.kt_core._pickle_packer(num)
assert buf != num
- ret = self.kt_core._unpack_data(buf)
+ ret = self.kt_core._pickle_unpacker(buf)
self.assertEqual(type(num), type(ret))
self.assertEqual(num, ret)

0 comments on commit 653d016

Please sign in to comment.