How to use the imapclient.imapclient.Quota function in IMAPClient

To help you get started, we’ve selected a few IMAPClient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mjs / imapclient / tests / test_imapclient.py View on Github external
def test_parse_quota(self):
        self.assertEqual(_parse_quota([]), [])
        self.assertEqual(
            _parse_quota([b'"User quota" (STORAGE 586720 4882812)']),
            [Quota('User quota', 'STORAGE', 586720, 4882812)]
        )
        self.assertEqual(
            _parse_quota([
                b'"User quota" (STORAGE 586720 4882812)',
                b'"Global quota" (MESSAGES 42 1000)'
            ]),
            [
                Quota('User quota', 'STORAGE', 586720, 4882812),
                Quota('Global quota', 'MESSAGES', 42, 1000)
            ]
        )
        self.assertEqual(
            _parse_quota([
                b'"User quota" (STORAGE 586720 4882812 MESSAGES 42 1000)',
            ]),
            [
                Quota('User quota', 'STORAGE', 586720, 4882812),
                Quota('User quota', 'MESSAGES', 42, 1000)
            ]
github mjs / imapclient / tests / test_imapclient.py View on Github external
_parse_quota([
                b'"User quota" (STORAGE 586720 4882812)',
                b'"Global quota" (MESSAGES 42 1000)'
            ]),
            [
                Quota('User quota', 'STORAGE', 586720, 4882812),
                Quota('Global quota', 'MESSAGES', 42, 1000)
            ]
        )
        self.assertEqual(
            _parse_quota([
                b'"User quota" (STORAGE 586720 4882812 MESSAGES 42 1000)',
            ]),
            [
                Quota('User quota', 'STORAGE', 586720, 4882812),
                Quota('User quota', 'MESSAGES', 42, 1000)
            ]
github mjs / imapclient / tests / test_imapclient.py View on Github external
def test_parse_quota(self):
        self.assertEqual(_parse_quota([]), [])
        self.assertEqual(
            _parse_quota([b'"User quota" (STORAGE 586720 4882812)']),
            [Quota('User quota', 'STORAGE', 586720, 4882812)]
        )
        self.assertEqual(
            _parse_quota([
                b'"User quota" (STORAGE 586720 4882812)',
                b'"Global quota" (MESSAGES 42 1000)'
            ]),
            [
                Quota('User quota', 'STORAGE', 586720, 4882812),
                Quota('Global quota', 'MESSAGES', 42, 1000)
            ]
        )
        self.assertEqual(
            _parse_quota([
                b'"User quota" (STORAGE 586720 4882812 MESSAGES 42 1000)',
            ]),
            [
github mjs / imapclient / tests / test_imapclient.py View on Github external
def test__get_quota(self):
        self.client._command_and_check = Mock()
        self.client._command_and_check.return_value = (
            [b'"User quota" (MESSAGES 42 1000)']
        )

        quotas = self.client._get_quota('foo')

        self.client._command_and_check.assert_called_once_with(
            'getquota', '"foo"'
        )
        self.assertEqual(quotas, [Quota('User quota', 'MESSAGES', 42, 1000)])
github mjs / imapclient / tests / test_imapclient.py View on Github external
def test_set_quota(self):
        self.client._raw_command_untagged = Mock()
        self.client._raw_command_untagged.return_value = (
            [b'"User quota" (STORAGE 42 1000 MESSAGES 42 1000)']
        )
        quotas = [
            Quota('User quota', 'STORAGE', 42, 1000),
            Quota('User quota', 'MESSAGES', 42, 1000)
        ]
        resp = self.client.set_quota(quotas)

        self.client._raw_command_untagged.assert_called_once_with(
            b'SETQUOTA', [b'"User quota"', b'(STORAGE 1000 MESSAGES 1000)'],
            uid=False, response_name='QUOTA'
        )
        self.assertListEqual(resp, quotas)
github mjs / imapclient / tests / test_imapclient.py View on Github external
def test_set_quota(self):
        self.client._raw_command_untagged = Mock()
        self.client._raw_command_untagged.return_value = (
            [b'"User quota" (STORAGE 42 1000 MESSAGES 42 1000)']
        )
        quotas = [
            Quota('User quota', 'STORAGE', 42, 1000),
            Quota('User quota', 'MESSAGES', 42, 1000)
        ]
        resp = self.client.set_quota(quotas)

        self.client._raw_command_untagged.assert_called_once_with(
            b'SETQUOTA', [b'"User quota"', b'(STORAGE 1000 MESSAGES 1000)'],
            uid=False, response_name='QUOTA'
        )
        self.assertListEqual(resp, quotas)
github mjs / imapclient / imapclient / imapclient.py View on Github external
def _parse_quota(quota_rep):
    quota_rep = parse_response(quota_rep)
    rv = list()
    for quota_root, quota_resource_infos in as_pairs(quota_rep):
        for quota_resource_info in as_triplets(quota_resource_infos):
            rv.append(Quota(
                quota_root=to_unicode(quota_root),
                resource=to_unicode(quota_resource_info[0]),
                usage=quota_resource_info[1],
                limit=quota_resource_info[2]
            ))
    return rv