Пример #1
0
def deserialize_wrong_mimetype_infrastructure_test():
    data = util.load_json_from_file('infrastructure_request.json')
    
    try:
        Infrastructure.deserialize(util.WRONG_MIMETYPE, data)
        assert False
    except NotImplementedError as e:
        assert 'Unrecognized mimetype or model type' in str(e)
Пример #2
0
def register_infrastructure():
    body = util.remove_non_usable_characters(
                        util.remove_xml_header(request.data.decode("utf-8")))
    content_type = request.content_type
    
    validator_factory = factory_selector.get_factory(content_type)
    validator = validator_factory.create_infrastructure_request_validator()
    validator.validate(body)
    
    infrastructure = Infrastructure.deserialize(content_type, body)
    
    manager = FlavorSynchronizer()
    manager.register_infrastructure(infrastructure)
    
    response_body = infrastructure.serialize(request.accept_mimetypes)
    
    return Response(response_body, status=201, mimetype=request.accept_mimetypes[0][0])
Пример #3
0
def deserialize_xml_infrastructure_test():
    data = util.load_clean_xml_payload('infrastructure_request.xml')
    infrastructure = Infrastructure.deserialize(util.XML_MIMETYPE, data)
    _check_infrastructure_model_contents(infrastructure)
Пример #4
0
def deserialize_json_infrastructure_test():
    data = util.load_json_from_file('infrastructure_request.json')
    infrastructure = Infrastructure.deserialize(util.JSON_MIMETYPE, json.dumps(data))
    _check_infrastructure_model_contents(infrastructure)