-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new retrieve_document_content method
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import annotations | ||
|
||
import httpx | ||
import pytest | ||
|
||
from rossum_api.api_client import Resource | ||
|
||
|
||
@pytest.fixture | ||
def file_data() -> bytes: | ||
with open("tests/data/sample_invoice.pdf", "rb") as f: | ||
return f.read() | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestDocuments: | ||
async def test_retrieve_document_content(self, elis_client, file_data): | ||
client, http_client = elis_client | ||
http_client.request.return_value = httpx.Response(status_code=200, content=file_data) | ||
|
||
document_id = 123 | ||
result = await client.retrieve_document_content(document_id=document_id) | ||
|
||
http_client.request.assert_called_with( | ||
"GET", url=f"{Resource.Document.value}/{document_id}/content" | ||
) | ||
assert result == file_data | ||
|
||
|
||
class TestDocumentsSync: | ||
def test_retrieve_document_content(self, elis_client_sync, file_data): | ||
client, http_client = elis_client_sync | ||
http_client.request.return_value = httpx.Response(status_code=200, content=file_data) | ||
|
||
document_id = 123 | ||
result = client.retrieve_document_content(document_id=document_id) | ||
|
||
http_client.request.assert_called_with( | ||
"GET", url=f"{Resource.Document.value}/{document_id}/content" | ||
) | ||
assert result == file_data |