# Path: roulier/roulier.py
# class RoulierFactory(object):
#     def __init__(self):
#     def register_builder(self, carrier_type, action, Carrierclass):
#     def get(self, carrier_type, action, **kwargs):
# def get(carrier_type, action, *args, **kwargs):
# def get_carriers_action_available():
# 
# Path: roulier/exception.py
# class InvalidApiInput(Exception):
#     """Bad input.
# 
#     Use this class in your application to manage
#     exception with api call
#     """
# 
# class CarrierError(Exception):
#     """Error from WS.
# 
#     Use this class in your application to manage
#     exception with the carrier WS
#     """
# 
#     def __init__(self, response, msg=None):
#         if msg is None:
#             msg = "An error occured with WS"
#         super(CarrierError, self).__init__(msg)
#         self.response = response
#         if self.response:
#             if hasattr(self.response, "text"):
#                 log.debug(response.text)
#             else:
#                 log.debug(response)
# 
# Path: roulier/carriers/laposte_fr/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {"shippingDate": date.today()},
#     "parcels": [{"weight": 1.2, "instructions": "Fake instructions"}],
#     "to_address": {
#         "name": "Fr",
#         "firstName": "Hpar",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#     },
#     "from_address": {
#         "name": "TEST",
#         "firstName": "AUTOMATIC",
#         "street1": "72 rue Cécile Honxa",
#         "city": "Paris",
#         "country": "FR",
#         "zip": "75001",
#     },
# }
# 
# Path: roulier/carriers/laposte_fr/tests/test_laposte_basic.py
# def _do_not_execute_test_on_remote():
#     """Test execution require valid credentials
#     which are not included in commited files.
# 
#     Main tests are only executable in local installation.
#     This method when called allow to escape remote tests
#     """
#     if DATA["auth"]["password"] == "blablabla":
#         return True
#     return False
# 
# Path: roulier/carriers/laposte_fr/tests/test_laposte_basic.py
# def assert_label(result):
#     assert "parcels" in result
#     assert len(result["parcels"]) > 0
#     assert "label" in result["parcels"][0]
#     assert "data" in result["parcels"][0]["label"]
#     return result["parcels"][0]["label"]


import logging
import copy
import pytest
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA
from .test_laposte_basic import _do_not_execute_test_on_remote
from .test_laposte_basic import assert_label
        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOM"
    result = roulier.get("laposte_fr", "get_label", vals)
    label = assert_label(result)
    assert "data" in label


def test_DOS_product():
    """France - Colissimo Domicile - avec signature"""
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOS"
    result = roulier.get("laposte_fr", "get_label", vals)
    label = assert_label(result)
    assert "data" in label


def test_DOM_product_raise():
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOM"
    vals["to_address"]["zip"] = "99999"
    with pytest.raises(
        CarrierError,
        match="Le code pays ou le code postal du destinataire est incorrect "
        "pour le code produit fourni",
    ):

# Path: roulier/roulier.py
# class RoulierFactory(object):
#     def __init__(self):
#     def register_builder(self, carrier_type, action, Carrierclass):
#     def get(self, carrier_type, action, **kwargs):
# def get(carrier_type, action, *args, **kwargs):
# def get_carriers_action_available():
# 
# Path: roulier/exception.py
# class InvalidApiInput(Exception):
#     """Bad input.
# 
#     Use this class in your application to manage
#     exception with api call
#     """
# 
# class CarrierError(Exception):
#     """Error from WS.
# 
#     Use this class in your application to manage
#     exception with the carrier WS
#     """
# 
#     def __init__(self, response, msg=None):
#         if msg is None:
#             msg = "An error occured with WS"
#         super(CarrierError, self).__init__(msg)
#         self.response = response
#         if self.response:
#             if hasattr(self.response, "text"):
#                 log.debug(response.text)
#             else:
#                 log.debug(response)
# 
# Path: roulier/carriers/laposte_fr/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {"shippingDate": date.today()},
#     "parcels": [{"weight": 1.2, "instructions": "Fake instructions"}],
#     "to_address": {
#         "name": "Fr",
#         "firstName": "Hpar",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#     },
#     "from_address": {
#         "name": "TEST",
#         "firstName": "AUTOMATIC",
#         "street1": "72 rue Cécile Honxa",
#         "city": "Paris",
#         "country": "FR",
#         "zip": "75001",
#     },
# }
# 
# Path: roulier/carriers/laposte_fr/tests/test_laposte_basic.py
# def _do_not_execute_test_on_remote():
#     """Test execution require valid credentials
#     which are not included in commited files.
# 
#     Main tests are only executable in local installation.
#     This method when called allow to escape remote tests
#     """
#     if DATA["auth"]["password"] == "blablabla":
#         return True
#     return False
# 
# Path: roulier/carriers/laposte_fr/tests/test_laposte_basic.py
# def assert_label(result):
#     assert "parcels" in result
#     assert len(result["parcels"]) > 0
#     assert "label" in result["parcels"][0]
#     assert "data" in result["parcels"][0]["label"]
#     return result["parcels"][0]["label"]


# Path: roulier/carriers/laposte_fr/tests/test_laposte_europe.py
import logging
import copy
import pytest
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA
from .test_laposte_basic import _do_not_execute_test_on_remote
from .test_laposte_basic import assert_label

        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOM"
    result = roulier.get("laposte_fr", "get_label", vals)
    label = assert_label(result)
    assert "data" in label


def test_DOS_product():
    """France - Colissimo Domicile - avec signature"""
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOS"
    result = roulier.get("laposte_fr", "get_label", vals)
    label = assert_label(result)
    assert "data" in label


def test_DOM_product_raise():
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(DATA)
    vals["service"]["product"] = "DOM"
    vals["to_address"]["zip"] = "99999"
    with pytest.raises(
        CarrierError,
        match="Le code pays ou le code postal du destinataire est incorrect "
        "pour le code produit fourni",
    ):

        roulier.get("laposte_fr", "get_label", vals)