# Path: alot/commands/globals.py
# MODE = 'global'
# class ExitCommand(Command):
# class SearchCommand(Command):
# class PromptCommand(Command):
# class RefreshCommand(Command):
# class ExternalCommand(Command):
# class EditCommand(ExternalCommand):
# class PythonShellCommand(Command):
# class RepeatCommand(Command):
# class CallCommand(Command):
# class BufferCloseCommand(Command):
# class BufferFocusCommand(Command):
# class OpenBufferlistCommand(Command):
# class TagListCommand(Command):
# class NamedQueriesCommand(Command):
# class FlushCommand(Command):
# class HelpCommand(Command):
# class ComposeCommand(Command):
#     class ApplyError(Exception):
# class MoveCommand(Command):
# class ReloadCommand(Command):
# class SaveQueryCommand(Command):
# class RemoveQueryCommand(Command):
# class ConfirmCommand(Command):
#     def __init__(self, _prompt=True, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, query, sort=None, **kwargs):
#     def apply(self, ui):
#     def __init__(self, startwith='', **kwargs):
#     async def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, cmd, stdin=None, shell=False, spawn=False,
#                  refocus=True, thread=False, on_success=None, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, path, spawn=None, thread=None, **kwargs):
#     async def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, command, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, buffer=None, force=False, redraw=True, **kwargs):
#     async def apply(self, ui):
#         async def one_buffer(prompt=True):
#     def __init__(self, buffer=None, index=None, offset=0, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=lambda x: x, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=lambda x: x, tags=None, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=bool, **kwargs):
#     def apply(self, ui):
#     def __init__(self, callback=None, silent=False, **kwargs):
#     def apply(self, ui):
#                 def f(*_):
#     def __init__(self, commandname='', **kwargs):
#     def apply(self, ui):
#     def __init__(
#             self,
#             envelope=None, headers=None, template=None, sender='',
#             tags=None, subject='', to=None, cc=None, bcc=None, attach=None,
#             omit_signature=False, spawn=None, rest=None, encrypt=False,
#             **kwargs):
#     def _get_template(self, ui):
#     async def _get_sender_details(self, ui):
#     async def _set_signature(self, ui):
#     async def apply(self, ui):
#     def _get_account(self, ui):
#     def _set_envelope(self):
#     def _set_gpg_sign(self, ui):
#     async def _set_to(self, ui):
#     async def _set_gpg_encrypt(self, ui):
#     def _set_base_attributes(self):
#     async def _set_subject(self, ui):
#     async def _set_compose_tags(self, ui):
#     def _set_attachments(self):
#     async def __apply(self, ui):
#     def __init__(self, movement=None, **kwargs):
#     def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, alias, query=None, flush=True, **kwargs):
#     def apply(self, ui):
#     def __init__(self, alias, flush=True, **kwargs):
#     def apply(self, ui):
#     def __init__(self, msg=None, **kwargs):
#     async def apply(self, ui):


import os
import tempfile
import unittest
from unittest import mock
from alot.commands import globals as g_commands
from .. import utilities
class Stop(Exception):
    """exception for stopping testing of giant unmanagable functions."""
    pass


class TestComposeCommand(unittest.TestCase):

    """Tests for the compose command."""

    @staticmethod
    def _make_envelope_mock():
        envelope = mock.Mock()
        envelope.headers = {'From': 'foo <foo@example.com>'}
        envelope.get = envelope.headers.get
        envelope.sign_key = None
        envelope.sign = False
        return envelope

    @staticmethod
    def _make_account_mock(
            sign_by_default=True, gpg_key=mock.sentinel.gpg_key):
        account = mock.Mock()
        account.sign_by_default = sign_by_default
        account.gpg_key = gpg_key
        account.signature = None
        return account

    def test_set_gpg_sign_by_default_okay(self):
        envelope = self._make_envelope_mock()
        envelope.account = self._make_account_mock()

# Path: alot/commands/globals.py
# MODE = 'global'
# class ExitCommand(Command):
# class SearchCommand(Command):
# class PromptCommand(Command):
# class RefreshCommand(Command):
# class ExternalCommand(Command):
# class EditCommand(ExternalCommand):
# class PythonShellCommand(Command):
# class RepeatCommand(Command):
# class CallCommand(Command):
# class BufferCloseCommand(Command):
# class BufferFocusCommand(Command):
# class OpenBufferlistCommand(Command):
# class TagListCommand(Command):
# class NamedQueriesCommand(Command):
# class FlushCommand(Command):
# class HelpCommand(Command):
# class ComposeCommand(Command):
#     class ApplyError(Exception):
# class MoveCommand(Command):
# class ReloadCommand(Command):
# class SaveQueryCommand(Command):
# class RemoveQueryCommand(Command):
# class ConfirmCommand(Command):
#     def __init__(self, _prompt=True, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, query, sort=None, **kwargs):
#     def apply(self, ui):
#     def __init__(self, startwith='', **kwargs):
#     async def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, cmd, stdin=None, shell=False, spawn=False,
#                  refocus=True, thread=False, on_success=None, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, path, spawn=None, thread=None, **kwargs):
#     async def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, command, **kwargs):
#     async def apply(self, ui):
#     def __init__(self, buffer=None, force=False, redraw=True, **kwargs):
#     async def apply(self, ui):
#         async def one_buffer(prompt=True):
#     def __init__(self, buffer=None, index=None, offset=0, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=lambda x: x, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=lambda x: x, tags=None, **kwargs):
#     def apply(self, ui):
#     def __init__(self, filtfun=bool, **kwargs):
#     def apply(self, ui):
#     def __init__(self, callback=None, silent=False, **kwargs):
#     def apply(self, ui):
#                 def f(*_):
#     def __init__(self, commandname='', **kwargs):
#     def apply(self, ui):
#     def __init__(
#             self,
#             envelope=None, headers=None, template=None, sender='',
#             tags=None, subject='', to=None, cc=None, bcc=None, attach=None,
#             omit_signature=False, spawn=None, rest=None, encrypt=False,
#             **kwargs):
#     def _get_template(self, ui):
#     async def _get_sender_details(self, ui):
#     async def _set_signature(self, ui):
#     async def apply(self, ui):
#     def _get_account(self, ui):
#     def _set_envelope(self):
#     def _set_gpg_sign(self, ui):
#     async def _set_to(self, ui):
#     async def _set_gpg_encrypt(self, ui):
#     def _set_base_attributes(self):
#     async def _set_subject(self, ui):
#     async def _set_compose_tags(self, ui):
#     def _set_attachments(self):
#     async def __apply(self, ui):
#     def __init__(self, movement=None, **kwargs):
#     def apply(self, ui):
#     def apply(self, ui):
#     def __init__(self, alias, query=None, flush=True, **kwargs):
#     def apply(self, ui):
#     def __init__(self, alias, flush=True, **kwargs):
#     def apply(self, ui):
#     def __init__(self, msg=None, **kwargs):
#     async def apply(self, ui):


# Path: tests/commands/test_global.py
import os
import tempfile
import unittest
from unittest import mock
from alot.commands import globals as g_commands
from .. import utilities

class Stop(Exception):
    """exception for stopping testing of giant unmanagable functions."""
    pass


class TestComposeCommand(unittest.TestCase):

    """Tests for the compose command."""

    @staticmethod
    def _make_envelope_mock():
        envelope = mock.Mock()
        envelope.headers = {'From': 'foo <foo@example.com>'}
        envelope.get = envelope.headers.get
        envelope.sign_key = None
        envelope.sign = False
        return envelope

    @staticmethod
    def _make_account_mock(
            sign_by_default=True, gpg_key=mock.sentinel.gpg_key):
        account = mock.Mock()
        account.sign_by_default = sign_by_default
        account.gpg_key = gpg_key
        account.signature = None
        return account

    def test_set_gpg_sign_by_default_okay(self):
        envelope = self._make_envelope_mock()
        envelope.account = self._make_account_mock()

        cmd = g_commands.ComposeCommand(envelope=envelope)