openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
168 stars 75 forks source link

Support string parameter types #1094

Open nikhilwoodruff opened 2 years ago

nikhilwoodruff commented 2 years ago

This PR fixes #1092 by supporting string parameters. I've added a test for it, and removed an old test which would now be incorrect (testing that a string parameter fails).

benjello commented 2 years ago

@sandcha @MattiSG @maukoquiroga @guillett : do you remember why we forbid string parameters ?

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.02%) to 78.855% when pulling 18cd0c106524a09b5ff0af5a78be7de19855ee4f on nikhilwoodruff:string-parameter into 601a397fd02d6c56b751cadfbda0f3e5c911934f on openfisca:master.

sandcha commented 2 years ago

@nikhilwoodruff Do you have all the information you need about the Web API test suggested above?

nikhilwoodruff commented 2 years ago

@nikhilwoodruff Do you have all the information you need about the Web API test suggested above?

Thanks @MattiSG and @sandcha - not sure I fully understand what exactly the Web API should test for, could you provide any more detail?

MattiSG commented 2 years ago

The test you added tests the Python API of OpenFisca 👍 That's a great starting point!

However, by enabling new data types to be exposed, this changeset also changes the Web API (the module that exposes parameter values and calculations over RESTful HTTP). The web API is packaged in its own module (web_api at the root of the repository, alongside core). In order to ensure that the parameters are also properly exposed over the Web API, you need to also add tests for that behaviour 🙂

This is done by editing the tests/web_api/test_parameters.py file. I suggest that you add a new test that would try to get a String value. For that, you will need to add one such parameter in the Country Template, which will also enable discovery for new users.

Finally, of course, updating the documentation would be a great final touch for users to know about this new feature 😉