[17.0][MIG] delivery_roulier_chronopost_fr: Migration to 17.0
Depends on:
- [x] https://github.com/OCA/delivery-carrier/pull/828
- [x] https://github.com/OCA/delivery-carrier/pull/827
- [x] https://github.com/OCA/delivery-carrier/pull/826
- [x] https://github.com/OCA/delivery-carrier/pull/829
hello @florian-dacosta can you pls help to test the module? how the test should be run?
hello @florian-dacosta can you pls help to test the module? how the test should be run?
I think the class test should be inheriting carrier_label_case.TestCarrierLabel instead of carrier_label_case.CarrierLabelCase So the test "test_labels" from carrier_label_case.TestCarrierLabel is run. I guess there were some change in base_delivery_carrier_label since the test of delivery_roulier_chronopost_fr were made
@florian-dacosta @ivantodorovich do you have any idea why I have such an error in test:
cls = <class 'odoo.addons.delivery_roulier_chronopost_fr.tests.test_label_chronopost.ChronopostLabelCase'>
@classmethod
def setUpClass(cls):
# need it to be defined before super to avoid failure in _hide_sensitive_data
cls.account = False
> super().setUpClass()
E TypeError: CarrierLabelCase.setUpClass() missing 1 required positional argument: 'self'
odoo/external-src/delivery-carrier/delivery_roulier_chronopost_fr/tests/test_label_chronopost.py:13: TypeError
I can't find a reason. Can you help/advise how to solve that issue?
@florian-dacosta @ivantodorovich do you have any idea why I have such an error in test:
cls = <class 'odoo.addons.delivery_roulier_chronopost_fr.tests.test_label_chronopost.ChronopostLabelCase'> @classmethod def setUpClass(cls): # need it to be defined before super to avoid failure in _hide_sensitive_data cls.account = False > super().setUpClass() E TypeError: CarrierLabelCase.setUpClass() missing 1 required positional argument: 'self' odoo/external-src/delivery-carrier/delivery_roulier_chronopost_fr/tests/test_label_chronopost.py:13: TypeErrorI can't find a reason. Can you help/advise how to solve that issue?
Hello, No idea about this sorry
@yankinmax I think the tests will be fixed by
- [x] https://github.com/OCA/delivery-carrier/pull/861
#861 merged, I restarted the CI jobs
[update] still failing, maybe we need a rebase.
/ocabot migration delivery_roulier_chronopost_fr
@gurneyalex @florian-dacosta
In general, I think we can't base chronopost test on the test from base_delivery_carrier_label.
The reason is that in CarrierLabelCase we create and validate the picking which is sending a request to chronopost service.
This request can't be really mocked.
What I prefer is to have brand new test for chronopost even if it copy-paste of the code.
But, we can at least be sure the mock will be made when we call button_validate.
BTW, I still need your help to finish.
What am I missing with my mock call?
odoo/external-src/delivery-carrier/delivery_roulier_chronopost_fr/tests/test_label_chronopost.py::ChronopostLabelCase::test_roulier_chronopost_fr 2024-07-17 16:54:38,801 1 INFO testdb vcr.cassette: <function VCR._build_before_record_request.<locals>.before_record_request at 0x7161a22cb130>
FAILED
================================================================================================= FAILURES =================================================================================================
______________________________________________________________________________ ChronopostLabelCase.test_roulier_chronopost_fr ______________________________________________________________________________
self = <odoo.addons.delivery_roulier_chronopost_fr.tests.test_label_chronopost.ChronopostLabelCase testMethod=test_roulier_chronopost_fr>
@pytest.mark.default_cassette("test_roulier_chronopost_fr.yaml")
@pytest.mark.block_network
@pytest.mark.vcr
def test_roulier_chronopost_fr(self):
> self.picking.with_context(dummy_account_id=self.account.id).button_validate()
odoo/external-src/delivery-carrier/delivery_roulier_chronopost_fr/tests/test_label_chronopost.py:124:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
odoo/src/addons/stock/models/stock_picking.py:1145: in button_validate
pickings_to_backorder.with_context(cancel_backorder=False)._action_done()
odoo/src/addons/sale_stock/models/stock.py:109: in _action_done
res = super()._action_done()
odoo/src/addons/stock/models/stock_picking.py:985: in _action_done
self._send_confirmation_email()
odoo/src/addons/stock_delivery/models/stock_picking.py:137: in _send_confirmation_email
pick.sudo().send_to_shipper()
odoo/external-src/delivery-carrier/base_delivery_carrier_label/models/stock_picking.py:82: in send_to_shipper
return super().send_to_shipper()
odoo/src/addons/stock_delivery/models/stock_picking.py:183: in send_to_shipper
res = self.carrier_id.send_shipping(self)[0]
odoo/external-src/delivery-carrier/base_delivery_carrier_label/models/delivery_carrier.py:44: in send_shipping
result = self.alternative_send_shipping(pickings)
odoo/external-src/delivery-carrier/delivery_roulier/models/delivery_carrier.py:14: in alternative_send_shipping
return pickings._roulier_generate_labels()
odoo/external-src/delivery-carrier/delivery_roulier/models/stock_picking.py:98: in _roulier_generate_labels
label_info.append(picking.package_ids._generate_labels(picking))
odoo/external-src/delivery-carrier/delivery_roulier/decorator.py:40: in wrapper
return getattr(cls, fun)(*args, **kwargs)
odoo/external-src/delivery-carrier/delivery_roulier/models/stock_quant_package.py:94: in _roulier_generate_labels
response = self._call_roulier_api(picking)
odoo/external-src/delivery-carrier/delivery_roulier/models/stock_quant_package.py:183: in _call_roulier_api
ret = roulier.get(picking.delivery_type, "get_label", payload)
usr/local/lib/python3.10/site-packages/roulier/roulier.py:24: in get
return getattr(carrier_obj, action)(carrier_type, action, *args, **kwargs)
usr/local/lib/python3.10/site-packages/roulier/carrier_action.py:74: in get_label
response = transport.send(payload)
usr/local/lib/python3.10/site-packages/roulier/transport.py:39: in send
response = self.send_request(**request_kwargs)
usr/local/lib/python3.10/site-packages/roulier/transport.py:59: in send_request
return send(url, headers=headers, auth=auth, data=body, **kwargs)
usr/local/lib/python3.10/site-packages/requests/api.py:115: in post
return request("post", url, data=data, json=json, **kwargs)
usr/local/lib/python3.10/site-packages/requests/api.py:59: in request
return session.request(method=method, url=url, **kwargs)
usr/local/lib/python3.10/site-packages/requests/sessions.py:587: in request
resp = self.send(prep, **send_kwargs)
odoo/src/odoo/tests/common.py:319: in <lambda>
lambda s, r, **kwargs: cls._request_handler(s, r, **kwargs),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'odoo.addons.delivery_roulier_chronopost_fr.tests.test_label_chronopost.ChronopostLabelCase'>, s = <requests.sessions.Session object at 0x7161a1f92290>, r = <PreparedRequest [POST]>
kw = {'allow_redirects': True, 'cert': None, 'proxies': OrderedDict(), 'stream': False, ...}
url = URL(scheme='https', netloc='ws.chronopost.fr', path='/shipping-cxf/ShippingServiceWS', query='', fragment='')
@classmethod
def _request_handler(cls, s: Session, r: PreparedRequest, /, **kw):
# allow localhost requests
# TODO: also check port?
url = werkzeug.urls.url_parse(r.url)
if url.host in (HOST, 'localhost'):
return _super_send(s, r, **kw)
if url.scheme == 'file':
return _super_send(s, r, **kw)
_logger.getChild('requests').info(
"Blocking un-mocked external HTTP request %s %s", r.method, r.url)
> raise BlockedRequest(f"External requests verboten (was {r.method} {r.url})")
E odoo.tests.common.BlockedRequest: External requests verboten (was POST https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS)
odoo/src/odoo/tests/common.py:278: BlockedRequest
And tests here won't depend anymore on tests here of course:
- [ ] https://github.com/OCA/delivery-carrier/pull/862
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.