def test_get_pli(): """Test get_pli when the pdf is requested.""" with requests_mock.Mocker() as m: api_response = open("pydelivengo/tests/assets/get_pli_pdf_ok.json", "rb", encoding='utf8').read() m.get('https://mydelivengo.laposte.fr/api/v2.4/plis/11437479', text=api_response) api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu') result = api.get_pli(11437479, print_pdf=True) # Check if 'id', 'plis' and 'documents_supports' are keys of result data_keys_set = set(result['data'].keys()) assert {'id', 'documents_supports'}.issubset(data_keys_set)
def test_get_pli_missing_parameter(): """Test get_pli when pli_id is none.""" api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu') with pytest.raises(PyDelivengoTypeError): # noinspection PyTypeChecker api.get_pli(pli_id=None)