Skip to content

Commit

Permalink
fixed error in the creation of the main backup folder
Browse files Browse the repository at this point in the history
  • Loading branch information
rlunaro committed Feb 10, 2024
1 parent e8572a0 commit 3ffb36a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def setupLogger( logging_dict : dict ):
verificationStrategy= RealVerifyStrategy( config["verifyUploadedFiles"] == "true" ),
reporter= reporter )
log.debug( "done" )
backupFolderId = googleDrive.getOrCreateFolder(config["backupPolicy"]["destinationFolder"])
backupFolderId = googleDrive.getOrCreateFolder(config["backupPolicy"]["destinationFolder"], 'root' )

backupPolicy = BackupPolicy( config["backupPolicy"], today = today_value )

Expand Down
2 changes: 1 addition & 1 deletion src/service_google_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def folderCreate(self, folderName: str, parentFolderId = None ):
'mimeType': 'application/vnd.google-apps.folder',
'parents' : [ parentFolderId ] }
else :
file_metadata = { 'name' : 'backup',
file_metadata = { 'name' : folderName,
'mimeType': 'application/vnd.google-apps.folder' }
file = self._drive_service.files().create(body=file_metadata,
fields='id').execute()
Expand Down
49 changes: 49 additions & 0 deletions test/test_google_drive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'''
Copyright 2024 superman_ha_muerto@yahoo.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@author: rluna
'''
import unittest
import pickle
import os.path

from service_google_drive import ServiceGoogleDrive
from real_verify_strategy import RealVerifyStrategy
from on_memory_reporting_strategy import OnMemoryReportingStrategy


class TestGoogleDrive(unittest.TestCase):


def setUp(self):
with open(os.path.join("..","token.pickle"), "rb") as token:
creds = pickle.load(token)
reporter = OnMemoryReportingStrategy()
self.googleDrive = ServiceGoogleDrive( credentials = creds,
verificationStrategy= RealVerifyStrategy( True ),
reporter= reporter )


def tearDown(self):
pass


def testCreateFolder(self):
backupFolderId = self.googleDrive.getOrCreateFolder( "my_backup_folder" )
self.assertTrue( True )

if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()

0 comments on commit 3ffb36a

Please sign in to comment.