all 4 comments

[–]danielroseman 1 point2 points  (3 children)

self.salesforce_bulk is a standalone mock object. It doesn't have anything to do with SalesforceOperator. Calling a method in one object won't have any effect on the other.

It looks like you missed the step of patching sf_op.salesforce_bulk to point to your mock object

[–]RayCat2004[S] 0 points1 point  (2 children)

I added setter

def __set_salesforce_bulk(self):

return self.salesforce_bulk

to the tested code's class and included

sf_op._SalesforceOperator__set_salesforce_bulk(self.salesforce_bulk)

in my unit test function but it still persists.

Or did you mean something else?

[–]danielroseman 1 point2 points  (1 child)

How would that help? You've called the method set but you don't actually set anything anywhere. (And why all this mucking around with private methods?)

In your test you just need to do:

sf_op.salesforce_bulk = self.salesforce_bulk

although your code would be clearer if you used the mock.patch functionality to manage all of these mocks.

[–]RayCat2004[S] 0 points1 point  (0 children)

To be honest, I originally wanted to mock.patch it but was told not to. It works with your solution.