Skip to content
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

[17.0][MIG] delivery_roulier_chronopost_fr: Migration to 17.0 #830

Closed

Conversation

@yankinmax
Copy link
Contributor Author

hello @florian-dacosta can you pls help to test the module? how the test should be run?

@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier_chronopost_fr branch 2 times, most recently from 72adc94 to 3db06fd Compare June 5, 2024 17:13
@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier_chronopost_fr branch 2 times, most recently from b0ba3ba to 141b8e6 Compare June 18, 2024 09:23
Copy link

@Camille0907 Camille0907 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration technically LGTM

@florian-dacosta
Copy link
Contributor

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

@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier_chronopost_fr branch from 141b8e6 to aae7cf8 Compare July 12, 2024 11:32
@yankinmax
Copy link
Contributor Author

@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
Copy link
Contributor

florian-dacosta commented Jul 15, 2024

@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?

Hello,
No idea about this sorry

@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier_chronopost_fr branch from aae7cf8 to 9ba85e3 Compare July 16, 2024 15:06
@gurneyalex
Copy link
Member

gurneyalex commented Jul 17, 2024

@yankinmax I think the tests will be fixed by

@gurneyalex
Copy link
Member

gurneyalex commented Jul 17, 2024

#861 merged, I restarted the CI jobs

[update] still failing, maybe we need a rebase.

@gurneyalex
Copy link
Member

/ocabot migration delivery_roulier_chronopost_fr

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone Jul 17, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request Jul 17, 2024
34 tasks
@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier_chronopost_fr branch from 9ba85e3 to 67b0dfa Compare July 17, 2024 07:09
@yankinmax
Copy link
Contributor Author

yankinmax commented Jul 17, 2024

@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:

Copy link

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.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 17, 2024
@github-actions github-actions bot closed this Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants