Skip to content

Add mock mode for ConfigClient#195

Open
oliwenmandiamond wants to merge 29 commits into
mainfrom
create_mock_config_client
Open

Add mock mode for ConfigClient#195
oliwenmandiamond wants to merge 29 commits into
mainfrom
create_mock_config_client

Conversation

@oliwenmandiamond

@oliwenmandiamond oliwenmandiamond commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes #194

@oliwenmandiamond oliwenmandiamond marked this pull request as draft June 26, 2026 11:14
@oliwenmandiamond oliwenmandiamond marked this pull request as ready for review June 26, 2026 13:45
@oliwenmandiamond

oliwenmandiamond commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

@DominicOram thanks for the review for my dodal change DiamondLightSource/dodal#2099. I agree with your points. However, I felt as though I was fighting the design of the ConfigClient so I've just made the change directly here and then I will rebase my dodal change on this. Let me know what you think!

@jacob720 jacob720 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing my comments on the dodal PR, I don't think we should add behaviour to do conversion into a mock client. The client receives converted data from the server, and any test data in dodal/ixx-bluesky repos should emulate the responses we get from the server, not the original config files.

I think instead of baking in server behaviour to the client, in tests we should either:

  • mock responses from the server.
  • directly mock the result of get_file_contents instead of forcing the behaviour of reading the file system, model_validateing and returning the result.

Probably we will want to do both in different places.

I agree that a framework to make this easy and consistent would be nice

Comment on lines -195 to -197
if the config file isn't in the FILE_TO_CONVERTER_MAP at all. This
should only be used for testing or when waiting on a release that will
add the file to the FILE_TO_CONVERTER_MAP.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you removed these lines from the docstring? I think they still apply

@oliwenmandiamond

oliwenmandiamond commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Echoing my comments on the dodal PR, I don't think we should add behaviour to do conversion into a mock client. The client receives converted data from the server, and any test data in dodal/ixx-bluesky repos should emulate the responses we get from the server, not the original config files.

I think instead of baking in server behaviour to the client, in tests we should either:

* mock responses from the server.

* directly mock the result of `get_file_contents` instead of forcing the behaviour of reading the file system, `model_validate`ing and returning the result.

Probably we will want to do both in different places.

I agree that a framework to make this easy and consistent would be nice

After discussing IRL, I understand what you mean now and implemented this. I've adjust the code, tests and docs to reflect this. So now the mock client only mocks the server response and doesn't try to implement server conversion logic. Instead, we just provide optional configuration of the path with the associated data we should get back when in mock mode.

Please take another look and review. Thanks!

@oliwenmandiamond oliwenmandiamond requested a review from jacob720 July 1, 2026 14:33
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.

Allow ConfigClient to be mocked in a standard way

2 participants