Example #1
0
    def test_combine_search_criterion(self):
        self.imap_account = imaplib.IMAP4_SSL()

        date = datetime.datetime(1989, 1, 3)
        mail_address = '*****@*****.**'
        search_criterion = [
            search.create_search_criterion_by_date(date, relative='BEFORE'),
            search.create_search_criterion_by_mail_address(mail_address,
                                                           header_name='TO'),
        ]

        imap_request = search.combine_search_criterion(search_criterion)
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='AND')
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='OR')
        assert imap_request == 'OR BEFORE 03-Jan-1989 TO "*****@*****.**"'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='NOT')
        assert imap_request == 'NOT BEFORE 03-Jan-1989 TO "*****@*****.**"'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='WRONG')
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'
Example #2
0
    def test_combine_search_criterion(self):
        self.imap_account = imaplib.IMAP4_SSL()

        date = datetime.datetime(1989, 1, 3)
        mail_address = '*****@*****.**'
        search_criterion = [
            search.create_search_criterion_by_date(date, relative='BEFORE'),
            search.create_search_criterion_by_mail_address(mail_address,
                                                           header_name='TO'),
        ]

        imap_request = search.combine_search_criterion(search_criterion)
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='AND')
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='OR')
        assert imap_request == 'OR BEFORE 03-Jan-1989 TO "*****@*****.**"'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='NOT')
        assert imap_request == 'NOT BEFORE 03-Jan-1989 TO "*****@*****.**"'

        imap_request = search.combine_search_criterion(search_criterion,
                                                       operator='WRONG')
        assert imap_request == '(BEFORE 03-Jan-1989 TO "*****@*****.**")'
Example #3
0
    def test_create_search_criteria_by_date(self):
        self.imap_account = imaplib.IMAP4_SSL()

        date = datetime.datetime(1989, 1, 3)
        search_criterion = search.create_search_criterion(date=date)
        assert search_criterion == ['SINCE 03-Jan-1989']

        search_criterion = search.create_search_criterion_by_date(
            date, relative='BEFORE')
        assert search_criterion == 'BEFORE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='ON')
        assert search_criterion == 'ON 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='SINCE')
        assert search_criterion == 'SINCE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='BEFORE', sent=True)
        assert search_criterion == 'SENTBEFORE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='ON', sent=True)
        assert search_criterion == 'SENTON 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='SINCE', sent=True)
        assert search_criterion == 'SENTSINCE 03-Jan-1989'
Example #4
0
    def test_create_search_criteria_by_date(self):
        self.imap_account = imaplib.IMAP4_SSL()

        date = datetime.datetime(1989, 1, 3)
        search_criterion = search.create_search_criterion(date=date)
        assert search_criterion == ['SINCE 03-Jan-1989']

        search_criterion = search.create_search_criterion_by_date(
            date, relative='BEFORE')
        assert search_criterion == 'BEFORE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='ON')
        assert search_criterion == 'ON 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='SINCE')
        assert search_criterion == 'SINCE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='BEFORE', sent=True)
        assert search_criterion == 'SENTBEFORE 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='ON', sent=True)
        assert search_criterion == 'SENTON 03-Jan-1989'

        search_criterion = search.create_search_criterion_by_date(
            date, relative='SINCE', sent=True)
        assert search_criterion == 'SENTSINCE 03-Jan-1989'