Skip to content

Commit

Permalink
Fixes for running the tests under Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jboone100 committed Feb 10, 2016
1 parent 51ddf5d commit ad1f302
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
File renamed without changes.
17 changes: 9 additions & 8 deletions test/new_tests/test_get_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import cPickle as pickle
except:
import pickle
from collections import OrderedDict
from .test_base_class import TestBaseClass

# from collections import OrderedDict
from .test_base_class import TestBaseClass
aerospike = pytest.importorskip("aerospike")
try:
import aerospike
Expand All @@ -17,6 +17,7 @@
print("Please install aerospike python client.")
sys.exit(1)


class SomeClass(object):
pass

Expand Down Expand Up @@ -48,9 +49,9 @@ class TestGetPut():
(('test', 'demo', 'map_key'), {'names': {'name': 'John', 'age': 24}}),
(('test', 'demo', 'map_key_float'), {"double_map": {"1": 3.141,"2": 4.123,"3": 6.285}}),
(('test', 'demo', 'map_key_unicode'), {'a': {u'aa': u'11'}, 'b': {u'bb': u'22'}}),
(('test', 'demo', 1),
{'odict': OrderedDict(sorted({'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2}.items(),
key=lambda t: t[0]))}),
# (('test', 'demo', 1),
# {'odict': OrderedDict(sorted({'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2}.items(),
# key=lambda t: t[0]))}),
# Tuple Data
(('test', 'demo', 'tuple_key'), {'tuple_seq': tuple('abc')}),
Expand Down Expand Up @@ -780,13 +781,13 @@ def test_neg_put_with_string_record_without_connection(self):
assert exception.code == 11

@pytest.mark.parametrize("key, record, meta, policy, ex_code, ex_msg", [
(('test', 'demo', 1), {'name': 'john'},
(('test', 'demo', 1), {'name': 'john'},
{'gen': "wrong", 'ttl': 25000}, {'timeout': 1000}, #Gen as string
-2, "Generation should be an int or long"),
(('test', 'demo', 1), {'name': 'john'},
(('test', 'demo', 1), {'name': 'john'},
{'gen': 3, 'ttl': "25000"}, {'timeout': 1000}, # ttl as string
-2, "TTL should be an int or long"),
(('test', 'demo', 1), {'name': 'john'},
(('test', 'demo', 1), {'name': 'john'},
{'gen': 3, 'ttl': 25000}, {'timeout': "1000"}, # Timeout as string
-2, "timeout is invalid"),
(('test', 'demo', 1), {'name': 'john'}, #Policy as string
Expand Down
8 changes: 4 additions & 4 deletions test/new_tests/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ def test_neg_remove_with_policy_gen_GT_lesser(self, put_data):
'timeout': 1000,
'retry': aerospike.POLICY_RETRY_ONCE,
'key': aerospike.POLICY_KEY_SEND,
'gen': aerospike.POLICY_GEN_GT
'gen': aerospike.POLICY_GEN_GT
}

(key, meta) = self.as_connection.exists(key) # Record had GEN = x
lesserGen = meta['gen'] -1 #Compute GEN = x - 1
(key, meta) = self.as_connection.exists(key)
lesserGen = meta['gen'] - 1

with pytest.raises(e.RecordGenerationError) as exception:
self.as_connection.remove(key, {"gen", lesserGen}, policy)
self.as_connection.remove(key, ("gen", lesserGen), policy)
(code, msg, _, _) = exception.value
assert msg == "AEROSPIKE_ERR_RECORD_GENERATION"
assert code == 3
Expand Down
3 changes: 1 addition & 2 deletions test/new_tests/test_remove_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ def test_pos_remove_bin_no_bin(self, put_data):
key = ('test', 'demo', 1)
record = {'name': "jeff", 'age': 45}
put_data(self.as_connection, key, record)
self.as_connection.remove_bin(key, [])

try:
self.as_connection.remove_bin(key, [])
(key, _, bins) = self.as_connection.get(key)
assert bins == record
except e.InvalidRequest:
Expand Down

0 comments on commit ad1f302

Please sign in to comment.