# 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",
#     },
# }
# 
# PACKING_SLIP_DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
# }


import logging
import copy
import base64
import requests
import shutil
import pytest
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA, PACKING_SLIP_DATA
        roulier.get("laposte_fr", "get_packing_slip", vals)

    vals["parcels_numbers"] = ["123", "456"]
    vals["packing_slip_number"] = "123"
    regex = r"'parcels_numbers' must not be present with 'packing_slip_number'"
    with pytest.raises(InvalidApiInput, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)


def test_common_failed_get_packing_slip():
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(PACKING_SLIP_DATA)

    vals["parcels_numbers"] = ["123", "456"]
    regex = r"'id': 50031"  # numéro de colis invalide
    with pytest.raises(CarrierError, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)

    del vals["parcels_numbers"]
    vals["packing_slip_number"] = "0"
    regex = r"'id': 50027"  # not found
    with pytest.raises(CarrierError, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)


def test_common_success_get_packing_slip():
    if _do_not_execute_test_on_remote():
        return
    # first, we need to create a valid parcel number

# 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",
#     },
# }
# 
# PACKING_SLIP_DATA = {
#     "auth": {
#         "login": credentials["login"],
#         "password": credentials["password"],
#         "isTest": credentials["isTest"],
#     },
# }


# Path: roulier/carriers/laposte_fr/tests/test_laposte_basic.py
import logging
import copy
import base64
import requests
import shutil
import pytest
from roulier import roulier
from roulier.exception import InvalidApiInput, CarrierError
from .data import DATA, PACKING_SLIP_DATA

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

    vals["parcels_numbers"] = ["123", "456"]
    vals["packing_slip_number"] = "123"
    regex = r"'parcels_numbers' must not be present with 'packing_slip_number'"
    with pytest.raises(InvalidApiInput, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)


def test_common_failed_get_packing_slip():
    if _do_not_execute_test_on_remote():
        return
    vals = copy.deepcopy(PACKING_SLIP_DATA)

    vals["parcels_numbers"] = ["123", "456"]
    regex = r"'id': 50031"  # numéro de colis invalide
    with pytest.raises(CarrierError, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)

    del vals["parcels_numbers"]
    vals["packing_slip_number"] = "0"
    regex = r"'id': 50027"  # not found
    with pytest.raises(CarrierError, match=regex):
        roulier.get("laposte_fr", "get_packing_slip", vals)


def test_common_success_get_packing_slip():
    if _do_not_execute_test_on_remote():
        return
    # first, we need to create a valid parcel number

    vals = copy.deepcopy(DATA)