Skip to content

Commit b27e1d3

Browse files
committed
[IMP] delivery_carrier_label_gls: Improve tests flow
1 parent b193d61 commit b27e1d3

File tree

7 files changed

+83
-40
lines changed

7 files changed

+83
-40
lines changed

delivery_carrier_label_gls/README.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Delivery Carrier Label GLS
33
==========================
44

5-
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
67
!! This file is generated by oca-gen-addon-readme !!
78
!! changes will be overwritten. !!
89
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:06fda2250228b5c5afd09c2a72b1045f9a0c3d98a770787b50dbc78bb50d9ba7
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
912
1013
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1114
:target: https://odoo-community.org/page/development-status
@@ -20,10 +23,10 @@ Delivery Carrier Label GLS
2023
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_carrier_label_gls
2124
:alt: Translate me on Weblate
2225
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
23-
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/delivery-carrier&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=16.0
2427
:alt: Try me on Runboat
2528

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
2730

2831
Integration with GLS shipping webservices.
2932
Documentation:
@@ -73,7 +76,7 @@ Bug Tracker
7376

7477
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
7578
In case of trouble, please check there if your issue has already been reported.
76-
If you spotted it first, help us smashing it by providing a detailed and welcomed
79+
If you spotted it first, help us to smash it by providing a detailed and welcomed
7780
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_carrier_label_gls%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7881

7982
Do not contact contributors directly about support or help with technical issues.

delivery_carrier_label_gls/static/description/index.html

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
54
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
5+
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
76
<title>Delivery Carrier Label GLS</title>
87
<style type="text/css">
98

109
/*
1110
:Author: David Goodger (goodger@python.org)
12-
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
1615
17-
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
16+
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
1918
*/
2019

@@ -366,27 +365,29 @@ <h1 class="title">Delivery Carrier Label GLS</h1>
366365
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367366
!! This file is generated by oca-gen-addon-readme !!
368367
!! changes will be overwritten. !!
368+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369+
!! source digest: sha256:06fda2250228b5c5afd09c2a72b1045f9a0c3d98a770787b50dbc78bb50d9ba7
369370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls"><img alt="OCA/delivery-carrier" src="https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_carrier_label_gls"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/delivery-carrier&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls"><img alt="OCA/delivery-carrier" src="https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_carrier_label_gls"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371372
<p>Integration with GLS shipping webservices.
372373
Documentation:
373374
<a class="reference external" href="http://gls-shipit.gls-group.eu/webservices/2_8_11/doxygen/WS-REST-API/index.html">http://gls-shipit.gls-group.eu/webservices/2_8_11/doxygen/WS-REST-API/index.html</a></p>
374375
<p><strong>Table of contents</strong></p>
375376
<div class="contents local topic" id="contents">
376377
<ul class="simple">
377-
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
378-
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
379-
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
380-
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
381-
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
382-
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
383-
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
378+
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
379+
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
380+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
381+
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
382+
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
383+
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
384+
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
384385
</ul>
385386
</li>
386387
</ul>
387388
</div>
388389
<div class="section" id="configuration">
389-
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
390+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
390391
<p>To start using GLS, you need to configure two types of settings in
391392
<em>Inventory - Configuration- Delivery</em> or <em>Inventory - Configuration - Settings</em>
392393
which leads to the right section in inventory global settings.
@@ -400,7 +401,7 @@ <h1><a class="toc-backref" href="#id1">Configuration</a></h1>
400401
<p>For client integration tests you need to fill your credentials in the tests/common.py.</p>
401402
</div>
402403
<div class="section" id="usage">
403-
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
404+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
404405
<p>Create the packages on GLS which returns a tracking ID.
405406
If there is any kind of mistake (address, weight),
406407
it is possible to cancel it as long as it has not been scanned yet.
@@ -415,24 +416,24 @@ <h1><a class="toc-backref" href="#id2">Usage</a></h1>
415416
next day, and provided with the next report if there is one.</p>
416417
</div>
417418
<div class="section" id="bug-tracker">
418-
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
419+
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
419420
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/delivery-carrier/issues">GitHub Issues</a>.
420421
In case of trouble, please check there if your issue has already been reported.
421-
If you spotted it first, help us smashing it by providing a detailed and welcomed
422+
If you spotted it first, help us to smash it by providing a detailed and welcomed
422423
<a class="reference external" href="https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_carrier_label_gls%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
423424
<p>Do not contact contributors directly about support or help with technical issues.</p>
424425
</div>
425426
<div class="section" id="credits">
426-
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
427+
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
427428
<div class="section" id="authors">
428-
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
429+
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
429430
<ul class="simple">
430431
<li>Acsone</li>
431432
<li>Akretion</li>
432433
</ul>
433434
</div>
434435
<div class="section" id="contributors">
435-
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
436+
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
436437
<ul class="simple">
437438
<li>David Beal &#64; Akretion</li>
438439
<li>Nans Lefebvre &lt;<a class="reference external" href="mailto:nans.lefebvre&#64;acsone.eu">nans.lefebvre&#64;acsone.eu</a>&gt;</li>
@@ -441,7 +442,7 @@ <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
441442
</ul>
442443
</div>
443444
<div class="section" id="maintainers">
444-
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
445+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
445446
<p>This module is maintained by the OCA.</p>
446447
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
447448
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose

delivery_carrier_label_gls/tests/common.py

+31-16
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,7 @@ def _get_gls_carrier_account_vals(cls):
3636
def setUpClass(cls):
3737
super().setUpClass()
3838
cls.company = cls.env.user.company_id
39-
vals_gls_product = {
40-
"default_code": "Code ship GLS",
41-
"type": "service",
42-
"sale_ok": False,
43-
"name": "Name ship GLS",
44-
}
45-
cls.gls_product = cls.env["product.product"].create(vals_gls_product)
46-
vals_gls_carrier_account = cls._get_gls_carrier_account_vals()
47-
cls.gls_carrier_account = cls.env["carrier.account"].create(
48-
vals_gls_carrier_account
49-
)
50-
vals_gls_carrier = cls._get_gls_carrier_vals()
51-
cls.gls_carrier = cls.env["delivery.carrier"].create(vals_gls_carrier)
52-
cls.gls_client = cls.env["delivery.client.gls"].create(
53-
{"carrier_id": cls.gls_carrier.id}
54-
)
39+
5540
vals_product = {"name": "product", "type": "product", "weight": 0.5}
5641
cls.product = cls.env["product.product"].create(vals_product)
5742
vals_partner = {
@@ -69,6 +54,9 @@ def setUpClass(cls):
6954
)
7055
cls.customer_location = cls.env.ref("stock.stock_location_customers")
7156
cls.gls_parcel_shop = "0560005537"
57+
58+
@classmethod
59+
def _create_sale_order(cls):
7260
vals_sale_order = {
7361
"partner_id": cls.partner.id,
7462
"gls_parcel_shop": cls.gls_parcel_shop,
@@ -82,6 +70,33 @@ def setUpClass(cls):
8270
}
8371
cls.order_line = cls.env["sale.order.line"].create(vals_order_line)
8472

73+
@classmethod
74+
def _create_gls_account(cls):
75+
vals_gls_carrier_account = cls._get_gls_carrier_account_vals()
76+
cls.gls_carrier_account = cls.env["carrier.account"].create(
77+
vals_gls_carrier_account
78+
)
79+
80+
@classmethod
81+
def _create_gls_product(cls):
82+
vals_gls_product = {
83+
"default_code": "Code ship GLS",
84+
"type": "service",
85+
"sale_ok": False,
86+
"name": "Name ship GLS",
87+
}
88+
cls.gls_product = cls.env["product.product"].create(vals_gls_product)
89+
90+
@classmethod
91+
def _create_gls_carrier(cls):
92+
cls._create_gls_account()
93+
cls._create_gls_product()
94+
vals_gls_carrier = cls._get_gls_carrier_vals()
95+
cls.gls_carrier = cls.env["delivery.carrier"].create(vals_gls_carrier)
96+
cls.gls_client = cls.env["delivery.client.gls"].create(
97+
{"carrier_id": cls.gls_carrier.id}
98+
)
99+
85100

86101
@contextmanager
87102
def mock_gls_client(mock_client=None):

delivery_carrier_label_gls/tests/test_carrier_constraints.py

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414

1515
class TestCarrierConstraints(TestGLS):
16+
@classmethod
17+
def setUpClass(cls):
18+
super().setUpClass()
19+
cls._create_gls_account()
20+
cls._create_gls_product()
21+
1622
def test_missing_field(self):
1723
for field in gls_required_fields:
1824
values = self._get_gls_carrier_vals()

delivery_carrier_label_gls/tests/test_flow.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88

99
class TestGlsFlow(TestGLS):
10+
@classmethod
11+
def setUpClass(cls):
12+
super().setUpClass()
13+
cls._create_gls_carrier()
14+
cls._create_sale_order()
15+
1016
def test_flow(self):
1117
"""We test the complete flow, since actions depend on each other.
1218
To call cancel, you need to call create before; same with the report.

delivery_carrier_label_gls/tests/test_gls_client.py

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
# and shipping method.
1313
@unittest.skip("gls_client")
1414
class TestGlsClient(TestGLS):
15+
@classmethod
16+
def setUpClass(cls):
17+
super().setUpClass()
18+
cls._create_gls_carrier()
19+
cls._create_sale_order()
20+
1521
@property
1622
def create_payload(self):
1723
return {

delivery_carrier_label_gls/tests/test_partner.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88

99
class TestPartner(TestGLS):
10+
@classmethod
11+
def setUpClass(cls):
12+
super().setUpClass()
13+
cls._create_gls_carrier()
14+
cls._create_sale_order()
15+
1016
def test_belgian_zip(self):
1117
"""Check that we have a string formatting parameter"""
1218
expected = "1367"

0 commit comments

Comments
 (0)