@@ -1699,6 +1699,126 @@ def test__update_users_data_from_initial_data(
1699
1699
assert model .user_dict == user_dict
1700
1700
assert model .users == user_list
1701
1701
1702
+ @pytest .mark .parametrize (
1703
+ "stream_id, expected_value" ,
1704
+ [
1705
+ case (
1706
+ 1000 ,
1707
+ {
1708
+ "name" : "Some general stream" ,
1709
+ "date_created" : None ,
1710
+ "invite_only" : False ,
1711
+ "color" : "#baf" ,
1712
+ "pin_to_top" : False ,
1713
+ "stream_id" : 1000 ,
1714
+ "is_muted" : False ,
1715
+ "audible_notifications" : False ,
1716
+ "description" : "General Stream" ,
1717
+ "rendered_description" : "General Stream" ,
1718
+ "desktop_notifications" : False ,
1719
+ "stream_weekly_traffic" : 0 ,
1720
+ "push_notifications" : False ,
1721
+ "email_address" : "general@example.comm" ,
1722
+ "message_retention_days" : None ,
1723
+ "subscribers" : [1001 , 11 , 12 ],
1724
+ "history_public_to_subscribers" : True ,
1725
+ "is_announcement_only" : False ,
1726
+ "first_message_id" : 1 ,
1727
+ "email_notifications" : False ,
1728
+ "wildcard_mentions_notify" : False ,
1729
+ "is_web_public" : False ,
1730
+ },
1731
+ ),
1732
+ case (
1733
+ 3 ,
1734
+ {
1735
+ "name" : "Stream 3" ,
1736
+ "date_created" : 1472047127 ,
1737
+ "invite_only" : False ,
1738
+ "color" : "#b0a5fd" ,
1739
+ "pin_to_top" : False ,
1740
+ "stream_id" : 3 ,
1741
+ "is_muted" : False ,
1742
+ "audible_notifications" : False ,
1743
+ "description" : "A description of stream 3" ,
1744
+ "rendered_description" : "A description of stream 3" ,
1745
+ "desktop_notifications" : False ,
1746
+ "stream_weekly_traffic" : 0 ,
1747
+ "push_notifications" : False ,
1748
+ "message_retention_days" : 33 ,
1749
+ "email_address" : "stream3@example.com" ,
1750
+ "email_notifications" : False ,
1751
+ "wildcard_mentions_notify" : False ,
1752
+ "subscribers" : [1001 , 11 , 12 ],
1753
+ "history_public_to_subscribers" : True ,
1754
+ "is_announcement_only" : True ,
1755
+ "stream_post_policy" : 0 ,
1756
+ "is_web_public" : True ,
1757
+ "first_message_id" : None ,
1758
+ },
1759
+ ),
1760
+ case (
1761
+ 5 ,
1762
+ {
1763
+ "name" : "Stream 5" ,
1764
+ "date_created" : 1472047129 ,
1765
+ "invite_only" : False ,
1766
+ "stream_id" : 5 ,
1767
+ "description" : "A description of stream 5" ,
1768
+ "rendered_description" : "A description of stream 5" ,
1769
+ "stream_weekly_traffic" : 0 ,
1770
+ "message_retention_days" : 35 ,
1771
+ "subscribers" : [1001 , 11 , 12 ],
1772
+ "history_public_to_subscribers" : True ,
1773
+ "is_announcement_only" : True ,
1774
+ "stream_post_policy" : 0 ,
1775
+ "is_web_public" : True ,
1776
+ "first_message_id" : None ,
1777
+ },
1778
+ ),
1779
+ ],
1780
+ )
1781
+ def test__get_stream_from_id (
1782
+ self ,
1783
+ model ,
1784
+ stream_id ,
1785
+ expected_value ,
1786
+ stream_dict ,
1787
+ unsubscribed_streams_fixture ,
1788
+ never_subscribed_streams_fixture ,
1789
+ ):
1790
+ model .stream_dict = stream_dict
1791
+ model ._unsubscribed_streams = unsubscribed_streams_fixture
1792
+ model ._never_subscribed_streams = never_subscribed_streams_fixture
1793
+ assert model ._get_stream_from_id (stream_id ) == expected_value
1794
+
1795
+ def test__get_stream_from_id__nonexistent_stream (
1796
+ self ,
1797
+ model ,
1798
+ stream_dict ,
1799
+ unsubscribed_streams_fixture ,
1800
+ never_subscribed_streams_fixture ,
1801
+ stream_id = 231 , # id 231 does not belong to any stream
1802
+ ):
1803
+ model .stream_dict = stream_dict
1804
+ model ._unsubscribed_streams = unsubscribed_streams_fixture
1805
+ model ._never_subscribed_streams = never_subscribed_streams_fixture
1806
+ with pytest .raises (RuntimeError ):
1807
+ model ._get_stream_from_id (stream_id )
1808
+
1809
+ def test__get_all_stream_ids (
1810
+ self ,
1811
+ model ,
1812
+ stream_dict ,
1813
+ unsubscribed_streams_fixture ,
1814
+ never_subscribed_streams_fixture ,
1815
+ expected_value = [1000 , 99 , 999 , 1 , 2 , 3 , 4 , 5 , 6 ],
1816
+ ):
1817
+ model .stream_dict = stream_dict
1818
+ model ._unsubscribed_streams = unsubscribed_streams_fixture
1819
+ model ._never_subscribed_streams = never_subscribed_streams_fixture
1820
+ assert model ._get_all_stream_ids () == expected_value
1821
+
1702
1822
@pytest .mark .parametrize ("muted" , powerset ([99 , 1000 ]))
1703
1823
@pytest .mark .parametrize ("visual_notification_enabled" , powerset ([99 , 1000 ]))
1704
1824
def test__subscribe_to_streams (
0 commit comments