Comment 1 for bug 1165210

Revision history for this message
Leo Arias (elopio) wrote :

<pindonga> elopio, on l. 162, instead of asserting on the attrs, why not mock CreditCardRequest.__new__ and assert it was called with the right kwargs?
<pindonga> you probably need a MagicMock instance for that, but imo it'd be testing what you actually want (which is unwrapping the args before calling __new_ ,right?)
<elopio> pindonga: +1
<elopio> pindonga: magicmock doesn't support __new__. Do you know any alternative?
<pindonga> :( no
<pindonga> plain mock maybe?
<pindonga> never really grokked magicmock
<elopio> pindonga: it says "are not supported as they are either in use by mock, can’t be set dynamically, or can cause problems", so I think it's not really possible to mock __init__ or __new__
<pindonga> elopio, ah
<pindonga> but you don't need to :)
<pindonga> you can mock CreditCardRequest (the class)
<pindonga> and the call assert_called_with
<pindonga> since it's a callable
<pindonga> right?
<pindonga> if not , I'd ask mfoord on monday
<elopio> I think so. I'm trying small changes to see if one works.
<elopio> the things is that if I mock CreditCardRequest, then .from_data_objects will be mocked too.
<elopio> yeah, I can't seem to make it work. I'll better ask mfoord.
<elopio> pindonga: is it ok if I land it with the assertion, and update with the mock later, if possible?
<pindonga> yes, I guess so, if nessita and matiasb agree
<nessita> sounds good
<matiasb> ok for me