# 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/gls_fr/rest/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {
#         "shippingDate": date.today(),
#         "customerId": credentials["customerId"],
#         "agencyId": credentials["agencyId"],
#     },
#     "parcels": [{"weight": 1.2, "comment": "Fake comment"}],
#     "to_address": {
#         "name": "Anne O'nyme",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "email": "test@example.com",
#     },
# }
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_FDS = "flexDeliveryService"
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_SHD = "shopdeliveryservice"
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_SRS = "shopreturnservice"


import base64
import copy
import logging
import pytest
import requests
import shutil
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA
from ..constants import SERVICE_FDS
from ..constants import SERVICE_SHD
from ..constants import SERVICE_SRS
    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["service"]["incoterm"] = "00"
    with pytest.raises(CarrierError, match="Incoterm is invalid"):
        result = roulier.get("gls_fr_rest", "get_label", vals)


def test_FDS():
    vals = copy.deepcopy(DATA)
    vals["parcels"][0]["services"] = [{"product": SERVICE_FDS}]
    result = roulier.get("gls_fr_rest", "get_label", vals)
    assert_result(vals, result, 1, 0)


def test_SHD():
    vals = copy.deepcopy(DATA)
    vals["to_address"]["contact"] = "Dylann"
    vals["parcels"][0]["services"] = [
        {"product": SERVICE_SHD, "pickupLocationId": "2500389381"}
    ]
    result = roulier.get("gls_fr_rest", "get_label", vals)
    assert_result(vals, result, 1, 0)


def test_SHD_auto():
    vals = copy.deepcopy(DATA)
    vals["to_address"]["contact"] = "Dylann"

# 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/gls_fr/rest/tests/data.py
# DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
#     "service": {
#         "shippingDate": date.today(),
#         "customerId": credentials["customerId"],
#         "agencyId": credentials["agencyId"],
#     },
#     "parcels": [{"weight": 1.2, "comment": "Fake comment"}],
#     "to_address": {
#         "name": "Anne O'nyme",
#         "street1": "27 rue Léon CAMET",
#         "city": "Villeurbanne",
#         "country": "FR",
#         "zip": "69100",
#         "email": "test@example.com",
#     },
# }
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_FDS = "flexDeliveryService"
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_SHD = "shopdeliveryservice"
# 
# Path: roulier/carriers/gls_fr/rest/constants.py
# SERVICE_SRS = "shopreturnservice"


# Path: roulier/carriers/gls_fr/rest/tests/test_rest.py
import base64
import copy
import logging
import pytest
import requests
import shutil
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA
from ..constants import SERVICE_FDS
from ..constants import SERVICE_SHD
from ..constants import SERVICE_SRS

    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["service"]["incoterm"] = "00"
    with pytest.raises(CarrierError, match="Incoterm is invalid"):
        result = roulier.get("gls_fr_rest", "get_label", vals)


def test_FDS():
    vals = copy.deepcopy(DATA)
    vals["parcels"][0]["services"] = [{"product": SERVICE_FDS}]
    result = roulier.get("gls_fr_rest", "get_label", vals)
    assert_result(vals, result, 1, 0)


def test_SHD():
    vals = copy.deepcopy(DATA)
    vals["to_address"]["contact"] = "Dylann"
    vals["parcels"][0]["services"] = [
        {"product": SERVICE_SHD, "pickupLocationId": "2500389381"}
    ]
    result = roulier.get("gls_fr_rest", "get_label", vals)
    assert_result(vals, result, 1, 0)


def test_SHD_auto():
    vals = copy.deepcopy(DATA)
    vals["to_address"]["contact"] = "Dylann"

    vals["parcels"][0]["services"] = [{"product": SERVICE_SHD}]