Example #1
0
def test_mail_name_socket():
    check_value = "socket.blackhole.io"
    with mock.patch("os.access", return_value=False), mock.patch(
        "socket.getfqdn", return_value="socket.blackhole.io"
    ):
        mn = mailname()
    assert mn == check_value
Example #2
0
def test_mail_name_file_garbage():
    mnfile = create_file('mailname', '            \n     ')
    check_value = 'socket.blackhole.io'
    with mock.patch('os.access', return_value=True), \
            mock.patch('socket.getfqdn', return_value='socket.blackhole.io'):
        mn = mailname(mnfile)
    assert mn == check_value
Example #3
0
def test_mail_name_file():
    check_value = "file.blackhole.io"
    with mock.patch("os.access", return_value=True), mock.patch(
        "codecs.open", return_value=StringIO(check_value)
    ):
        mn = mailname()
        assert mn == check_value
Example #4
0
def test_mail_name_file_garbage():
    mnfile = create_file("mailname", "            \n     ")
    check_value = "socket.blackhole.io"
    with mock.patch("os.access", return_value=True), mock.patch(
            "socket.getfqdn", return_value="socket.blackhole.io"):
        mn = mailname(mnfile)
    assert mn == check_value
Example #5
0
def test_mail_name_file_garbage():
    mnfile = create_file("mailname", "            \n     ")
    check_value = "socket.blackhole.io"
    with mock.patch("os.access", return_value=True), mock.patch(
        "socket.getfqdn", return_value="socket.blackhole.io"
    ):
        mn = mailname(mnfile)
    assert mn == check_value
Example #6
0
    def __init__(self):
        """
        Initialise the SMTP parotocol.

        .. note::

           Loads the configuration, defines the server's FQDN and generates
           a RFC 2822 Message-ID.
        """
        self.loop = asyncio.get_event_loop()
        super().__init__(asyncio.StreamReader(loop=self.loop),
                         client_connected_cb=self._client_connected_cb,
                         loop=self.loop)
        self.config = Config()
        self.fqdn = mailname()
        self.message_id = message_id()
Example #7
0
    def __init__(self, *args, **kwargs):
        """
        Initialise the SMTP Protocol.

        .. note::

           Loads the configuration, defines the server's FQDN and generates
           a RFC 2822 Message-ID.
        """
        self.loop = asyncio.get_event_loop()
        super().__init__(
            asyncio.StreamReader(loop=self.loop),
            client_connected_cb=self._client_connected_cb,
            loop=self.loop)
        self.config = Config()
        self.fqdn = mailname()
        self.message_id = message_id()
Example #8
0
def test_mail_name_socket(mock_os, mock_socket):
    check_value = 'socket.blackhole.io'
    mn = mailname()
    assert mn == check_value
Example #9
0
def test_mail_name_file(mock_os):
    check_value = 'file.blackhole.io'
    with mock.patch('builtins.open', return_value=StringIO(check_value)):
        mn = mailname()
        assert mn == check_value
Example #10
0
def test_mail_name_socket():
    check_value = "socket.blackhole.io"
    with mock.patch("os.access", return_value=False), mock.patch(
            "socket.getfqdn", return_value="socket.blackhole.io"):
        mn = mailname()
    assert mn == check_value
Example #11
0
def test_mail_name_file():
    check_value = "file.blackhole.io"
    with mock.patch("os.access", return_value=True), mock.patch(
            "codecs.open", return_value=StringIO(check_value)):
        mn = mailname()
        assert mn == check_value
Example #12
0
def test_mail_name_socket():
    check_value = 'socket.blackhole.io'
    with mock.patch('os.access', return_value=False), \
            mock.patch('socket.getfqdn', return_value='socket.blackhole.io'):
        mn = mailname()
    assert mn == check_value
Example #13
0
def test_mail_name_file():
    check_value = 'file.blackhole.io'
    with mock.patch('os.access', return_value=True), \
            mock.patch('builtins.open', return_value=StringIO(check_value)):
        mn = mailname()
        assert mn == check_value
Example #14
0
def test_mail_name_socket(mock_os, mock_socket):
    check_value = 'socket.blackhole.io'
    mn = mailname()
    assert mn == check_value