@@ -800,6 +800,37 @@ async def test_create_document_pdf_base64_await(async_client, user, collection):
800
800
await Document .objects .all ().adelete ()
801
801
802
802
803
+ async def test_create_document_pdf_base64_long_name_await (
804
+ async_client , user , collection
805
+ ):
806
+ # test_docs/ is a directory in the same level as the test.py file - we will use a sample PDF file from there
807
+
808
+ with open ("api/tests/test_docs/sample.pdf" , "rb" ) as f :
809
+ # convert the file to base64
810
+ base64_string = base64_string = base64 .b64encode (f .read ()).decode ("utf-8" )
811
+
812
+ response = await async_client .post (
813
+ "/documents/upsert-document/" ,
814
+ json = {
815
+ "name" : "VeryLongDocumentName" * 10 ,
816
+ "base64" : base64_string ,
817
+ "wait" : True ,
818
+ },
819
+ headers = {"Authorization" : f"Bearer { user .token } " },
820
+ )
821
+ response_data = response .json ()
822
+ assert response .status_code == 201
823
+ # The URL should now be a pre-signed S3 URL
824
+ assert "s3.amazonaws.com" in response_data ["url" ]
825
+ assert response_data ["id" ] == 1
826
+ assert response_data ["name" ] == "VeryLongDocumentName" * 10
827
+ assert response_data ["metadata" ] == {}
828
+ assert response_data ["num_pages" ] == 1
829
+ assert response_data ["collection_name" ] == "default_collection"
830
+ assert response_data ["pages" ] is None
831
+ await Document .objects .all ().adelete ()
832
+
833
+
803
834
async def test_create_document_pdf_base64_async (async_client , user , collection ):
804
835
# test_docs/ is a directory in the same level as the test.py file - we will use a sample PDF file from there
805
836
0 commit comments