Encapsulate subprocess calls in run() function #107
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#107
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a follow up to the discussion in #97.
I basically did the change above in https://projects.torsion.org/floli/borgmatic/src/branch/run_function but have a hard time mocking the function for the tests.
My main problems at mocking are:
To accept both variants of calling a function with an argument given the default value and the argument not given at all, which are essentially the same.
Previously, some tests mocked
subprocess.check_call
andsubprocess.check_output
. These are now both calls torun(capture_output = False)
orrun(capture_output = True)
. So I need to mock two calls to the same function with different argument sets.Therefore my commit does not include any test changes and thus the tests will fail.
I am happy to make this a WIP pull-request, so at least @witten can contribute.
Best!
Here are some ideas that may help you out with automated testing these changes:
.with_args()
will help you set up separate mocks for each ofrun(capture_output=False)
andrun(capture_output=True)
branches. For instance:I believe that first mock may handle this case:
If not, you can always add an additional mock as well that expects no arguments, e.g.
.with_args()
. (To test the default behavior.)And you're welcome to make a WIP pull request if you like. I'm happy to contribute.
For anyone else looking at this ticket, here's the WIP PR: witten/borgmatic#109
Closing this since the PR is closed, but I'm happy to revisit in the future if you like.