File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ module Util
2727 '.htm' => 'text/html' ,
2828 '.html' => 'text/html' ,
2929 '.zip' => 'application/zip' ,
30+ '.epub' => 'application/epub+zip' ,
3031 '.swf' => 'application/x-shockwave-flash'
3132 } . freeze
3233
Original file line number Diff line number Diff line change 1+ # test/test_google_drive_export.rb
2+
3+ $LOAD_PATH. unshift ( File . dirname ( __FILE__ ) + '/../lib' )
4+ require 'yaml'
5+
6+ require 'rubygems'
7+ require 'bundler/setup'
8+ require 'highline'
9+ require 'test/unit'
10+
11+ require 'google_drive'
12+ require_relative 'test_helper'
13+
14+ class TestGoogleDriveExport < Test ::Unit ::TestCase
15+ include ( SessionHelper )
16+
17+ def test_upload_and_download
18+ session = get_session
19+ return unless auth_type == AuthType ::USER_ACCOUNT
20+ test_file_path = File . join ( File . dirname ( __FILE__ ) , 'test_file.txt' )
21+ test_file_title = 'test_file_123.txt'
22+ file = session . upload_from_file (
23+ test_file_path , test_file_title , convert : true
24+ )
25+ assert { file . is_a? ( GoogleDrive ::File ) }
26+ assert { file . title == "test_file_123" }
27+ assert { file . available_content_types == [ ] }
28+ assert { file . mime_type == 'application/vnd.google-apps.document' }
29+ download_path = File . join ( File . dirname ( __FILE__ ) , 'sample-epub-file-dl.epub' )
30+ file . export_as_file ( download_path )
31+ assert { File . exist? ( download_path ) }
32+ File . delete ( download_path )
33+ end
34+ end
You can’t perform that action at this time.
0 commit comments