Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
80e3344
model/api_types: Add data structures to support non-subscribed streams.
theViz343 May 31, 2023
82ed222
model: Add stream id accessor methods.
theViz343 Jun 6, 2023
d1a8eb7
refactor: model: Use get_stream_name instead of stream_dict.
theViz343 Jun 6, 2023
b51eae4
refactor: model/views: Use get_stream_subscribers instead of stream_d…
theViz343 Jun 6, 2023
80e0d5a
refactor: model: Use stream_date_created (get/set)ter methods.
theViz343 Jun 6, 2023
b6ab397
refactor: model: Use is_stream_web_public instead of stream_dict.
theViz343 Jun 6, 2023
55d8560
refactor: model: Use stream_message_retention_days (get/set)ter methods.
theViz343 Jun 6, 2023
023ea38
refactor: model: Use is_stream_invite_only instead of stream_dict.
theViz343 Jun 6, 2023
6282150
refactor: model/views: Use get_stream_post_policy accessor method.
theViz343 Jun 10, 2023
71d5bd0
refactor: model/views: Use is_stream_announcement_only accessor method.
theViz343 Jun 10, 2023
6a67577
refactor: model/views: Use is_stream_history_public_to_subscribers me…
theViz343 Jun 10, 2023
f451244
refactor: model/views: Use get_stream_weekly_traffic method.
theViz343 Jun 10, 2023
8d6e057
refactor: model/views: Use get_stream_rendered_description method.
theViz343 Jun 10, 2023
5e5bd20
model: Add get_all_subscription_ids accessor method.
theViz343 Jun 6, 2023
dee7e2b
refactor: model: Use get_subscription_color instead of stream_dict.
theViz343 Jun 6, 2023
e39bbe3
refactor: model/views: Use get_subscription_email instead of stream_d…
theViz343 Jun 10, 2023
5ca5ee6
refactor: model: Improve stream_dict typing.
theViz343 Jun 15, 2023
308fa13
refactor: model: Rename stream_dict to _subscribed_streams.
theViz343 Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ def web_public_stream() -> Subscription:
@pytest.fixture
def get_stream_from_id_fixture(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong in the next commit?

I also have two concerns about this fixture, if we keep it:

  • what is stream id? how is it used via the fixture?
  • the body is very similar to the function itself

stream_id: int,
stream_dict: Dict[int, Subscription],
_subscribed_streams: Dict[int, Subscription],
unsubscribed_streams_fixture: Dict[int, Subscription],
never_subscribed_streams_fixture: Dict[int, Stream],
) -> Union[Subscription, Stream]:
if stream_id in stream_dict:
return stream_dict[stream_id]
if stream_id in _subscribed_streams:
return _subscribed_streams[stream_id]
elif stream_id in unsubscribed_streams_fixture:
return unsubscribed_streams_fixture[stream_id]
else:
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def never_subscribed_streams_fixture() -> Dict[int, Stream]:


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


Expand Down
20 changes: 10 additions & 10 deletions tests/core/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def test_narrow_to_stream(
controller.model.narrow = []
controller.model.index = index_stream
controller.view.message_view = mocker.patch("urwid.ListBox")
controller.model.stream_dict = {
controller.model._subscribed_streams = {
stream_id: general_stream,
}
controller.model.stream_dict[stream_id].update(
controller.model._subscribed_streams[stream_id].update(
{
"color": "#ffffff",
"name": stream_name,
Expand Down Expand Up @@ -191,10 +191,10 @@ def test_narrow_to_topic(
controller.model.index = index_multiple_topic_msg
controller.model.stream_id = initial_stream_id
controller.view.message_view = mocker.patch("urwid.ListBox")
controller.model.stream_dict = {
controller.model._subscribed_streams = {
stream_id: general_stream,
}
controller.model.stream_dict[stream_id].update(
controller.model._subscribed_streams[stream_id].update(
{
"color": "#ffffff",
"name": stream_name,
Expand Down Expand Up @@ -267,10 +267,10 @@ def test_narrow_to_all_messages(
controller.view.message_view = mocker.patch("urwid.ListBox")
controller.model.user_email = "some@email"
controller.model.user_id = 1
controller.model.stream_dict = {
controller.model._subscribed_streams = {
205: general_stream,
}
controller.model.stream_dict[205].update(
controller.model._subscribed_streams[205].update(
{
"color": "#ffffff",
}
Expand Down Expand Up @@ -323,10 +323,10 @@ def test_narrow_to_all_starred(
# FIXME: Expand upon is_muted_topic().
mocker.patch(MODEL + ".is_muted_topic", return_value=False)
controller.model.user_email = "some@email"
controller.model.stream_dict = {
controller.model._subscribed_streams = {
205: general_stream,
}
controller.model.stream_dict[205].update(
controller.model._subscribed_streams[205].update(
{
"color": "#ffffff",
}
Expand Down Expand Up @@ -357,10 +357,10 @@ def test_narrow_to_all_mentions(
mocker.patch(MODEL + ".is_muted_topic", return_value=False)
controller.model.user_email = "some@email"
controller.model.user_id = 1
controller.model.stream_dict = {
controller.model._subscribed_streams = {
205: general_stream,
}
controller.model.stream_dict[205].update(
controller.model._subscribed_streams[205].update(
{
"color": "#ffffff",
}
Expand Down
9 changes: 6 additions & 3 deletions tests/helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,21 @@ def test_powerset(
def test_classify_unread_counts(
mocker: MockerFixture,
initial_data: Dict[str, Any],
stream_dict: Dict[int, Subscription],
_subscribed_streams: Dict[int, Subscription],
classified_unread_counts: Dict[str, Any],
muted_topics: List[List[str]],
muted_streams: Set[int],
vary_in_unreads: Dict[str, Any],
) -> None:
model = mocker.Mock()
model.stream_dict = stream_dict
model._subscribed_streams = _subscribed_streams
model.initial_data = initial_data
model.is_muted_topic = mocker.Mock(
side_effect=(
lambda stream_id, topic: [model.stream_dict[stream_id]["name"], topic]
lambda stream_id, topic: [
model._subscribed_streams[stream_id]["name"],
topic,
]
in muted_topics
)
)
Expand Down
Loading