-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add missing mock for locate_oc_binary method #3944
Add missing mock for locate_oc_binary method #3944
Conversation
Can one of the admins verify this patch?
|
Can one of the admins verify this patch?
|
Interesting.
We get the That's mocked and is set up as having side effects. The locate_oc_binary() function must be called multiple times. As there is only 1 side effect set on the mock locater any additional calls to it would fail. Maybe instead of using side effects you set the |
When locate_oc_binary has not been mocked, the test suite fails when oc executable is available.
I didn't notice the method was called twice, thanks ! |
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.
Please use return_value
instead.
@@ -245,6 +246,11 @@ def test_state_present(self, mock_cmd, mock_tmpfile_copy, mock_write): | |||
'/tmp/mocked_kubeconfig', | |||
] | |||
|
|||
mock_oc_binary.side_effect = [ |
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.
For these mock_oc_binary
s I think it's safer to simply assign oc
to their return_value
property. Can you swap these to use return_value
instead? That will save us from any pain in the future if the code base changes again and the number of calls changes. return_value
will always return just that one value. side_effect
on an iterator will run out of values (as we saw before).
mock_oc_binary.return_value = 'oc'
side_effect
is good at what it does, returning items from an iterable or anything from a function, but it's a little too much for this use-case.
Thanks to Tim Bielawa for pointing it out.
@tbielawa done ( |
aos-ci-test |
[test] |
/me wipes the flakes off this one openshift/origin#13846 |
re[test] |
Evaluated for openshift ansible test up to 93a979a |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/64/) (Base Commit: 307bc94) |
Same failure, meanwhile a fix for the failing test (#3966) was merged. Should I rebase this pull-request ? |
@pilou- I am not sure if that would do anything. I am going to poke @sdodson here and ask for advice. I think in this mornings team meeting Scott was saying we're waiting for a repository to update, but I'm not sure if that would effect this, or if a change that @mtnbikenc is working on is required as well.. @sdodson @mtnbikenc please advise 😻 |
should be fixed now |
Evaluated for openshift ansible merge up to 93a979a |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/269/) (Base Commit: 662aac5) |
When
locate_oc_binary
has not been mocked, the test suite fails whenoc
executable is available.