@@ -588,6 +588,7 @@ class TestDownload:
588588 ds .DRIVE_IGNORE_VERSION )
589589
590590 GDOC_EXPORT_MIME_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
591+ GDOC_ALT_EXPORT_MIME_TYPE = 'application/pdf'
591592
592593 @pytest .mark .asyncio
593594 @pytest .mark .aiohttpretty
@@ -619,6 +620,36 @@ async def test_download_editable_gdoc_no_revision(self, provider, sharing_fixtur
619620 assert aiohttpretty .has_call (method = 'GET' , uri = revisions_url )
620621 assert aiohttpretty .has_call (method = 'GET' , uri = download_file_url )
621622
623+ @pytest .mark .asyncio
624+ @pytest .mark .aiohttpretty
625+ async def test_download_editable_gdoc_as_mfr (self , provider , sharing_fixtures ):
626+ metadata_body = sharing_fixtures ['editable_gdoc' ]['metadata' ]
627+ path = GoogleDrivePath (
628+ '/sharing/editable_gdoc' ,
629+ _ids = ['1' , '2' , metadata_body ['id' ]]
630+ )
631+
632+ metadata_query = provider ._build_query (path .identifier )
633+ metadata_url = provider .build_url ('files' , path .identifier )
634+ aiohttpretty .register_json_uri ('GET' , metadata_url , body = metadata_body )
635+
636+ revisions_body = sharing_fixtures ['editable_gdoc' ]['revisions' ]
637+ revisions_url = provider .build_url ('files' , metadata_body ['id' ], 'revisions' )
638+ aiohttpretty .register_json_uri ('GET' , revisions_url , body = revisions_body )
639+
640+ file_content = b'we love you conrad'
641+ download_file_url = metadata_body ['exportLinks' ][self .GDOC_ALT_EXPORT_MIME_TYPE ]
642+ aiohttpretty .register_uri ('GET' , download_file_url , body = file_content , auto_length = True )
643+
644+ result = await provider .download (path , mfr = 'true' )
645+ assert result .name == 'editable_gdoc.pdf'
646+
647+ content = await result .read ()
648+ assert content == file_content
649+ assert aiohttpretty .has_call (method = 'GET' , uri = metadata_url )
650+ assert aiohttpretty .has_call (method = 'GET' , uri = revisions_url )
651+ assert aiohttpretty .has_call (method = 'GET' , uri = download_file_url )
652+
622653 @pytest .mark .asyncio
623654 @pytest .mark .aiohttpretty
624655 async def test_download_editable_gdoc_good_revision (self , provider , sharing_fixtures ):
@@ -1577,6 +1608,19 @@ async def test_intra_copy_file(self, provider, root_provider_fixtures):
15771608
15781609class TestOperationsOrMisc :
15791610
1611+ def test_misc_utils (self ):
1612+ metadata = {
1613+ 'mimeType' : 'application/vnd.google-apps.drawing' ,
1614+ 'exportLinks' : {
1615+ 'image/jpeg' : 'badurl.osf.899'
1616+ }
1617+ }
1618+ ext = drive_utils .get_alt_download_extension (metadata )
1619+ link = drive_utils .get_alt_export_link (metadata )
1620+
1621+ assert ext == '.jpg'
1622+ assert link == 'badurl.osf.899'
1623+
15801624 @pytest .mark .asyncio
15811625 @pytest .mark .aiohttpretty
15821626 async def test_can_duplicate_names (self , provider ):
0 commit comments