attribute (eg. Gmail).
"""
return self._store(b'+X-GM-LABELS', messages,
- self._normalise_label_list(labels), b'X-GM-LABELS')
+ self._normalise_labels(labels), b'X-GM-LABELS')
def remove_gmail_labels(self, messages, labels):
"""Remove one or more *labels* from *messages*.
attribute (eg. Gmail).
"""
return self._store(b'-X-GM-LABELS', messages,
- self._normalise_label_list(labels), b'X-GM-LABELS')
+ self._normalise_labels(labels), b'X-GM-LABELS')
def set_gmail_labels(self, messages, labels):
"""Set the *labels* for *messages*.
attribute (eg. Gmail).
"""
return self._store(b'X-GM-LABELS', messages,
- self._normalise_label_list(labels), b'X-GM-LABELS')
+ self._normalise_labels(labels), b'X-GM-LABELS')
def delete_messages(self, messages):
"""Delete one or more *messages* from the currently selected
folder_name = encode_utf7(folder_name)
return _quote(folder_name)
- def _normalise_label_list(self, labels):
- return iter(self._imap._quote(l) for l in labels)
+ def _normalise_labels(self, labels):
+ return [_quote(l) for l in labels]
def _quote(arg):
444: [b'foo']})
def test_add(self):
- self.client.add_gmail_labels(sentinel.messages, sentinel.labels)
- self.client._store.assert_called_with(b'+X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS')
+ self.client.add_gmail_labels(sentinel.messages, ['foo', 'B"A"R'])
+ self.client._store.assert_called_with(
+ b'+X-GM-LABELS', sentinel.messages,
+ ['"foo"', '"B\\"A\\"R"'], b'X-GM-LABELS')
def test_remove(self):
- self.client.remove_gmail_labels(sentinel.messages, sentinel.labels)
- self.client._store.assert_called_with(b'-X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS')
+ self.client.remove_gmail_labels(sentinel.messages, ['q\\ux'])
+ self.client._store.assert_called_with(
+ b'-X-GM-LABELS', sentinel.messages,
+ ['"q\\\\ux"'], b'X-GM-LABELS')
def test_set(self):
- self.client.set_gmail_labels(sentinel.messages, sentinel.labels)
- self.client._store.assert_called_with(b'X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS')
+ self.client.set_gmail_labels(sentinel.messages, ['faz', 'baz'])
+ self.client._store.assert_called_with(
+ b'X-GM-LABELS', sentinel.messages,
+ ['"faz"', '"baz"'], b'X-GM-LABELS')
class TestNamespace(IMAPClientTest):