Skip to content

Commit 308fa13

Browse files
committed
refactor: model: Rename stream_dict to _subscribed_streams.
This commit renames stream_dict to _subscribed_streams. This change is necessary due to the introduction of _unsubscribed_streams and never_subscribed streams in the model. Tests updated.
1 parent 5ca5ee6 commit 308fa13

File tree

11 files changed

+123
-105
lines changed

11 files changed

+123
-105
lines changed

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ def web_public_stream() -> Subscription:
299299
@pytest.fixture
300300
def get_stream_from_id_fixture(
301301
stream_id: int,
302-
stream_dict: Dict[int, Subscription],
302+
_subscribed_streams: Dict[int, Subscription],
303303
unsubscribed_streams_fixture: Dict[int, Subscription],
304304
never_subscribed_streams_fixture: Dict[int, Stream],
305305
) -> Union[Subscription, Stream]:
306-
if stream_id in stream_dict:
307-
return stream_dict[stream_id]
306+
if stream_id in _subscribed_streams:
307+
return _subscribed_streams[stream_id]
308308
elif stream_id in unsubscribed_streams_fixture:
309309
return unsubscribed_streams_fixture[stream_id]
310310
else:
@@ -1278,7 +1278,7 @@ def never_subscribed_streams_fixture() -> Dict[int, Stream]:
12781278

12791279

12801280
@pytest.fixture
1281-
def stream_dict(streams_fixture: List[Subscription]) -> Dict[int, Subscription]:
1281+
def _subscribed_streams(streams_fixture: List[Subscription]) -> Dict[int, Subscription]:
12821282
return {stream["stream_id"]: stream for stream in streams_fixture}
12831283

12841284

tests/core/test_core.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ def test_narrow_to_stream(
132132
controller.model.narrow = []
133133
controller.model.index = index_stream
134134
controller.view.message_view = mocker.patch("urwid.ListBox")
135-
controller.model.stream_dict = {
135+
controller.model._subscribed_streams = {
136136
stream_id: general_stream,
137137
}
138-
controller.model.stream_dict[stream_id].update(
138+
controller.model._subscribed_streams[stream_id].update(
139139
{
140140
"color": "#ffffff",
141141
"name": stream_name,
@@ -191,10 +191,10 @@ def test_narrow_to_topic(
191191
controller.model.index = index_multiple_topic_msg
192192
controller.model.stream_id = initial_stream_id
193193
controller.view.message_view = mocker.patch("urwid.ListBox")
194-
controller.model.stream_dict = {
194+
controller.model._subscribed_streams = {
195195
stream_id: general_stream,
196196
}
197-
controller.model.stream_dict[stream_id].update(
197+
controller.model._subscribed_streams[stream_id].update(
198198
{
199199
"color": "#ffffff",
200200
"name": stream_name,
@@ -267,10 +267,10 @@ def test_narrow_to_all_messages(
267267
controller.view.message_view = mocker.patch("urwid.ListBox")
268268
controller.model.user_email = "some@email"
269269
controller.model.user_id = 1
270-
controller.model.stream_dict = {
270+
controller.model._subscribed_streams = {
271271
205: general_stream,
272272
}
273-
controller.model.stream_dict[205].update(
273+
controller.model._subscribed_streams[205].update(
274274
{
275275
"color": "#ffffff",
276276
}
@@ -323,10 +323,10 @@ def test_narrow_to_all_starred(
323323
# FIXME: Expand upon is_muted_topic().
324324
mocker.patch(MODEL + ".is_muted_topic", return_value=False)
325325
controller.model.user_email = "some@email"
326-
controller.model.stream_dict = {
326+
controller.model._subscribed_streams = {
327327
205: general_stream,
328328
}
329-
controller.model.stream_dict[205].update(
329+
controller.model._subscribed_streams[205].update(
330330
{
331331
"color": "#ffffff",
332332
}
@@ -357,10 +357,10 @@ def test_narrow_to_all_mentions(
357357
mocker.patch(MODEL + ".is_muted_topic", return_value=False)
358358
controller.model.user_email = "some@email"
359359
controller.model.user_id = 1
360-
controller.model.stream_dict = {
360+
controller.model._subscribed_streams = {
361361
205: general_stream,
362362
}
363-
controller.model.stream_dict[205].update(
363+
controller.model._subscribed_streams[205].update(
364364
{
365365
"color": "#ffffff",
366366
}

tests/helper/test_helper.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,21 @@ def test_powerset(
278278
def test_classify_unread_counts(
279279
mocker: MockerFixture,
280280
initial_data: Dict[str, Any],
281-
stream_dict: Dict[int, Subscription],
281+
_subscribed_streams: Dict[int, Subscription],
282282
classified_unread_counts: Dict[str, Any],
283283
muted_topics: List[List[str]],
284284
muted_streams: Set[int],
285285
vary_in_unreads: Dict[str, Any],
286286
) -> None:
287287
model = mocker.Mock()
288-
model.stream_dict = stream_dict
288+
model._subscribed_streams = _subscribed_streams
289289
model.initial_data = initial_data
290290
model.is_muted_topic = mocker.Mock(
291291
side_effect=(
292-
lambda stream_id, topic: [model.stream_dict[stream_id]["name"], topic]
292+
lambda stream_id, topic: [
293+
model._subscribed_streams[stream_id]["name"],
294+
topic,
295+
]
293296
in muted_topics
294297
)
295298
)

0 commit comments

Comments
 (0)