def test_get_envois():
    """Test get_envois with a mock."""
    with requests_mock.Mocker() as m:
        api_response = open("pydelivengo/tests/assets/get_envois_ok.json",
                            "rb",
                            encoding='utf8').read()
        m.get('https://mydelivengo.laposte.fr/api/v2.4/envois',
              text=api_response)

        api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
        result = api.get_envois()

        assert result == {
            "data": [{
                "id": "5256598",
                "id_support": "33",
                "id_utilisateur": "22852",
                "date_creation": "2018-01-18 10:48:37",
                "date_impression": "2018-01-18 10:48:37",
                "descriptif": "DESCRIPTIF DELIVENGO SUIVI 18",
                "total": "2",
                "plis": ["11349969", "11349970"]
            }],
            "recordsFiltered":
            1,
            "recordsTotal":
            1
        }
def test_get_envois_type_error():
    """Test get_envois when params is not a dictionary."""
    api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
    with pytest.raises(PyDelivengoTypeError):
        # noinspection PyTypeChecker
        api.get_envois(params='lolcatz')