Skip to content

VED-803 Refactor filenameprocessor#929

Merged
JamesW1-NHS merged 44 commits intomasterfrom
VED-803-filenameprocessor
Oct 28, 2025
Merged

VED-803 Refactor filenameprocessor#929
JamesW1-NHS merged 44 commits intomasterfrom
VED-803-filenameprocessor

Conversation

@JamesW1-NHS
Copy link
Contributor

@JamesW1-NHS JamesW1-NHS commented Oct 23, 2025

Summary

  • Routine Change
    As part of code restructuring. 

Refactor the filenameprocessor lambda into lambdas/ and shared/ folders. 

Source files which can move to shared:

logging_decorator
clients
errors (part)

Note to testers: This is a refactoring only. There will be no change in functionality or in logging. Smoke testing required only.

Reviews Required

  • Dev
  • Test
  • Tech Author
  • Product Owner

Review Checklist

ℹ️ This section is to be filled in by the reviewer.

  • I have reviewed the changes in this PR and they fill all or part of the acceptance criteria of the ticket, and the code is in a mergeable state.
  • If there were infrastructure, operational, or build changes, I have made sure there is sufficient evidence that the changes will work.
  • I have ensured the changelog has been updated by the submitter, if necessary.

)
@patch("elasticache.redis_client.hkeys", return_value=["FLU", "RSV"])
def test_validate_file_key(self, mock_hkeys, mock_hget):
def test_validate_file_key(self, mock_get_redis_client):
Copy link
Contributor Author

@JamesW1-NHS JamesW1-NHS Oct 27, 2025

Choose a reason for hiding this comment

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

Why this test has been split into three separate ones:

Since refactoring redis_client, the invalid file key tests were getting assertion errors on hkeys('vacc_to_diseases') not being called. In fact, in file_validation.validate_file_key(), we can see that in these cases the error is raised before elasticache.get_valid_vaccine_types_from_cache() (which sets hkeys) is called at all.

It isn't clear why this ever passed in its original form. I suspect an error in the test configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I believe the problem here is that they are using .subTest but not resetting the mocks. Unlike between whole tests and where you are using a setUp and tearDown to reset the mocks/patches, the problem here is that they are using a for loop with .subTest. Overall, it's not a very useful or reliable assertion or use of mocks.


firehose_client = boto3_client("firehose", region_name=REGION_NAME)
secrets_manager_client = boto3_client("secretsmanager", region_name=REGION_NAME)
lambda_client = boto3_client("lambda", region_name=REGION_NAME)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the file need this Lambda client? I believe we removed any code referring to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're quite right. We used to use it so that one of the lambdas could relaunch itself. We have indeed removed that bit of code, so this can go too.

dlzhry2nhs
dlzhry2nhs previously approved these changes Oct 28, 2025
Copy link
Collaborator

@dlzhry2nhs dlzhry2nhs left a comment

Choose a reason for hiding this comment

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

Looks good - only minor comment relating to removing a client we no longer need.

@JamesW1-NHS JamesW1-NHS mentioned this pull request Oct 28, 2025
7 tasks
@sonarqubecloud
Copy link

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.

2 participants