<s> import pytest <EOL> import os <EOL> from urllib . parse import quote <EOL> from waterbutler . providers . googledrive . provider import GoogleDrivePath <EOL> from waterbutler . providers . googledrive . provider import GoogleDrivePathPart <EOL> from waterbutler . providers . googledrive . metadata import GoogleDriveRevision <EOL> from waterbutler . providers . googledrive . metadata import GoogleDriveFileMetadata <EOL> from waterbutler . providers . googledrive . metadata import GoogleDriveFolderMetadata <EOL> from tests . providers . googledrive import fixtures <EOL> @ pytest . fixture <EOL> def basepath ( ) : <EOL> return GoogleDrivePath ( '<STR_LIT>' ) <EOL> def test_file_metadata_drive ( basepath ) : <EOL> item = fixtures . list_file [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> path = basepath . child ( item [ '<STR_LIT:title>' ] ) <EOL> parsed = GoogleDriveFileMetadata ( item , path ) <EOL> assert parsed . provider == '<STR_LIT>' <EOL> assert parsed . id == item [ '<STR_LIT:id>' ] <EOL> assert path . name == item [ '<STR_LIT:title>' ] <EOL> assert parsed . name == item [ '<STR_LIT:title>' ] <EOL> assert parsed . size == item [ '<STR_LIT>' ] <EOL> assert parsed . modified == item [ '<STR_LIT>' ] <EOL> assert parsed . content_type == item [ '<STR_LIT>' ] <EOL> assert parsed . extra == { '<STR_LIT>' : item [ '<STR_LIT:version>' ] , '<STR_LIT>' : item [ '<STR_LIT>' ] } <EOL> assert parsed . path == '<STR_LIT:/>' + os . path . join ( * [ x . raw for x in path . parts ] ) <EOL> assert parsed . materialized_path == str ( path ) <EOL> assert parsed . is_google_doc == False <EOL> assert parsed . export_name == item [ '<STR_LIT:title>' ] <EOL> def test_file_metadata_drive_slashes ( basepath ) : <EOL> item = fixtures . file_forward_slash <EOL> path = basepath . child ( item [ '<STR_LIT:title>' ] ) <EOL> parsed = GoogleDriveFileMetadata ( item , path ) <EOL> assert parsed . provider == '<STR_LIT>' <EOL> assert parsed . id == item [ '<STR_LIT:id>' ] <EOL> assert parsed . name == item [ '<STR_LIT:title>' ] <EOL> assert parsed . name == path . name <EOL> assert parsed . size == item [ '<STR_LIT>' ] <EOL> assert parsed . modified == item [ '<STR_LIT>' ] <EOL> assert parsed . content_type == item [ '<STR_LIT>' ] <EOL> assert parsed . extra == { '<STR_LIT>' : item [ '<STR_LIT:version>' ] , '<STR_LIT>' : item [ '<STR_LIT>' ] } <EOL> assert parsed . path == '<STR_LIT:/>' + os . path . join ( * [ x . raw for x in path . parts ] ) <EOL> assert parsed . materialized_path == str ( path ) <EOL> assert parsed . is_google_doc == False <EOL> assert parsed . export_name == item [ '<STR_LIT:title>' ] <EOL> def test_file_metadata_docs ( basepath ) : <EOL> item = fixtures . docs_file_metadata <EOL> path = basepath . child ( item [ '<STR_LIT:title>' ] ) <EOL> parsed = GoogleDriveFileMetadata ( item , path ) <EOL> assert parsed . name == item [ '<STR_LIT:title>' ] + '<STR_LIT>' <EOL> assert parsed . extra == { '<STR_LIT>' : item [ '<STR_LIT:version>' ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : item [ '<STR_LIT>' ] } <EOL> assert parsed . is_google_doc == True <EOL> assert parsed . export_name == item [ '<STR_LIT:title>' ] + '<STR_LIT>' <EOL> def test_folder_metadata ( ) : <EOL> item = fixtures . folder_metadata <EOL> path = GoogleDrivePath ( '<STR_LIT>' ) . child ( item [ '<STR_LIT:title>' ] , folder = True ) <EOL> parsed = GoogleDriveFolderMetadata ( item , path ) <EOL> assert parsed . provider == '<STR_LIT>' <EOL> assert parsed . id == item [ '<STR_LIT:id>' ] <EOL> assert parsed . name == item [ '<STR_LIT:title>' ] <EOL> assert parsed . extra == { '<STR_LIT>' : item [ '<STR_LIT:version>' ] } <EOL> assert parsed . path == '<STR_LIT:/>' + os . path . join ( * [ x . raw for x in path . parts ] ) + '<STR_LIT:/>' <EOL> assert parsed . materialized_path == str ( path ) <EOL> def test_folder_metadata_slash ( ) : <EOL> item = fixtures . folder_metadata_forward_slash <EOL> path = GoogleDrivePath ( '<STR_LIT>' ) . child ( item [ '<STR_LIT:title>' ] , folder = True ) <EOL> parsed = GoogleDriveFolderMetadata ( item , path ) <EOL> assert parsed . provider == '<STR_LIT>' <EOL> assert parsed . id == item [ '<STR_LIT:id>' ] <EOL> assert parsed . name == item [ '<STR_LIT:title>' ] <EOL> assert parsed . extra == { '<STR_LIT>' : item [ '<STR_LIT:version>' ] } <EOL> assert parsed . path == '<STR_LIT:/>' + os . path . join ( * [ x . raw for x in path . parts ] ) + '<STR_LIT:/>' <EOL> assert parsed . materialized_path == str ( path ) <EOL> def test_revision_metadata ( ) : <EOL> item = fixtures . revision_metadata <EOL> parsed = GoogleDriveRevision ( item ) <EOL> assert parsed . version_identifier == '<STR_LIT>' <EOL> assert parsed . version == item [ '<STR_LIT:id>' ] <EOL> assert parsed . modified == item [ '<STR_LIT>' ] </s>
