Exemplo n.º 1
0
    def test_for_system_DST_active(self, localtime):
        localtime_mock = Mock()
        localtime_mock.tm_isdst = True
        localtime.return_value = localtime_mock

        offset = FixedOffset.for_system()
        self.assertEqual(offset.tzname(None), '-1500')
Exemplo n.º 2
0
    def test_for_system_DST_active(self, localtime):
        localtime_mock = Mock()
        localtime_mock.tm_isdst = True
        localtime.return_value = localtime_mock

        offset = FixedOffset.for_system()
        self.assertEqual(offset.tzname(None), '-1500')
Exemplo n.º 3
0
    def _append(self, folder, msg, flags=(), msg_time=None):  # TODO
        """
        FORKED FORM IMAPCLIENT
        """
        if msg_time:
            if not msg_time.tzinfo:  # pragma: no cover
                msg_time = msg_time.replace(tzinfo=FixedOffset.for_system())  # pragma: no cover

            time_val = '"{0}"'.format(msg_time.strftime("%d-%b-%Y %H:%M:%S %z"))
            time_val = imapclient.imapclient.to_unicode(time_val)
        else:
            time_val = None

        return self.conn._command_and_check('append', self.conn._normalise_folder(folder), imapclient.imapclient.seq_to_parenstr(flags),
                                            time_val, Helper.str_to_bytes(msg),
                                            unpack=True)
Exemplo n.º 4
0
        check(' 9-Feb-2007 17:08:08 -0430',
              datetime(2007, 2, 9, 17, 8, 8, 0, FixedOffset(-4*60 - 30)))
 
        check('12-Feb-2007 17:08:08 +0200',
              datetime(2007, 2, 12, 17, 8, 8, 0, FixedOffset(2*60)))
 
        check(' 9-Dec-2007 17:08:08 +0000',
              datetime(2007, 12, 9, 17, 8, 8, 0, FixedOffset(0)))


    def test_mixed_types(self):
        self.assertEquals(parse_fetch_response([('1 (INTERNALDATE " 9-Feb-2007 17:08:08 +0100" RFC822 {21}',
                                                 'Subject: test\r\n\r\nbody'),
                                                ')']),
                          {1: {'INTERNALDATE': datetime_to_native(datetime(2007, 2, 9,
                                                                           17, 8, 8, 0,
                                                                           FixedOffset(60))),
                               'RFC822': 'Subject: test\r\n\r\nbody',
                               'SEQ': 1}})


def add_crlf(text):
    return CRLF.join(text.splitlines()) + CRLF


system_offset = FixedOffset.for_system()
def datetime_to_native(dt):
    return dt.astimezone(system_offset).replace(tzinfo=None)


Exemplo n.º 5
0
        check(' 9-Dec-2007 17:08:08 +0000',
              datetime(2007, 12, 9, 17, 8, 8, 0, FixedOffset(0)))

    def test_mixed_types(self):
        self.assertEqual(
            parse_fetch_response([
                ('1 (INTERNALDATE " 9-Feb-2007 17:08:08 +0100" RFC822 {21}',
                 'Subject: test\r\n\r\nbody'), ')'
            ]), {
                1: {
                    'INTERNALDATE':
                    datetime_to_native(
                        datetime(2007, 2, 9, 17, 8, 8, 0, FixedOffset(60))),
                    'RFC822':
                    'Subject: test\r\n\r\nbody',
                    'SEQ':
                    1
                }
            })


def add_crlf(text):
    return CRLF.join(text.splitlines()) + CRLF


system_offset = FixedOffset.for_system()


def datetime_to_native(dt):
    return dt.astimezone(system_offset).replace(tzinfo=None)
Exemplo n.º 6
0
 def test_for_system_no_DST(self):
     offset = FixedOffset.for_system()
     self.assertEqual(offset.tzname(None), '+1500')
Exemplo n.º 7
0
 def test_for_system_no_DST(self):
     offset = FixedOffset.for_system()
     self.assertEqual(offset.tzname(None), '+1500')
Exemplo n.º 8
0
 def test_for_system_DST(self):
     offset = FixedOffset.for_system()
     self.assert_(offset.tzname(None) == '-1500')