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
DM-32682: Mock out metadata setting in test #142
Conversation
With the task mocked out the metadata values calculated by the task are no longer real values but are themselves MagicMock objects. MagicMock objects can't be stored in a TaskMetadata so instead the run methods for the associator subtasks are explicitly mocked to return usable data for the metadata. This works with PropertySet since that seems to accept the mock value and silently ignores it.
4f756f7
to
e1e0571
Compare
@ktlim I took another look and realized that if I mocked out the |
with patch.multiple( | ||
task, **{task: DEFAULT for task in subtasksToMock + ["apdb"]} | ||
): | ||
with patch('lsst.ap.association.diaPipe.pd.concat', | ||
new=concatMock): | ||
with patch('lsst.ap.association.diaPipe.pd.concat', new=concatMock), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can parenthesize this whole thing, eliminating the need for backslashes. And can you add in the patch.multiple()
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, the parenthesized list may be Python 3.9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually Python 3.10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't merge it with the patch.multiple
because I didn't want to change the indent level of the code I wasn't touching.
With the task mocked out the metadata values calculated
by the task are no longer real values but are themselves
MagicMock objects. MagicMock objects can't be stored in
a TaskMetadata so we need to mock out the API that
sets the metadata.
This works with PropertySet since that seems to accept
the value and silently ignores it.