@@ -69,7 +69,7 @@ def setUpTestData(cls):
69
69
name = 'lemons-lemonade-stand' , used = False , active = True
70
70
)
71
71
cls .test_name_2 = OffTopicChannelName .objects .create (
72
- name = 'bbq-with-bisk' , used = True , active = True
72
+ name = 'bbq-with-bisk' , used = False , active = True
73
73
)
74
74
cls .test_name_3 = OffTopicChannelName .objects .create (
75
75
name = "frozen-with-iceman" , used = True , active = False
@@ -81,7 +81,7 @@ def test_returns_name_in_list(self):
81
81
response = self .client .get (url )
82
82
83
83
self .assertEqual (response .status_code , 200 )
84
- self .assertEqual (
84
+ self .assertListEqual (
85
85
response .json (),
86
86
[
87
87
self .test_name .name ,
@@ -90,22 +90,24 @@ def test_returns_name_in_list(self):
90
90
]
91
91
)
92
92
93
- def test_returns_single_item_with_random_items_param_set_to_1 (self ):
93
+ def test_returns_two_items_with_random_items_param_set_to_2 (self ):
94
94
"""Return not-used name instead used."""
95
95
url = reverse ('bot:offtopicchannelname-list' , host = 'api' )
96
- response = self .client .get (f'{ url } ?random_items=1 ' )
96
+ response = self .client .get (f'{ url } ?random_items=2 ' )
97
97
98
98
self .assertEqual (response .status_code , 200 )
99
- self .assertEqual (len (response .json ()), 1 )
100
- self .assertEqual (response .json (), [self .test_name .name ])
99
+ self .assertEqual (len (response .json ()), 2 )
100
+ self .assertEqual (response .json (), [self .test_name .name , self . test_name_2 . name ])
101
101
102
102
def test_running_out_of_names_with_random_parameter (self ):
103
103
"""Reset names `used` parameter to `False` when running out of names."""
104
104
url = reverse ('bot:offtopicchannelname-list' , host = 'api' )
105
- response = self .client .get (f'{ url } ?random_items=2 ' )
105
+ response = self .client .get (f'{ url } ?random_items=3 ' )
106
106
107
107
self .assertEqual (response .status_code , 200 )
108
- self .assertEqual (response .json (), [self .test_name .name , self .test_name_3 .name ])
108
+ self .assertListEqual (
109
+ response .json (), [self .test_name .name , self .test_name_2 .name , self .test_name_3 .name ]
110
+ )
109
111
110
112
def test_returns_inactive_ot_names (self ):
111
113
"""Return inactive off topic names."""
0 commit comments