def test_int(self): """ Assert unpack returns a list containing the provided int. """ value = 314159 explode = False expected = [value] self.assertEqual(uri_parsing.unpack(value, explode), expected)
def test_bool(self): """ Assert unpack returns a list containing the provided bool. """ value = True explode = False expected = [value] self.assertEqual(uri_parsing.unpack(value, explode), expected)
def test_str(self): """ Assert unpack returns a list containing the provided string. """ value = "this is a test value" explode = False expected = [value] self.assertEqual(uri_parsing.unpack(value, explode), expected)
def test_list_explode(self): """ Assert expected result for an unpack call with a list and explode. When unpack is provided with a list and explode=True, it should return an exact copy of the list originally provided. """ value = ["fizz", "buzz"] explode = True expected = value self.assertEqual(uri_parsing.unpack(value, explode), expected)
def test_list_no_explode(self): """ Assert expected result for an unpack call with a list but no expldoe. When unpack is provided with a list but explode is False, it should return a list containing a string of the originial list in comma-delimited format. """ value = ["fizz", "buzz"] explode = False expected = [",".join(value)] self.assertEqual(uri_parsing.unpack(value, explode), expected)
def test_dict_no_explode(self): """ Assert expected result for an unpack call with a dicti but no explode. When unpack is provided with a dictionary while expode is False, it should return a list composed of seperate elements for each key and associated value in the dict. """ value = {"foo": "bar", "fizz": "buzz"} explode = False expected = ["foo", "bar", "fizz", "buzz"] self.assertEqual(sorted(uri_parsing.unpack(value, explode)), sorted(expected))
def test_dict_explode(self): """ Assert expected result for an unpack call with a dict and explode. When unpack is provided with a dictionary and explode is True, it should return a list containing a string in the form "key=value" """ value = {"foo": "bar", "fizz": "buzz"} explode = True expected = ["foo=bar", "fizz=buzz"] self.assertEqual(sorted(uri_parsing.unpack(value, explode)), sorted(expected))