Example #1
0
    def zztest_args_custom_sync_mode(self):
        """
           Test custom sync mode
        """
        gmv_cmd.init_logging()

        # test 1: do imap search

        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-r', 'Since 1-Nov-2011 Before 4-Nov-2011', \
                    '--db-dir','/tmp/new-db-1', self.login]

        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()

        args = gmvlt.parse_args()

        #check args
        self.assertEquals(args['command'], 'sync')
        self.assertEquals(args['type'], 'custom')
        self.assertEquals(args['email'], self.login)
        self.assertEquals(args['passwd'], 'not_seen')
        self.assertEquals(args['oauth'], 'empty')
        self.assertEquals(args['request'], {
            'req': 'Since 1-Nov-2011 Before 4-Nov-2011',
            'type': 'imap'
        })
        self.assertEquals(args['host'], 'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'], '/tmp/new-db-1')

        # test 2: do gmail search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', self.login]

        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()

        args = gmvlt.parse_args()

        #check args
        self.assertEquals(args['command'], 'sync')
        self.assertEquals(args['type'], 'custom')
        self.assertEquals(args['email'], self.login)
        self.assertEquals(args['passwd'], 'not_seen')
        self.assertEquals(args['oauth'], 'empty')
        self.assertEquals(args['request'], {
            'req': 'subject:Chandeleur bis',
            'type': 'gmail'
        })
        self.assertEquals(args['host'], 'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'], '/tmp/new-db-1')
Example #2
0
    def zztest_args_custom_sync_mode(self):
        """
           Test custom sync mode
        """
        gmv_cmd.init_logging()
        
        # test 1: do imap search

        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-r', 'Since 1-Nov-2011 Before 4-Nov-2011', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'Since 1-Nov-2011 Before 4-Nov-2011', 'type': 'imap'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        # test 2: do gmail search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
Example #3
0
    def ztest_password_handling(self):
        """
           Test all credentials handling
        """
        gmv_cmd.init_logging()
        
        # test 1: enter passwd and go to interactive mode

        sys.argv = ['gmvault.py', '--imap-request', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '--email', self.login, \
                    '--passwd', '--interactive', '--db-dir', '/tmp/new-db-1']
    
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : 'a_password'}) #test_mode needed to avoid calling get_pass
    
        self.assertEquals(credential, {'type': 'passwd', 'value': 'a_password'})
        
        # store passwd and re-read it
        sys.argv = ['gmvault.py', '--imap-request', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '--email', self.login, \
                    '--passwd', '--save-passwd', '--db-dir', '/tmp/new-db-1']
        
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : 'a_new_password'})
        
        self.assertEquals(credential, {'type': 'passwd', 'option': 'saved', 'value': 'a_new_password'})
        
        # now read the password
        sys.argv = ['gmvault.py', 'sync', '--imap-req', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '-t', 'custom', \
                    '--passwd', '--db-dir', '/tmp/new-db-1', self.login]
        
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : "don't care"})
        
        self.assertEquals(credential, {'type': 'passwd', 'option': 'read', 'value': 'a_new_password'})
Example #4
0
    def ztest_password_handling(self):
        """
           Test all credentials handling
        """
        gmv_cmd.init_logging()
        
        # test 1: enter passwd and go to interactive mode

        sys.argv = ['gmvault.py', '--imap-request', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '--email', self.login, \
                    '--passwd', '--interactive', '--db-dir', '/tmp/new-db-1']
    
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : 'a_password'}) #test_mode needed to avoid calling get_pass
    
        self.assertEquals(credential, {'type': 'passwd', 'value': 'a_password'})
        
        # store passwd and re-read it
        sys.argv = ['gmvault.py', '--imap-request', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '--email', self.login, \
                    '--passwd', '--save-passwd', '--db-dir', '/tmp/new-db-1']
        
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : 'a_new_password'})
        
        self.assertEquals(credential, {'type': 'passwd', 'option': 'saved', 'value': 'a_new_password'})
        
        # now read the password
        sys.argv = ['gmvault.py', 'sync', '--imap-req', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '-t', 'custom', \
                    '--passwd', '--db-dir', '/tmp/new-db-1', self.login]
        
        gmvault_launcher = gmv_cmd.GMVaultLauncher()
        
        args = gmvault_launcher.parse_args()
        
        credential = gmvault_launcher.get_credential(args, test_mode = {'activate': True, 'value' : "don't care"})
        
        self.assertEquals(credential, {'type': 'passwd', 'option': 'read', 'value': 'a_new_password'})
Example #5
0
    def ztest_delete_sync_gmv(self):
        """
           delete sync via command line
        """
        gmv_cmd.init_logging()

        #first request to have the extra dirs
        sys.argv = ['gmvault.py', '--imap-server', 'imap.gmail.com', \
                    '--imap-port', '993', '--imap-request', \
                    'Since 1-Nov-2011 Before 7-Nov-2011', \
                    '--email', self.login, \
                    '--passwd', self.passwd, '--db-dir', '/tmp/new-db-1']

        gmvault_launcher = gmv_cmd.GMVaultLauncher()

        args = gmvault_launcher.parse_args()

        gmvault_launcher.run(args)

        #second requests so all files after the 5 should disappear
        sys.argv = ['gmvault.py', '--imap-server', 'imap.gmail.com', \
                    '--imap-port', '993', '--imap-request', \
                    'Since 1-Nov-2011 Before 5-Nov-2011', '--email', self.login, \
                    '--passwd', self.passwd, '--db-dir', '/tmp/new-db-1', '--db-cleaning', 'yes']

        args = gmvault_launcher.parse_args()
        gmvault_launcher.run(args)

        #check all stored gmail ids
        gstorer = gmvault.GmailStorer(args['db-dir'])

        ids = gstorer.get_all_existing_gmail_ids()

        self.assertEquals(len(ids), 5)

        self.assertEquals(ids, {1384403887202624608L: '2011-11', \
                                1384486067720566818L: '2011-11', \
                                1384313269332005293L: '2011-11', \
                                1384545182050901969L: '2011-11', \
                                1384578279292583731L: '2011-11'})
Example #6
0
 def ztest_delete_sync_gmv(self):
     """
        delete sync via command line
     """
     gmv_cmd.init_logging()
     
     #first request to have the extra dirs
     sys.argv = ['gmvault.py', '--imap-server', 'imap.gmail.com', \
                 '--imap-port', '993', '--imap-request', \
                 'Since 1-Nov-2011 Before 7-Nov-2011', \
                 '--email', self.login, \
                 '--passwd', self.passwd, '--db-dir', '/tmp/new-db-1']
 
     gmvault_launcher = gmv_cmd.GMVaultLauncher()
     
     args = gmvault_launcher.parse_args()
 
     gmvault_launcher.run(args)
     
     #second requests so all files after the 5 should disappear 
     sys.argv = ['gmvault.py', '--imap-server', 'imap.gmail.com', \
                 '--imap-port', '993', '--imap-request', \
                 'Since 1-Nov-2011 Before 5-Nov-2011', '--email', self.login, \
                 '--passwd', self.passwd, '--db-dir', '/tmp/new-db-1', '--db-cleaning', 'yes']
 
     args = gmvault_launcher.parse_args()
     gmvault_launcher.run(args)
 
     #check all stored gmail ids
     gstorer = gmvault.GmailStorer(args['db-dir'])
     
     ids = gstorer.get_all_existing_gmail_ids()
     
     self.assertEquals(len(ids), 5)
     
     self.assertEquals(ids, {1384403887202624608L: '2011-11', \
                             1384486067720566818L: '2011-11', \
                             1384313269332005293L: '2011-11', \
                             1384545182050901969L: '2011-11', \
                             1384578279292583731L: '2011-11'})
Example #7
0
    def ztest_commandline_args(self):
        """
           Test commandline args
        """
        gmv_cmd.init_logging()
        
        # test 1: default
        sys.argv = ['gmvault.py', 'sync', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'full')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'ALL', 'type': 'imap'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'%s/gmvault-db' % (os.environ['HOME']))
            
        
        # test 2: do imap search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-r', 'Since 1-Nov-2011 Before 4-Nov-2011', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'Since 1-Nov-2011 Before 4-Nov-2011', 'type': 'imap'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        # test 2: do gmail search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        #test3 emails only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--emails-only', self.login]
        
        #with emails only
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['emails_only'], True)
        self.assertEquals(args['chats_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        #test chats only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--chats-only', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['chats_only'], True)
        self.assertEquals(args['emails_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        self.assertEquals(args['ownership_control'], True)
        self.assertEquals(args['compression'], True)
        self.assertEquals(args['debug'], False)
        self.assertEquals(args['restart'], False)
 
 
        #test5 chats only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--check-db', 'no', '--resume', '--debug',\
                    '--no-compression', self.login]
        
        #with emails only
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['chats_only'], False)
        self.assertEquals(args['emails_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        self.assertEquals(args['compression'], False)
        self.assertEquals(args['debug'], True)
        self.assertEquals(args['restart'], True)
Example #8
0
    def test_commandline_args(self):
        """
           Test commandline args
        """
        gmv_cmd.init_logging()
        
        # test 1: default
        sys.argv = ['gmvault.py', 'sync', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'full')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'ALL', 'type': 'imap'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'%s/gmvault-db' % (os.environ['HOME']))
            
        
        # test 2: do imap search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-r', 'Since 1-Nov-2011 Before 4-Nov-2011', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'Since 1-Nov-2011 Before 4-Nov-2011', 'type': 'imap'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        # test 2: do gmail search
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', self.login]
        
        #do same as in bootstrap
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        #test3 emails only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--emails-only', self.login]
        
        #with emails only
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['emails_only'], True)
        self.assertEquals(args['chats_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        
        #test chats only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--chats-only', self.login]
        
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['chats_only'], True)
        self.assertEquals(args['emails_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], True)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        self.assertEquals(args['ownership_control'], True)
        self.assertEquals(args['compression'], True)
        self.assertEquals(args['debug'], False)
        self.assertEquals(args['restart'], False)
 
 
        #test5 chats only
        sys.argv = ['gmvault.py', 'sync','-t', 'custom',
                    '-g', 'subject:Chandeleur bis', \
                    '--db-dir','/tmp/new-db-1', \
                    '--check-db', 'no', '--resume', '--debug',\
                    '--no-compression', self.login]
        
        #with emails only
        gmvlt = gmv_cmd.GMVaultLauncher()
    
        args = gmvlt.parse_args()
        
        #check args
        self.assertEquals(args['chats_only'], False)
        self.assertEquals(args['emails_only'], False)
        self.assertEquals(args['command'],  'sync')
        self.assertEquals(args['type'],     'custom')
        self.assertEquals(args['email'],    self.login)
        self.assertEquals(args['passwd'],   'not_seen')
        self.assertEquals(args['oauth'],    'empty')
        self.assertEquals(args['request'], {'req': 'subject:Chandeleur bis', 'type': 'gmail'})
        self.assertEquals(args['host'],'imap.gmail.com')
        self.assertEquals(args['port'], 993)
        self.assertEquals(args['db-cleaning'], False)
        self.assertEquals(args['db-dir'],'/tmp/new-db-1')
        self.assertEquals(args['compression'], False)
        self.assertEquals(args['debug'], True)
        self.assertEquals(args['restart'], True)