updates census api with invalid stubbed response

This commit is contained in:
rgarcia
2016-12-20 12:21:35 +01:00
parent 7d3cb112ac
commit 398206c375

View File

@@ -74,7 +74,7 @@ class CensusApi
if end_point_available?
client.call(:get_habita_datos, message: request(document_type, document_number)).body
else
stubbed_response_body
stubbed_response(document_type, document_number)
end
end
@@ -97,8 +97,20 @@ class CensusApi
Rails.env.staging? || Rails.env.preproduction? || Rails.env.production?
end
def stubbed_response_body
{get_habita_datos_response: {get_habita_datos_return: {hay_errores: false, datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
def stubbed_response(document_type, document_number)
if document_number == "12345678Z" && document_type == "1"
stubbed_valid_response
else
stubbed_invalid_response
end
end
def stubbed_valid_response
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón", nombre: "José", apellido1: "García" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
end
def stubbed_invalid_response
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}, datos_vivienda: {}}}}
end
def is_dni?(document_type)