digitalsimboja | Hello! | 08:59 |
---|---|---|
digitalsimboja | @maysams, @dulek: Please help check what am not getting right here | 09:00 |
opendevreview | Roman Dobosz proposed openstack/kuryr-kubernetes master: Change documentation for devstack deployment. https://review.opendev.org/c/openstack/kuryr-kubernetes/+/801265 | 09:00 |
digitalsimboja | I defined ad tags | 09:00 |
digitalsimboja | https://paste.opendev.org/show/807580/ | 09:00 |
digitalsimboja | I am calling the add_tags here | 09:02 |
digitalsimboja | https://paste.opendev.org/show/807581/ | 09:02 |
digitalsimboja | i get this error | 09:02 |
digitalsimboja | 09:03 | |
digitalsimboja | File "/usr/lib/python3.8/unittest/mock.py", line 913, in assert_called_with | 09:03 |
digitalsimboja | raise AssertionError(_error_message()) from cause | 09:03 |
digitalsimboja | 09:03 | |
digitalsimboja | AssertionError: expected call not found. | 09:03 |
digitalsimboja | Expected: ports(status='ACTIVE') | 09:03 |
digitalsimboja | Actual: ports(status='ACTIVE', tags=['foo']) | 09:03 |
digitalsimboja | 09:03 | |
digitalsimboja | 09:03 | |
digitalsimboja | 09:03 | |
digitalsimboja | ====== | 09:03 |
maysams | digitalsimboja: you could use a mock for the lbaasv2 driver and mock the add_tags call and set the return_value | 09:06 |
maysams | instead of defining the function on the test | 09:06 |
maysams | digitalsimboja: maybe something like https://github.com/openstack/kuryr-kubernetes/blob/e8abda8674079699c950c92d180dd8d3299140db/kuryr_kubernetes/tests/unit/controller/drivers/test_lbaasv2.py#L82-L84 | 09:08 |
dulek | digitalsimboja: Looks like you just need to add tags to assertCalledOnceWith in the test or a similar function. | 09:11 |
dulek | The test checks if .ports() were called with particular parameters. As it's now called differently you need to modify the mock check? | 09:11 |
digitalsimboja | Let me take a look and be back | 09:13 |
digitalsimboja | @maysams: I am still getting this | 13:19 |
digitalsimboja | 13:20 | |
digitalsimboja | File "/usr/lib/python3.8/unittest/mock.py", line 637, in __getattr__ | 13:20 |
digitalsimboja | raise AttributeError("Mock object has no attribute %r" % name) | 13:20 |
digitalsimboja | 13:20 | |
digitalsimboja | AttributeError: Mock object has no attribute '_drv_lbaas' | 13:20 |
maysams | hello digitalsimboja | 14:53 |
digitalsimboja | hello | 14:54 |
maysams | can you share the code fragment that is causing such issue? | 14:54 |
digitalsimboja | a second | 14:55 |
digitalsimboja | https://paste.opendev.org/show/807596/ | 14:55 |
digitalsimboja | Keeps reporting attribute error for the instance of the driver defined in the constructor | 15:01 |
gryf | digitalsimboja, perhaps this is side effect of using mock, which has been called and return another mock. i.e. you might forgot to return some expected object using return_value/side_effect attributes. | 15:03 |
digitalsimboja | So I need to set the return_value | 15:05 |
gryf | not sure where, since I've not seen the code you try to test. | 15:08 |
digitalsimboja | Please take a look | 15:09 |
digitalsimboja | https://paste.opendev.org/show/807597/ | 15:10 |
gryf | ok, so this review: https://review.opendev.org/c/openstack/kuryr-kubernetes/+/800707 right? | 15:11 |
digitalsimboja | Yeah sure | 15:12 |
digitalsimboja | Not this in particular but here | 15:15 |
digitalsimboja | https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904 | 15:15 |
digitalsimboja | But same logic almost | 15:16 |
maysams | digitalsimboja: have you tried removing the return_value | 15:17 |
maysams | ? | 15:17 |
digitalsimboja | let me do it | 15:17 |
maysams | or you could just try to create a mock with the driver spec instead | 15:18 |
gryf | in this particular case m_handler in the test, doesn't have attribute _drv_lbaas. At least this is the thing mock is complaining of. | 15:18 |
digitalsimboja | yeah sure | 15:18 |
gryf | and yet, it trying to access it https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904/20/kuryr_kubernetes/controller/handlers/loadbalancer.py#145 | 15:19 |
gryf | which is weird, since you mocked it: m_handler = mock.Mock(spec=h_lb.KuryrLoadBalancerHandler) | 15:20 |
digitalsimboja | I have been on this, honestly its wierd to me | 15:26 |
digitalsimboja | I read that this usually occurs if the reference its defined on the constructor, I have tried what was recomended but did not resolve it | 15:27 |
digitalsimboja | @gryf: I guess mocking the handler would bring in all the classes and methods initialized at the constructor and within the handler class? | 15:39 |
gryf | that's the idea of creating mock with spec. | 15:40 |
gryf | although at some point you got this attribute error, so I'm wondering why. | 15:41 |
opendevreview | Sunday Mgbogu proposed openstack/kuryr-kubernetes master: wip: Loadbalancers reconciliation https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904 | 18:06 |
Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!