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