Commit Graph

12 Commits

Author SHA1 Message Date
Senén Rodero Rodríguez
dd0f56f85f Use shorter responses and configuration for specs
By simplyfing the responses the configuration for specs can be simpler too.

We're also using more generic terms instead of the ones used in Madrid's
Census API.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
93e458d46e Return invalid response when document_type or document_number are empty
Probably this case is not real for production environments where those
arguments will always be fullfilled but seems to be interesting for
testing environment where this method is being called when those
paremeters where empty.
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
06dcbd699c Extract block to configure remote census in tests
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-11-02 11:42:39 +01:00
Senén Rodero Rodríguez
ba6b2f4940 Refactor specs
Improve readability, simplify, reorganize and cover missing cases.
2019-10-21 14:30:03 +02:00
Javi Martín
ffc50246c2 Apply explict RSpec/DescribedClass rubocop rule
We settled on using this style in commit 4cbe81a1, but didn't add the
rule enforcing this style and we didn't apply it to existing code.
2019-09-23 16:51:00 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
taitus
4dfce4f245 RemoteCensusAPI accept :date_of_birth and :postal_code
New RemoteCensusAPI allow receive :date_of_birth and
:postal_code and use in request to endpoint always that have
been configured on remote_census_configuration:
  - Setting["remote_census.request.date_of_birth"]
  - Setting["remote_census.request.postal_code"]

Add new params to CensusCaller 'call' method.
2019-07-29 13:10:09 +02:00
taitus
3f16157418 Create new RemoteCensusAPI
Create a new RemoteCensusAPI with the same functionality as
the old CensusAPI.

In the new RemoteCensusAPI both the request and the
processing of the response are made according to the
parameters defined in the "Remote Census Configuration"
page.

Same as old Census API we only consider document_type and
document_number on API request.

* request(document_type, document_number))

On "Remote Census Configuration" we allow to define request
structure on Setting["remote_census.request.structure"]

The information text of this field on "Remote Census Configuration" is:
> The "static" values of this request should be filled.
> Values related to Document Type, Document Number, Date of Birth and
  Postal Code should be nil value.

An Example with the expected value for this field:
"{ request:
    {
      codigo_institucion: 1,
      codigo_portal: 1,
      codigo_usuario: 1,
      documento: nil,
      tipo_documento: nil,
      codigo_idioma: '102',
      nivel: '3'
    }
  }"
Where 'codigo_institucion', 'codigo_portal', 'codigo_usuario' and
'nivel' are "static" and filled in with their expected static values.
On the other hand 'documento' and 'tipo_documento' are fields
related with 'document_type','document_number' and filled in with
 nil value.

On 'request' method we fill in thats 'nil values' with their
correct argument value. We can fill_in correctly because on
"Remote Census Configuration" we allow to define request path for
'document_type','document_number'

Setting["remote_census.request.document_type"]
Setting["remote_census.request.document_number"]

An Example with the expected values:
Setting["remote_census.request.document_type"] = "request.tipo_documento"
Setting["remote_census.request.document_number"] = "request.documento"

With this information with 'fill_in(structure, path_value, value)'
method, we can update structure with correct argument ('document_type',
'document_number', 'date_of_birth' and 'postal_code') value.

An Example of fill_in(structure, path_value, value) where:
structure = "{ request:
                {
                  codigo_institucion: 1,
                  codigo_portal: 1,
                  codigo_usuario: 1,
                  documento: nil,
                  tipo_documento: nil,
                  codigo_idioma: '102',
                  nivel: '3'
                }
              }"
path_value = "request.documento"
value = "12345678X"

The result expected is:
{ request:
  {
    codigo_institucion: 1,
    codigo_portal: 1,
    codigo_usuario: 1,
    documento: "12345678X",
    tipo_documento: nil,
    codigo_idioma: '102',
    nivel: '3'
  }
}
2019-07-29 13:10:09 +02:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Angel Perez
bdda397bf1 Use new RSpec stub syntax to fix deprecation warnings 2018-09-10 11:41:20 -04:00
Bertocq
7d406cae76 Rubocop autocorrections 2017-07-25 13:01:03 +02:00
María Checa
dccf221b47 New tests added for Census calls
Added new spec files for `CensusCaller` and `LocalCensus` libraries.
2017-07-14 15:39:49 +02:00