def testGetBackupsDiff_RemoveOldBackups(self):
     '''
     makes sure that function VMExplorerFtpBackup.getBackupsDiff can create correctly a diff between 2 backups
     so that this function can be used for getting a backup dic containing backups that needs to be deleted, because
     they are already present in the ftp
     '''
     localBackups = {
         'Bart' :   {
             dateFromString('21/11/2006 16:30') : [ 'bartFile1.txt','bartFile1.2.txt'],
             dateFromString('21/11/2006 16:31') : [ 'bartFile2','file.txt2.2']
         },
         'Raoul' :  {
             dateFromString('21/11/2016 16:36') :  [ 'raoulFile1,txt']
         }
     }
     remoteBackups = {
         # all the  tree must be deleted!
         'Miro' :   {
             dateFromString('21/11/2046 16:30') : [ 'bartFile1.txt','bartFile1.2.txt'],
             dateFromString('21/11/2045 16:30') : [ 'bartFile2','file.txt2.2']
         },
         'Bart' :  {
             # this backup should NOT be deleted
             dateFromString('21/11/2006 16:31') : [ 'bartFile2','file.txt2.2'],
             # this backup should be deleted
             dateFromString('21/11/2003 16:31') : [ 'bartFile2','file.txt2.2']
         }
     }
     backupsToDelete = backupManager.get_backups_diff(localBackups, remoteBackups)
     self.assertTrue(backupsToDelete != None)
     self.assertTrue(backupsToDelete.has_key('Miro'))
     self.assertTrue(len(backupsToDelete['Miro']) == 2)
     self.assertTrue(backupsToDelete.has_key('Bart'))
     self.assertTrue(len(backupsToDelete['Bart']) == 1)
     self.assertTrue(backupsToDelete['Bart'][dateFromString('21/11/2003 16:31')] != None)
 def testGetBackupsDiff_UploadNewBackups(self):
     '''
     makes sure that function VMExplorerFtpBackup.getBackupsDiff can create correctly a diff between 2 backups
     so that this function can be used for getting a backup dic containing backups that needs to be uploaded on a
     remote ftp server
     '''
     localBackups = {
         'Bart' :   {
             # this backup must NOT be uploaded
             dateFromString('21/11/2006 16:30') : [ 'bartFile1.txt','bartFile1.2.txt'],
             #this backup must be uploaded
             dateFromString('21/11/2006 16:32') : [ 'bartFile2','file.txt2.2']
         },
         'Raoul' :  {
             #this backup should be uploaded
             dateFromString('21/11/2016 16:36') :  [ 'raoulFile1,txt']
         },
         'Miro' :   {
             # this is just a duplicate to make sure that in the diff result this key is not doubled
             dateFromString('21/11/2046 16:30') : [ 'bartFile1.txt','bartFile1.2.txt'],
         }
     }
     remoteBackups = {
         'Miro' :   {
             dateFromString('21/11/2046 16:30') : [ 'bartFile1.txt','bartFile1.2.txt'],
             dateFromString('21/11/2045 16:30') : [ 'bartFile2','file.txt2.2']
         },
         'Bart' :  {
             dateFromString('21/11/2006 16:30') : [ 'bartFile2','file.txt2.2'],
             dateFromString('21/11/2003 16:31') : [ 'bartFile2','file.txt2.2']
         }
     }
     backupToUpload = backupManager.get_backups_diff(remoteBackups, localBackups)
     self.assertTrue(backupToUpload != None)
     self.assertTrue(backupToUpload.has_key('Bart'))
     self.assertTrue(len(backupToUpload['Bart']) == 1)
     self.assertTrue(backupToUpload['Bart'][dateFromString('21/11/2006 16:32')] != None)
     self.assertTrue(backupToUpload.has_key('Raoul'))
     self.assertTrue(len(backupToUpload['Raoul']) == 1)
     self.assertTrue(backupToUpload['Raoul'][dateFromString('21/11/2016 16:36')] != None)