Skip to content

Make FakeConfiguration a representative configuration object. #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

albu-diku
Copy link

As of this commit fake configuration instances are populated with the same properties, including the same default values, as a genuine Configuration object instance. This ensures that logic under test is going to behave far more as it would with a real configuration object which means a great deal more assurance in the tests.

Achieve this by using the dictionary of defaults that was split out previously to initialize the FakeConfiguration which itself is now a SimpleNamespace. Making it a namespace ensures that attribute lookup, something that normal Configuration objects support, work correctly but in addition forces the attributes to be set "up front". This keeps us honest in the properties we expose.

Since a FakeConfiguration needs to track the real Configuration we also prevent the addition of attributes that not keys of a real configuration. Unfortunarely it seems that a lot of properties are set dynamically as part of loading a configuration, but laythe first steps to a canonical configuration object by making a couple of properties used by existing tests static; existing defaults are re-used to avoid functional change.

As of this commit fake configuration instances are populated with
the same properties, including the same default values, as a genuine
Configuration object instance. This ensures that logic under test is
going to behave far more as it would with a real configuration object
which means a great deal more assurance in the tests.

Achieve this by using the dictionary of defaults that was split out
previously to initialize the FakeConfiguration which itself is now
a SimpleNamespace. Making it a namespace ensures that attribute lookup,
something that normal Configuration objects support, work correctly but
in addition forces the attributes to be set "up front". This keeps us
honest in the properties we expose.

Since a FakeConfiguration needs to track the real Configuration we also
prevent the addition of attributes that not keys of a real configuration.
Unfortunarely it seems that a lot of properties are set dynamically as
part of loading a configuration, but laythe first steps to a canonical
configuration object by making a couple of properties used by existing
tests static; existing defaults are re-used to avoid functional change.
@albu-diku albu-diku force-pushed the test/enhance-fake-configuration branch from 40c209e to b451cff Compare April 9, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant