@@ -196,24 +196,46 @@ def test_build_formdata(self):
196
196
self .assertEqual (actual , expected )
197
197
198
198
def test_get_details (self ):
199
- """Assert we handle valid JSON and other values."""
199
+ """Assert we handle valid dict and other values."""
200
200
actual_string_arg = form .get_details ('cool' )
201
201
expected_string_arg = 'cool'
202
202
self .assertEqual (actual_string_arg , expected_string_arg )
203
- actual_json_arg = form .get_details (json . dumps ( {'a' : 'b' , 'c' : False }) )
204
- expected_json_arg = '<li>a: b</li><li>c: false</li>'
205
- self .assertEqual (actual_json_arg , expected_json_arg )
203
+ actual_dict_arg = form .get_details ({'a' : 'b' , 'c' : False })
204
+ expected_dict_arg = '<li>a: b</li><li>c: false</li>'
205
+ self .assertEqual (actual_dict_arg , expected_dict_arg )
206
206
207
207
def test_build_details (self ):
208
208
"""Expected HTML is returned for a json object or a string."""
209
209
actual_json_arg = form .build_details (json .dumps (
210
210
{'a' : 'b' , 'c' : False }))
211
- expected_json_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n <li>a: b</li><li>c: false</li>\n </ul>\n </details>' # nopep8
211
+ expected_json_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n <li>a: b</li><li>c: false</li>\n </ul>\n \n </details>' # nopep8
212
212
self .assertEqual (actual_json_arg , expected_json_arg )
213
- actual_string_arg = form .build_details (" cool" )
214
- expected_string_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n cool\n </ul>\n </details>' # nopep8
213
+ actual_string_arg = form .build_details (' cool' )
214
+ expected_string_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n cool\n </ul>\n \n </details>' # nopep8
215
215
self .assertEqual (actual_string_arg , expected_string_arg )
216
216
217
+ def test_build_details_with_console_logs (self ):
218
+ """Expected HTML is returned for a json object with console logs."""
219
+ actual_json_arg = form .build_details (json .dumps (
220
+ {'a' : 'b' , 'c' : False , 'consoleLog' : ['console.log(hi)' ]}))
221
+ expected_json_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n <li>a: b</li><li>c: false</li>\n </ul>\n <p>Console Messages:</p>\n <pre>\n [u\' console.log(hi)\' ]\n </pre>\n </details>' # nopep8
222
+ self .assertEqual (actual_json_arg , expected_json_arg )
223
+ actual_empty_log_arg = form .build_details (json .dumps (
224
+ {'a' : 'b' , 'c' : False , 'consoleLog' : '' }))
225
+ expected_empty_log_arg = '<details>\n <summary>Browser Configuration</summary>\n <ul>\n <li>a: b</li><li>c: false</li>\n </ul>\n \n </details>' # nopep8
226
+ self .assertEqual (actual_empty_log_arg , expected_empty_log_arg )
227
+
228
+ def test_get_console_section (self ):
229
+ """Assert we return an empty string, or a pre with console messages."""
230
+ actual_empty_arg = form .get_console_section ('' )
231
+ expected_empty_arg = ''
232
+ self .assertEqual (actual_empty_arg , expected_empty_arg )
233
+ actual_none_arg = form .get_console_section (None )
234
+ self .assertEqual (actual_none_arg , expected_empty_arg )
235
+ actual_stringy_arg = form .get_console_section ('sup' )
236
+ expected_stringy_arg = '<p>Console Messages:</p>\n <pre>\n sup\n </pre>'
237
+ self .assertEqual (actual_stringy_arg , expected_stringy_arg )
238
+
217
239
def test_is_valid_issue_form (self ):
218
240
"""Assert that we get the form parameters we want."""
219
241
incomplete_form = MultiDict ([('problem_category' , u'unknown_bug' )])
0 commit comments