Skip to content

Commit

Permalink
add tests for wrong/missing incoterm
Browse files Browse the repository at this point in the history
  • Loading branch information
DylannCordel committed Mar 10, 2021
1 parent d69141a commit 1a76e67
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 4 deletions.
3 changes: 2 additions & 1 deletion roulier/carriers/gls_fr/rest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
}
)
Expand Down
4 changes: 1 addition & 3 deletions roulier/carriers/gls_fr/rest/tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -39,7 +38,6 @@

DATA_FROM_ADDR = {
"name": "TEST",
"firstName": "AUTOMATIC",
"street1": "72 rue Cécile Honxa",
"city": "Paris",
"country": "FR",
Expand Down
83 changes: 83 additions & 0 deletions roulier/carriers/gls_fr/rest/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down

0 comments on commit 1a76e67

Please sign in to comment.