Example #1
0
    def test_StringIsListWithMultipleFieldOneOfWhichIsAList_ReturnedValueIsListWithThoseFields(
            self):
        field = IterField()

        self.assertEqual(["foo", ["bar", "boo"], "moo"],
                         field.to_python(
                             pickle.dumps(["foo", ["bar", "boo"], "moo"])))
    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_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_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)
Example #8
0
    def test_ValueIsDictionary_DictionaryIsReturned(self):
        field = IterField()

        self.assertEqual({
            1: 2,
            3: [4, 5, 6]
        }, field.to_python({
            1: 2,
            3: [4, 5, 6]
        }))
Example #9
0
    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_ValueIsNone_ReturnedValueIsNone(self):
        field = IterField()

        self.assertIsNone(field.to_python(None))
    def test_StringIsListWithOneField_ReturnedValueIsListWithThatField(self):
        field = IterField()

        self.assertEqual(["foo"], field.to_python(pickle.dumps(["foo"])))
Example #12
0
    def test_StringIsEmptyList_ReturnedValueIsEmptyList(self):
        field = IterField()

        self.assertEqual([], field.to_python(pickle.dumps([])))
Example #13
0
    def test_StringIsListWithOneField_ReturnedValueIsListWithThatField(self):
        field = IterField()

        self.assertEqual(["foo"], field.to_python(pickle.dumps(["foo"])))
    def test_StringIsEmpty_ReturnedValueIsEmptyList(self):
        field = IterField()

        self.assertEqual([], field.to_python(b""))
Example #15
0
    def test_ValueIsTuple_TupleIsReturned(self):
        field = IterField()

        self.assertEqual((1, 2, 3, 4, 5, 6), field.to_python(
            (1, 2, 3, 4, 5, 6)))
Example #16
0
    def test_StringIsEmpty_ReturnedValueIsEmptyList(self):
        field = IterField()

        self.assertEqual([], field.to_python(b""))
Example #17
0
    def test_ValueIsList_ListIsReturned(self):
        field = IterField()

        self.assertEqual([1, 2, {3: 4}], field.to_python([1, 2, {3: 4}]))
    def test_StringIsDictionary_ReturnedValueIsADictionaryWithTheCorrectFields(self):
        field = IterField()

        self.assertEqual({"foo": "bar", "boo": ["moo", "maa"]}, field.to_python(pickle.dumps({"foo": "bar", "boo": ["moo", "maa"]})))
Example #19
0
    def test_ValueIsNone_ReturnedValueIsNone(self):
        field = IterField()

        self.assertIsNone(field.to_python(None))
    def test_StringIsListWithMultipleFieldOneOfWhichIsAList_ReturnedValueIsListWithThoseFields(self):
        field = IterField()

        self.assertEqual(["foo", ["bar", "boo"], "moo"], field.to_python(pickle.dumps(["foo", ["bar", "boo"], "moo"])))
    def test_ValueIsList_ListIsReturned(self):
        field = IterField()

        self.assertEqual([1, 2, {3: 4}], field.to_python([1, 2, {3: 4}]))
    def test_StringIsEmptyList_ReturnedValueIsEmptyList(self):
        field = IterField()

        self.assertEqual([], field.to_python(pickle.dumps([])))
    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_ValueIsDictionary_DictionaryIsReturned(self):
        field = IterField()

        self.assertEqual({1: 2, 3: [4, 5, 6]}, field.to_python({1: 2, 3: [4, 5, 6]}))