1
1
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2
2
3
- from vcr_unittest import VCRMixin
3
+ import pytest
4
4
5
5
from odoo .addons .base_delivery_carrier_label .tests import carrier_label_case
6
6
7
7
8
- class ChronopostLabelCase (VCRMixin , carrier_label_case .CarrierLabelCase ):
9
- def setUp (self , * args , ** kwargs ):
8
+ class ChronopostLabelCase (carrier_label_case .TestCarrierLabel ):
9
+ @classmethod
10
+ def setUpClass (cls ):
10
11
# need it to be defined before super to avoid failure in _hide_sensitive_data
11
- self .account = False
12
- super ().setUp (* args , ** kwargs )
12
+ cls .account = False
13
+ super ().setUpClass ()
14
+ cls .env = cls .env (context = dict (cls .env .context , tracking_disable = True ))
13
15
# french carrier sender need to be from France
14
- self .picking .company_id .partner_id .write (
15
- {"country_id" : self .env .ref ("base.fr" ).id }
16
+ cls .picking .company_id .partner_id .write (
17
+ {"country_id" : cls .env .ref ("base.fr" ).id }
16
18
)
17
19
# change account and password with valid credentials to regenerate the cassette
18
- self .account = self .env ["carrier.account" ].create (
20
+ cls .account = cls .env ["carrier.account" ].create (
19
21
{
20
22
"name" : "Chronopost Test Account" ,
21
23
"delivery_type" : "chronopost_fr" ,
@@ -25,6 +27,7 @@ def setUp(self, *args, **kwargs):
25
27
}
26
28
)
27
29
30
+ @classmethod
28
31
def _hide_sensitive_data (self , request ):
29
32
password = self .account and self .account .password or "dummy"
30
33
account = self .account and self .account .account or "dummy"
@@ -34,8 +37,12 @@ def _hide_sensitive_data(self, request):
34
37
request .body = body
35
38
return request
36
39
37
- def _get_vcr_kwargs (self , ** kwargs ):
40
+ @classmethod
41
+ @pytest .fixture (scope = "module" )
42
+ def vcr_config (self ):
38
43
return {
44
+ "filter_headers" : ["authorization" ],
45
+ "ignore_localhost" : True ,
39
46
"record_mode" : "once" ,
40
47
"match_on" : ["method" , "path" ],
41
48
"decode_compressed_response" : True ,
0 commit comments