# 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/dpd_fr_soap/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {
#         "shippingDate": date.today(),
#         "customerId": credentials["customerId"],
#         "customerCountry": credentials["customerCountry"],
#         "agencyId": credentials["agencyId"],
#         "product": "DPD_Classic",
#         "labelFormat": "PDF",
#     },
#     "parcels": [{"weight": 1.2, "comment": "Fake comment"}],
#     "from_address": {
#         "name": "Fr",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "phone": "+330123456789",
#     },
#     "to_address": {
#         "name": "Fr",
#         "firstName": "Hpar",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "email": "test@example.com",
#     },
# }
# 
# MY_IP_IS_ALLOWED = credentials.get("my_IP_is_allowed", False)


import logging
import copy
import re
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA, MY_IP_IS_ALLOWED
logger = logging.getLogger(__name__)


EXCEPTION_MESSAGE = "Failed call with parameters %s"


def _test_ip_allowed(REQUIRE_ALLOWED=True):
    def canceled_test():
        if REQUIRE_ALLOWED:
            msg = "%s canceled because your IP is not allowed by DPD"
        else:
            msg = "%s canceled because your IP is allowed by DPD"
        logger.info(msg)

    def decorator(test):
        return test if MY_IP_IS_ALLOWED == REQUIRE_ALLOWED else canceled_test

    return decorator


def test_methods():
    assert (
        "dpd_fr_soap" in roulier.get_carriers_action_available().keys()
    ), "DPD carrier unavailable"
    assert roulier.get_carriers_action_available()["dpd_fr_soap"] == [
        "get_label",
    ], "get_label() method unavailable"


def test_label_basic_checks():

# 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/dpd_fr_soap/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {
#         "shippingDate": date.today(),
#         "customerId": credentials["customerId"],
#         "customerCountry": credentials["customerCountry"],
#         "agencyId": credentials["agencyId"],
#         "product": "DPD_Classic",
#         "labelFormat": "PDF",
#     },
#     "parcels": [{"weight": 1.2, "comment": "Fake comment"}],
#     "from_address": {
#         "name": "Fr",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "phone": "+330123456789",
#     },
#     "to_address": {
#         "name": "Fr",
#         "firstName": "Hpar",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "email": "test@example.com",
#     },
# }
# 
# MY_IP_IS_ALLOWED = credentials.get("my_IP_is_allowed", False)


# Path: roulier/carriers/dpd_fr_soap/tests/test_dpd.py
import logging
import copy
import re
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA, MY_IP_IS_ALLOWED

logger = logging.getLogger(__name__)


EXCEPTION_MESSAGE = "Failed call with parameters %s"


def _test_ip_allowed(REQUIRE_ALLOWED=True):
    def canceled_test():
        if REQUIRE_ALLOWED:
            msg = "%s canceled because your IP is not allowed by DPD"
        else:
            msg = "%s canceled because your IP is allowed by DPD"
        logger.info(msg)

    def decorator(test):
        return test if MY_IP_IS_ALLOWED == REQUIRE_ALLOWED else canceled_test

    return decorator


def test_methods():
    assert (
        "dpd_fr_soap" in roulier.get_carriers_action_available().keys()
    ), "DPD carrier unavailable"
    assert roulier.get_carriers_action_available()["dpd_fr_soap"] == [
        "get_label",
    ], "get_label() method unavailable"


def test_label_basic_checks():

    vals = copy.deepcopy(DATA)