-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLIENT-2077] Add support for reading key ordered maps (#512)
- Loading branch information
1 parent
376085b
commit 52b0963
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from aerospike import KeyOrderedDict | ||
import pytest | ||
from aerospike import exception as e | ||
|
||
|
||
class TestGetPutOrderedDict: | ||
@pytest.fixture(autouse=True) | ||
def setup(self, request, as_connection): | ||
yield | ||
try: | ||
self.as_connection.remove(self.key) | ||
except e.AerospikeError: | ||
pass | ||
|
||
@pytest.mark.parametrize( | ||
"bin_value", | ||
[ | ||
KeyOrderedDict({"f": 6, "e": 5, "d": 4}), | ||
[ | ||
KeyOrderedDict({"f": 6, "e": 5, "d": 4}) | ||
] | ||
], | ||
ids=[ | ||
"bin-level", | ||
"nested" | ||
] | ||
) | ||
def test_get_put_keyordereddict(self, bin_value): | ||
bins = { | ||
"dict": bin_value | ||
} | ||
self.key = ("test", "demo", 1) | ||
self.as_connection.put(self.key, bins) | ||
|
||
_, _, res = self.as_connection.get(self.key) | ||
|
||
assert res["dict"] == bin_value | ||
if type(res["dict"]) == list: | ||
assert type(res["dict"][0]) == KeyOrderedDict | ||
else: | ||
assert type(res["dict"]) == KeyOrderedDict |