From 1a76e67534e0f69430ce7de7214262e07594c0bd Mon Sep 17 00:00:00 2001 From: Dylann Cordel Date: Wed, 10 Mar 2021 10:44:58 +0100 Subject: [PATCH] add tests for wrong/missing incoterm --- roulier/carriers/gls_fr/rest/api.py | 3 +- roulier/carriers/gls_fr/rest/tests/data.py | 4 +- .../carriers/gls_fr/rest/tests/test_rest.py | 83 +++++++++++++++++++ 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/roulier/carriers/gls_fr/rest/api.py b/roulier/carriers/gls_fr/rest/api.py index a931049..a87c617 100644 --- a/roulier/carriers/gls_fr/rest/api.py +++ b/roulier/carriers/gls_fr/rest/api.py @@ -54,7 +54,8 @@ def _address(self): "mobile": schema["phone"], "incoterm": { "type": "string", - "allowed": ["DDP", "20", "DAP", "40", "50"], + # "regex": r"^\d{2}$", + # "allowed": ["10", "13", 18", "20", "23", "30", "40", "43", "50", "60"], }, } ) diff --git a/roulier/carriers/gls_fr/rest/tests/data.py b/roulier/carriers/gls_fr/rest/tests/data.py index 1638708..57f0ddf 100644 --- a/roulier/carriers/gls_fr/rest/tests/data.py +++ b/roulier/carriers/gls_fr/rest/tests/data.py @@ -27,8 +27,7 @@ }, "parcels": [{"weight": 1.2, "comment": "Fake comment"}], "to_address": { - "name": "Fr", - "firstName": "Hpar", + "name": "Anne O'nyme", "street1": "27 rue Léon CAMET", "city": "Villeurbanne", "country": "FR", @@ -39,7 +38,6 @@ DATA_FROM_ADDR = { "name": "TEST", - "firstName": "AUTOMATIC", "street1": "72 rue Cécile Honxa", "city": "Paris", "country": "FR", diff --git a/roulier/carriers/gls_fr/rest/tests/test_rest.py b/roulier/carriers/gls_fr/rest/tests/test_rest.py index cf7f25d..2799193 100644 --- a/roulier/carriers/gls_fr/rest/tests/test_rest.py +++ b/roulier/carriers/gls_fr/rest/tests/test_rest.py @@ -93,6 +93,89 @@ def test_eu_country(): assert_result(vals, result, 1, 0) +# Test currently disabled because it seems impossible to have a valid incoterm with this API +# and documentation given. GLS-EU France support contacted. Waiting for an answer to fix it +# def test_vat_country_valid(): +# """ +# Test using incoterm for VAT countries +# From https://gls-group.eu/IE/media/downloads/Customer_information_Brexit~1.pdf +# When exporting with GLS to the UK, dispatchers can choosebetween these Incoterms for +# commercial customs clearance: +# •Incoterm 10 (DDP): +# Freight costs, customs clearance costs, customs duties and taxes paid – +# the sender pays all costsincurred, the importer bears no costs. +# •Incoterm 20 (DAP): +# Freight costs paid, customs clearance costs, customs duties and taxes unpaid – +# the sender pays for freight only, the importer bears all other costs. +# •Incoterm 30 (DDP, VAT unpaid): +# Freight costs, customs clearance costs and customs duties paid, taxes unpaid – +# the sender pays for freight, customs clearance costs and customs duties, +# the importer pays for the taxes incurred. +# •Incoterm 40 (DAP, cleared): +# Freight costs and customs clearance costs paid, customs duties and taxes unpaid – +# the sender pays for freight and customs clearance costs, the importer pays customs +# duties and taxes. +# •Incoterm 60 (Pick&ShipService, Pick&ReturnService): +# Freight costs, customs clearance costs, customs duties and taxes paid – +# the customer pays all costs incurred, the importer bears no costs. + +# In future, we will be able to offer additional, cost-effective inco-terms for customs +# clearance of single parcels to the UK. +# •Incoterm 13 (DDP): +# Freight costs, customs clearance costs, customs duties and taxes paid – +# the sender pays all costs incurred, the importer bears no costs. +# •Incoterm 23 (DAP): +# Freight costs paid, customs clearance costs, customs duties and taxes unpaid – +# the sender paysfor freight only, the importer bears all other costs. +# •Incoterm 43 (DAP, cleared): +# Freight costs and customs clear-ance costs paid, customs duties and taxes unpaid – +# the sender pays for freight and customs clearance costs, the importer pays customs +# duties and taxes. +# •Incoterm 18 (DDP, VAT pre-registration): +# Freight costs, cus-toms clearance costs and taxes paid – +# the sender pays all costs incurred, the importer bears no costs. +# For single or various parcels with a goods value of less than GBP 135. +# Here, the import VAT can be paid directly to the British tax authorities. + +# From GLS-Web-API_FR_V01-03.pdf +# •Incoterm 50: +# Marchandise livrée, dédouanement export & import payés, exemption de faible valeur +# autorisation libre. +# """ +# vals = copy.deepcopy(DATA) +# vals["to_address"]["name"] = "Prince" +# vals["to_address"]["street1"] = "Place de Bel-Air" +# vals["to_address"]["zip"] = "1204" +# vals["to_address"]["city"] = "Geneve" +# vals["to_address"]["country"] = "CH" +# vals["to_address"]["incoterm"] = "20" +# result = roulier.get("gls_fr_rest", "get_label", vals) +# assert_result(vals, result, 1, 0) + + +def test_vat_country_missing_icoterm(): + vals = copy.deepcopy(DATA) + vals["to_address"]["name"] = "Prince" + vals["to_address"]["street1"] = "Place de Bel-Air" + vals["to_address"]["zip"] = "1204" + vals["to_address"]["city"] = "Geneve" + vals["to_address"]["country"] = "CH" + with pytest.raises(CarrierError, match="is missing: Incoterm"): + result = roulier.get("gls_fr_rest", "get_label", vals) + + +def test_vat_country_wrong_icoterm(): + vals = copy.deepcopy(DATA) + vals["to_address"]["name"] = "Prince" + vals["to_address"]["street1"] = "Place de Bel-Air" + vals["to_address"]["zip"] = "1204" + vals["to_address"]["city"] = "Geneve" + vals["to_address"]["country"] = "CH" + vals["to_address"]["incoterm"] = "00" + with pytest.raises(CarrierError, match="Field 'incoterm' not valid"): + result = roulier.get("gls_fr_rest", "get_label", vals) + + def test_FDS(): vals = copy.deepcopy(DATA) vals["parcels"][0]["services"] = [{"product": SERVICE_FDS}]