Skip to content

Commit

Permalink
Merge branch 'master' into upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
wbarnha authored Jun 22, 2023
2 parents 2154873 + 0531715 commit 5b56ef4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions faust/tables/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def on_change(self, added: Set[VT], removed: Set[VT]) -> None:
self.manager.send_changelog_event(self.key, OPERATION_UPDATE, [added, removed])

def sync_from_storage(self, value: Any) -> None:
self.data = cast(Set, value)
self.data = set(value)

def as_stored_value(self) -> Any:
return self.data
Expand Down Expand Up @@ -204,19 +204,19 @@ async def symmetric_difference_update(self, key: KT, members: Iterable[VT]) -> N
await self._send_operation(SetAction.SYMDIFF, key, members)

def _update(self, key: KT, members: List[VT]) -> None:
self.set_table[key].update(members)
self.set_table[key].update(set(members))

def _difference_update(self, key: KT, members: List[VT]) -> None:
self.set_table[key].difference_update(members)
self.set_table[key].difference_update(set(members))

def _clear(self, key: KT, members: List[VT]) -> None:
self.set_table[key].clear()

def _intersection_update(self, key: KT, members: List[VT]) -> None:
self.set_table[key].intersection_update(members)
self.set_table[key].intersection_update(set(members))

def _symmetric_difference_update(self, key: KT, members: List[VT]) -> None:
self.set_table[key].symmetric_difference_update(members)
self.set_table[key].symmetric_difference_update(set(members))

async def _send_operation(
self, action: SetAction, key: KT, members: Iterable[VT]
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/tables/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ async def test_symmetric_difference_update(self, *, man):
def test__update(self, *, man):
man.set_table = {"a": Mock(name="a"), "b": Mock(name="b")}
man._update("a", ["v1"])
man.set_table["a"].update.assert_called_once_with(["v1"])
man.set_table["a"].update.assert_called_once_with({"v1"})

def test__difference_update(self, *, man):
man.set_table = {"a": Mock(name="a"), "b": Mock(name="b")}
man._difference_update("a", ["v1"])
man.set_table["a"].difference_update.assert_called_once_with(["v1"])
man.set_table["a"].difference_update.assert_called_once_with({"v1"})

def test__clear(self, *, man):
man.set_table = {"a": Mock(name="a"), "b": Mock(name="b")}
Expand All @@ -264,14 +264,14 @@ def test__intersection_update(self, *, man):
man.set_table = {"a": Mock(name="a"), "b": Mock(name="b")}
man._intersection_update("a", ["v1", "v2", "v3"])
man.set_table["a"].intersection_update.assert_called_once_with(
["v1", "v2", "v3"],
{"v1", "v2", "v3"},
)

def test__symmetric_difference_update(self, *, man):
man.set_table = {"a": Mock(name="a"), "b": Mock(name="b")}
man._symmetric_difference_update("a", ["v1", "v2", "v3"])
man.set_table["a"].symmetric_difference_update.assert_called_once_with(
["v1", "v2", "v3"],
{"v1", "v2", "v3"},
)

@pytest.mark.asyncio
Expand Down Expand Up @@ -396,29 +396,29 @@ async def stream_items():

await man._modify_set(stream)

man.set_table["k1"].update.assert_called_with(["v"])
man.set_table["k2"].difference_update.assert_called_with(["v2"])
man.set_table["k3"].difference_update.assert_called_with([X(10, 30)])
man.set_table["k1"].update.assert_called_with({"v"})
man.set_table["k2"].difference_update.assert_called_with({"v2"})
man.set_table["k3"].difference_update.assert_called_with({X(10, 30)})
man.set_table["k5"].update.assert_called_with(
[
{
X(10, 30),
X(20, 40),
"v3",
]
}
)
man.set_table["k6"].intersection_update.assert_called_with(
[
{
X(10, 30),
X(20, 40),
"v3",
]
}
)
man.set_table["k7"].symmetric_difference_update.assert_called_with(
[
{
X(10, 30),
X(20, 40),
"v3",
]
}
)
man.set_table["k8"].clear.assert_called_once_with()

Expand Down

0 comments on commit 5b56ef4

Please sign in to comment.