def test_convert_with_Mock_type(self): # Arrange test_dict = mock # Assert with self.assertRaises(TypeError) as e: convert(test_dict) self.assertEqual(e.exception.message, 'Unsupported data type')
def test_convert_with_string_type__convert_backslash_into_br_tag(self): # Arrange test_dict = {'a':'Test_text\n'} expect_result = '<dl><dt>a</dt><dd><span class="string">Test_text<br></span></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)
def test_convert_with_float_type(self): # Arrange test_dict = {'a':5.55} expect_result = '<dl><dt>a</dt><dd><span class="float">5.55</span></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)
def test_convert_atom_with_unicode_input(self): # Arrange test_dict = {'a': u'\u2014'} expect_result = u'<dl><dt>a</dt><dd><span class="string">—</span></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)
def test_convert_with_boolean_type(self): # Arrange test_dict = {'a':True} expect_result = '<dl><dt>a</dt><dd><span class="boolean">True</span></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)
def test_convert_with_none_type(self): # Arrange test_dict = {'a':None} expect_result = '<dl><dt>a</dt><dd><span class="null"></span></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)
def test_convert_with_array_type(self): # Arrange test_dict = {'a':[1, 2, 3]} expect_result = '<dl><dt>a</dt><dd><ol><li><span class="int">1</span></li><li><span class="int">2</span></li>' \ '<li><span class="int">3</span></li></ol></dd></dl>' # Act result = convert(test_dict) # Assert self.assertEqual(result, expect_result)