예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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()
예제 #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()
예제 #8
0
def test_mail_name_socket(mock_os, mock_socket):
    check_value = 'socket.blackhole.io'
    mn = mailname()
    assert mn == check_value
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #14
0
def test_mail_name_socket(mock_os, mock_socket):
    check_value = 'socket.blackhole.io'
    mn = mailname()
    assert mn == check_value