Exemplo n.º 1
0
def test_get_envoi():
    """Test get_envoi with pdf"""
    with requests_mock.Mocker() as m:
        api_response = open("pydelivengo/tests/assets/get_envoi_pdf_ok.json",
                            "rb",
                            encoding='utf8').read()
        m.get('https://mydelivengo.laposte.fr/api/v2.4/envois/5306429',
              text=api_response)

        api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
        result = api.get_envoi(5306429, print_pdf=True)

        # Check if 'id', 'plis' and 'documents_supports' are keys of result
        data_keys_set = set(result['data'].keys())
        assert {'id', 'plis', 'documents_supports'}.issubset(data_keys_set)
Exemplo n.º 2
0
def test_get_envoi_missing_parameter():
    """Test get_envoi when envoi_id is none."""
    api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
    with pytest.raises(PyDelivengoTypeError):
        # noinspection PyTypeChecker
        api.get_envoi(envoi_id=None)
Exemplo n.º 3
0
def test_get_envoi_type_error():
    """Test get_envoi when params is not a dictionary."""
    api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
    with pytest.raises(PyDelivengoTypeError):
        # noinspection PyTypeChecker
        api.get_envoi(123, params='lolcatz')