Exemplo n.º 1
0
def test_get_depots():
    """Test get_depots function with a mock."""
    with requests_mock.Mocker() as m:
        api_response = open("pydelivengo/tests/assets/get_depots_ok.json", "rb", encoding='utf8').read()
        m.get('https://mydelivengo.laposte.fr/api/v2.4/depots', text=api_response)

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

        assert result == {"data": [
            {"id": 1814183, "id_utilisateur": 22852, "date": "2018-01-15 14:57:51",
             "num_coclico": "2205490", "num_siret": "",
             "bordereaux": [
                 {"id": 1727987, "numero": "0000000001",
                  "nb_pages": 2, "type": 35}]}],
            "recordsFiltered": 1, "recordsTotal": 1}
Exemplo n.º 2
0
def test_get_depots_type_error():
    """Test get_depots when params is not a dictionary."""
    api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
    with pytest.raises(PyDelivengoTypeError):
        # noinspection PyTypeChecker
        api.get_depots(params='lolcatz')