amenezes / config-client

config-client package for spring cloud config and cloud foundry
https://config-client.amenezes.net/
Apache License 2.0
24 stars 18 forks source link

Tests for array values #46

Closed luiscoms closed 2 years ago

luiscoms commented 2 years ago

This Pull request have tests for fix #45

amenezes commented 2 years ago

@luiscoms,

The version 1.0.2 works partially with nested list settings.

But as you noted there are cases where there is still inconsistency in merging the settings. I believe that with a new fix the problem has been solved.

Could you try the version 1.0.3a0 - pip install 'config-client[cli]'==1.0.3a0 and check if the problem was resolved. If you preferer test locally could you check branch rl-1.0.3 and make some requests for local config-server.

To start the config-server run: docker-compose up -d and after some seconds can you use the CLI to query config, for example:

# show all config from simpleweb000 on development profile
python -m config client simpleweb000 --all -v

# filter for some config
python -m config client simpleweb000 first.second_3 -v

python -m config client simpleweb000 example -v

python -m config client simpleweb000 examples -v

The full configuration was available here: https://github.com/amenezes/spring_config

amenezes commented 2 years ago

@luiscoms,

I added some more tests to array values in the file test_config.py. Could you added the entries that you entered in this PR in the related file?

luiscoms commented 2 years ago

I guess that is missing string examples, in your tests, to cover other data types, like

                "examples.three.one[0]": "one",
                "examples.three.one[1]": "thow",

In order to cover all data types

amenezes commented 2 years ago

Ok @luiscoms. Could you provide some more examples in the test_config.py, as the example below:

@pytest.mark.parametrize(
    "data, expected",
    [
      ...
      (
          {"examples.three.one[0]": "one", "examples.three.one[1]": "thow"}, # data
          {"examples": {"three": {"one": ["one", "thow"]}}}, # expected
      )
    ]
)
def test_to_dict(data, expected):
    assert to_dict(data) == expected
luiscoms commented 2 years ago

I'v tested with version 1.0.3, and it was fixed