Skip to content

Commit 750e3ad

Browse files
authored
fix scan options (#117)
* fix scan options * fix scan options
1 parent 7d29cad commit 750e3ad

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

faust/stores/aerospike.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,7 @@ def _iterkeys(self) -> Iterator[bytes]:
135135
scan: aerospike.Scan = self.client.scan(
136136
namespace=self.namespace, set=self.table_name
137137
)
138-
scan_opts = {
139-
"concurrent": True,
140-
"nobins": True,
141-
"priority": 2,
142-
}
143-
for result in scan.results(policy=scan_opts):
138+
for result in scan.results():
144139
yield result[0][2]
145140
except Exception as ex:
146141
self.log.error(
@@ -150,11 +145,10 @@ def _iterkeys(self) -> Iterator[bytes]:
150145

151146
def _itervalues(self) -> Iterator[bytes]:
152147
try:
153-
scan_opts = {"concurrent": True, "priority": aerospike.SCAN_PRIORITY_MEDIUM}
154148
scan: aerospike.Scan = self.client.scan(
155149
namespace=self.namespace, set=self.table_name
156150
)
157-
for result in scan.results(policy=scan_opts):
151+
for result in scan.results():
158152
(key, meta, bins) = result
159153
if bins:
160154
yield bins[self.BIN_KEY]
@@ -168,12 +162,11 @@ def _itervalues(self) -> Iterator[bytes]:
168162

169163
def _iteritems(self) -> Iterator[Tuple[bytes, bytes]]:
170164
try:
171-
scan_opts = {"concurrent": True, "priority": aerospike.SCAN_PRIORITY_MEDIUM}
172165

173166
scan: aerospike.Scan = self.client.scan(
174167
namespace=self.namespace, set=self.table_name
175168
)
176-
for result in scan.results(policy=scan_opts):
169+
for result in scan.results():
177170
(key_data, meta, bins) = result
178171
(ns, set, policy, key) = key_data
179172

tests/unit/stores/test_aerospike.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ def test_iterkeys_error(self, store):
131131
def test_iterkeys_success(self, store):
132132
scan = MagicMock()
133133
store.client.scan = MagicMock(return_value=scan)
134-
scan_opts = {
135-
"concurrent": True,
136-
"nobins": True,
137-
"priority": 2,
138-
}
139134
scan_result = {
140135
(("UUID1", "t1", "key1"), MagicMock(), MagicMock()),
141136
(("UUID2", "t2", "key2"), MagicMock(), MagicMock()),
@@ -144,16 +139,15 @@ def test_iterkeys_success(self, store):
144139
a = {"key1", "key2"}
145140
result = a - set(store._iterkeys())
146141
assert len(result) == 0
147-
scan.results.assert_called_with(policy=scan_opts)
142+
assert scan.results.called
148143
store.client.scan.assert_called_with(
149144
namespace=store.namespace, set=store.table_name
150145
)
151146

152147
def test_itervalues_success(self, store):
153-
with patch("faust.stores.aerospike.aerospike", MagicMock()) as aero:
148+
with patch("faust.stores.aerospike.aerospike", MagicMock()):
154149
scan = MagicMock()
155150
store.client.scan = MagicMock(return_value=scan)
156-
scan_opts = {"concurrent": True, "priority": aero.SCAN_PRIORITY_MEDIUM}
157151
scan_result = [
158152
(MagicMock(), {"ttl": 4294967295, "gen": 4}, {"value_key": "value1"}),
159153
(MagicMock(), {"ttl": 4294967295, "gen": 4}, None),
@@ -162,7 +156,7 @@ def test_itervalues_success(self, store):
162156
a = {None, "value1"}
163157
result = a - set(store._itervalues())
164158
assert len(result) == 0
165-
scan.results.assert_called_with(policy=scan_opts)
159+
scan.results.assert_called_with()
166160
store.client.scan.assert_called_with(
167161
namespace=store.namespace, set=store.table_name
168162
)
@@ -178,11 +172,10 @@ def test_iteritems_error(self, store):
178172
set(store._iteritems())
179173

180174
def test_iteritems_success(self, store):
181-
with patch("faust.stores.aerospike.aerospike", MagicMock()) as aero:
175+
with patch("faust.stores.aerospike.aerospike", MagicMock()):
182176

183177
scan = MagicMock()
184178
store.client.scan = MagicMock(return_value=scan)
185-
scan_opts = {"concurrent": True, "priority": aero.SCAN_PRIORITY_MEDIUM}
186179
scan_result = [
187180
(
188181
("UUID1", "t1", MagicMock(), "key1"),
@@ -199,7 +192,7 @@ def test_iteritems_success(self, store):
199192
a = {("key1", "value1"), ("key2", "value2")}
200193
result = a - set(store._iteritems())
201194
assert len(result) == 0
202-
scan.results.assert_called_with(policy=scan_opts)
195+
assert scan.results.assert_called
203196
store.client.scan.assert_called_with(
204197
namespace=store.namespace, set=store.table_name
205198
)

0 commit comments

Comments
 (0)