def test_deserialize_string_boolean_map(self):
        """
        Ensures that string boolean (additional properties)
        deserialization works
        """
        # make sure that an exception is thrown on an invalid type
        with self.assertRaises(ApiTypeError):
            deserialized = self.deserialize(
                MockResponse(data=json.dumps("test str")),
                (petstore_api.StringBooleanMap, ), True)

        # valid value works
        item_val = {'some_key': True}
        response = MockResponse(data=json.dumps(item_val))
        model = petstore_api.StringBooleanMap(**item_val)
        deserialized = self.deserialize(response,
                                        (petstore_api.StringBooleanMap, ),
                                        True)
        self.assertTrue(isinstance(deserialized,
                                   petstore_api.StringBooleanMap))
        self.assertTrue(deserialized['some_key'] == True)
        self.assertTrue(deserialized == model)
    def test_sanitize_for_serialization(self):
        # None
        data = None
        result = self.api_client.sanitize_for_serialization(None)
        self.assertEqual(result, data)

        # str
        data = "test string"
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, data)

        # int
        data = 1
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, data)

        # bool
        data = True
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, data)

        # date
        data = parse("1997-07-16").date()  # date
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, "1997-07-16")

        # datetime
        data = parse("1997-07-16T19:20:30.45+01:00")  # datetime
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, "1997-07-16T19:20:30.450000+01:00")

        # list
        data = [1]
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, data)

        # dict
        data = {"test key": "test value"}
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, data)

        # model
        pet_dict = {
            "id":
            1,
            "name":
            "monkey",
            "category": {
                "id": 1,
                "name": "test category"
            },
            "tags": [{
                "id": 1,
                "name": "test tag1"
            }, {
                "id": 2,
                "name": "test tag2"
            }],
            "status":
            "available",
            "photoUrls": ["http://foo.bar.com/3", "http://foo.bar.com/4"]
        }
        pet = petstore_api.Pet(name=pet_dict["name"],
                               photo_urls=pet_dict["photoUrls"])
        pet.id = pet_dict["id"]
        cate = petstore_api.Category()
        cate.id = pet_dict["category"]["id"]
        cate.name = pet_dict["category"]["name"]
        pet.category = cate
        tag1 = petstore_api.Tag()
        tag1.id = pet_dict["tags"][0]["id"]
        tag1.name = pet_dict["tags"][0]["name"]
        tag2 = petstore_api.Tag()
        tag2.id = pet_dict["tags"][1]["id"]
        tag2.name = pet_dict["tags"][1]["name"]
        pet.tags = [tag1, tag2]
        pet.status = pet_dict["status"]

        data = pet
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, pet_dict)

        # list of models
        list_of_pet_dict = [pet_dict]
        data = [pet]
        result = self.api_client.sanitize_for_serialization(data)
        self.assertEqual(result, list_of_pet_dict)

        # model with additional proerties
        model_dict = {'some_key': True}
        model = petstore_api.StringBooleanMap(**model_dict)
        result = self.api_client.sanitize_for_serialization(model)
        self.assertEqual(result, model_dict)