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