def test_delete_all_mails(self):
        doc = MagicMock(spec=SoledadDocument)
        doc.content = {'type': 'head'}
        self.soledad.get_all_docs.return_value = (1, [doc])

        delete_all_mails(self.args)

        self.soledad.delete_doc.assert_called_once_with(doc)
    def test_delete_all_mails(self):
        doc = MagicMock(spec=SoledadDocument)
        doc.content = {'type': 'head'}
        self.soledad.get_all_docs.return_value = (1, [doc])

        delete_all_mails(self.args)

        self.soledad.delete_doc.assert_called_once_with(doc)
    def test_only_mail_documents_are_deleted(self):
        docs = self._create_docs_of_type(['head', 'cnt', 'flags', 'mbx', 'foo', None])
        self.soledad.get_all_docs.return_value = (1, docs)

        delete_all_mails(self.args)

        for doc in docs:
            if doc.content['type'] in ['head', 'cnt', 'flags']:
                self.soledad.delete_doc.assert_any_call(doc)
        self.assertEqual(3, len(self.soledad.delete_doc.mock_calls))
    def test_only_mail_documents_are_deleted(self):
        docs = self._create_docs_of_type(
            ['head', 'cnt', 'flags', 'mbx', 'foo', None])
        self.soledad.get_all_docs.return_value = (1, docs)

        delete_all_mails(self.args)

        for doc in docs:
            if doc.content['type'] in ['head', 'cnt', 'flags']:
                self.soledad.delete_doc.assert_any_call(doc)
        self.assertEqual(3, len(self.soledad.delete_doc.mock_calls))
    def test_delete_all_mails_supports_empty_doclist(self):
        self.soledad.get_all_docs.return_value = (1, [])

        delete_all_mails(self.args)

        self.assertFalse(self.soledad.delete_doc.called)
    def test_delete_all_mails_supports_empty_doclist(self):
        self.soledad.get_all_docs.return_value = (1, [])

        delete_all_mails(self.args)

        self.assertFalse(self.soledad.delete_doc.called)