def test_create(self): m = actions.SortMailingList( { 'name': 'sort-mailing-list', 'dest-mailbox-base': 'lists-go-under-here.' }, {}, ) self.assertEqual('lists-go-under-here.', m._dest_mailbox_base) self.assertEqual(m._default_regex, m._dest_mailbox_regex.pattern)
def test_create_with_multi_group_regex(self): m = actions.SortMailingList( { 'name': 'sort-mailing-list', 'dest-mailbox-base': 'lists-go-under-here.', 'dest-mailbox-regex': ':(.*):(.*):', 'dest-mailbox-regex-group': 2 }, {}, ) self.assertEqual(2, m._dest_mailbox_regex_group)
def test_get_dest_mailbox_default(self): m = actions.SortMailingList( { 'name': 'sort-mailing-list', 'dest-mailbox-base': 'lists-go-under-here.' }, {}, ) self.msg['list-id'] = '<sphinx-dev.googlegroups.com>' dest = m._get_dest_mailbox('id-here', self.msg) self.assertEqual( 'lists-go-under-here.sphinx-dev', dest, )
def test_invoke(self): m = actions.SortMailingList( { 'name': 'sort-mailing-list', 'dest-mailbox-base': 'lists-go-under-here.', 'dest-mailbox-regex': r'<(.*)>' }, {}, ) self.msg['list-id'] = '<sphinx-dev.googlegroups.com>' conn = mock.Mock() m.invoke(conn, 'src-mailbox', 'id-here', self.msg) conn.move_message.assert_called_once_with( 'src-mailbox', 'lists-go-under-here.sphinx-dev.googlegroups.com', 'id-here', self.msg)