def test_StringIsListWithMultipleFieldOneOfWhichIsAList_ReturnedValueIsListWithThoseFields( self): field = IterField() self.assertEqual(["foo", ["bar", "boo"], "moo"], field.to_python( pickle.dumps(["foo", ["bar", "boo"], "moo"])))
def test_ValueIsEmptyList_ResultMatchesInput(self): value = [] field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsDictWithElementsListAndDicts_ResultMatchesInput(self): value = {"foo": 1, "bar": [2, 3, 4], "boo": {"moo": 5}} field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsListWithElementsListAndDicts_ResultMatchesInput(self): value = [1, 2, 3, [4, 5, 6], {"foo": 8}] field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsEmptyDict_ResultMatchesInput(self): value = {} field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsListWithElementsListAndDicts_ResultMatchesInput(self): value = [1, 2, 3, [4, 5, 6], {"foo": 8}] field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsDictWithElementsListAndDicts_ResultMatchesInput(self): value = {"foo": 1, "bar": [2, 3, 4], "boo": {"moo": 5}} field = IterField() prepped = field.get_prep_value(value) py = field.to_python(prepped) self.assertEqual(value, py)
def test_ValueIsDictionary_DictionaryIsReturned(self): field = IterField() self.assertEqual({ 1: 2, 3: [4, 5, 6] }, field.to_python({ 1: 2, 3: [4, 5, 6] }))
def test_StringIsDictionary_ReturnedValueIsADictionaryWithTheCorrectFields( self): field = IterField() self.assertEqual({ "foo": "bar", "boo": ["moo", "maa"] }, field.to_python(pickle.dumps({ "foo": "bar", "boo": ["moo", "maa"] })))
def test_ValueIsList_ListIsReturned(self): field = IterField() self.assertEqual([1, 2, {3: 4}], field.to_python([1, 2, {3: 4}]))
def test_ValueIsDictionary_DictionaryIsReturned(self): field = IterField() self.assertEqual({1: 2, 3: [4, 5, 6]}, field.to_python({1: 2, 3: [4, 5, 6]}))
def test_ValueIsListOfElements_StringIsJsonRepresentationOfThatListWithNoSpaces( self): field = IterField() value = [1, 2, 3, 4, 5] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsAnEmptyList_StringIsEmptyList(self): field = IterField() value = [] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_StringIsDictionary_ReturnedValueIsADictionaryWithTheCorrectFields(self): field = IterField() self.assertEqual({"foo": "bar", "boo": ["moo", "maa"]}, field.to_python(pickle.dumps({"foo": "bar", "boo": ["moo", "maa"]})))
def test_StringIsEmpty_ReturnedValueIsEmptyList(self): field = IterField() self.assertEqual([], field.to_python(b""))
def test_ValueIsTupleOfListsAndDictionaries_StringIsJsonRepresentationOfThatListWithNoSpaces(self): field = IterField() value = (0, {1: {2: 3}}, [4, 5, 6]) self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_StringIsListWithOneField_ReturnedValueIsListWithThatField(self): field = IterField() self.assertEqual(["foo"], field.to_python(pickle.dumps(["foo"])))
def test_ValueIsListOfListsAndDictionaries_StringIsJsonRepresentationOfThatListWithNoSpaces(self): field = IterField() value = [[1, 2, 3], {4: 5}] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsDictionaryOfElements_StringIsJsonRepresentationOfThatListWithNoSpaces(self): field = IterField() value = {1: 2, 3: 4, 5: 6} self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsListOfElements_StringIsJsonRepresentationOfThatListWithNoSpaces(self): field = IterField() value = [1, 2, 3, 4, 5] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsATuple_StringIsEmptyDict(self): field = IterField() value = (1, 2, 3) self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsAnEmptyDictionary_StringIsEmptyDict(self): field = IterField() value = {} self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsTuple_TupleIsReturned(self): field = IterField() self.assertEqual((1, 2, 3, 4, 5, 6), field.to_python((1, 2, 3, 4, 5, 6)))
def test_ValueIsDictionaryOfElements_StringIsJsonRepresentationOfThatListWithNoSpaces( self): field = IterField() value = {1: 2, 3: 4, 5: 6} self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_StringIsEmptyList_ReturnedValueIsEmptyList(self): field = IterField() self.assertEqual([], field.to_python(pickle.dumps([])))
def test_ValueIsListOfListsAndDictionaries_StringIsJsonRepresentationOfThatListWithNoSpaces( self): field = IterField() value = [[1, 2, 3], {4: 5}] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_StringIsListWithMultipleFieldOneOfWhichIsAList_ReturnedValueIsListWithThoseFields(self): field = IterField() self.assertEqual(["foo", ["bar", "boo"], "moo"], field.to_python(pickle.dumps(["foo", ["bar", "boo"], "moo"])))
def test_StringIsEmptyList_ReturnedValueIsEmptyList(self): field = IterField() self.assertEqual([], field.to_python(pickle.dumps([])))
def test_ValueIsNone_ReturnedValueIsNone(self): field = IterField() self.assertIsNone(field.to_python(None))
def test_ValueIsAnEmptyList_StringIsEmptyList(self): field = IterField() value = [] self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsList_ListIsReturned(self): field = IterField() self.assertEqual([1, 2, {3: 4}], field.to_python([1, 2, {3: 4}]))
def test_ValueIsATuple_StringIsEmptyDict(self): field = IterField() value = (1, 2, 3) self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_ValueIsTuple_TupleIsReturned(self): field = IterField() self.assertEqual((1, 2, 3, 4, 5, 6), field.to_python( (1, 2, 3, 4, 5, 6)))
def test_ValueIsTupleOfListsAndDictionaries_StringIsJsonRepresentationOfThatListWithNoSpaces( self): field = IterField() value = (0, {1: {2: 3}}, [4, 5, 6]) self.assertEqual(pickle.dumps(value), field.get_prep_value(value))
def test_StringIsListWithOneField_ReturnedValueIsListWithThatField(self): field = IterField() self.assertEqual(["foo"], field.to_python(pickle.dumps(["foo"])))
def test_ValueIsNone_ReturnedValueIsNone(self): field = IterField() self.assertIsNone(field.to_python(None))
def test_StringIsEmpty_ReturnedValueIsEmptyList(self): field = IterField() self.assertEqual([], field.to_python(b""))
def test_ValueIsAnEmptyDictionary_StringIsEmptyDict(self): field = IterField() value = {} self.assertEqual(pickle.dumps(value), field.get_prep_value(value))