wuttamess/tests/test_postfix.py

57 lines
1.5 KiB
Python
Raw Normal View History

2024-09-10 14:05:13 -05:00
# -*- coding: utf-8; -*-
from unittest import TestCase
from unittest.mock import MagicMock
from wuttamess import postfix as mod
class TestSetConfig(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_config(c, "foo", "bar")
2024-09-10 14:05:13 -05:00
c.run.assert_called_once_with("postconf -e 'foo=bar'")
class TestSetMyhostname(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_myhostname(c, "test.example.com")
2024-09-10 14:05:13 -05:00
c.run.assert_called_once_with("postconf -e 'myhostname=test.example.com'")
class TestSetMyorigin(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_myorigin(c, "example.com")
2024-09-10 14:05:13 -05:00
c.run.assert_called_once_with("postconf -e 'myorigin=example.com'")
class TestSetMydestination(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_mydestination(c, "example.com", "test.example.com", "localhost")
c.run.assert_called_once_with(
"postconf -e 'mydestination=example.com, test.example.com, localhost'"
)
2024-09-10 14:05:13 -05:00
class TestSetMynetworks(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_mynetworks(c, "127.0.0.0/8", "[::1]/128")
2024-09-10 14:05:13 -05:00
c.run.assert_called_once_with("postconf -e 'mynetworks=127.0.0.0/8 [::1]/128'")
class TestSetRelayhost(TestCase):
def test_basic(self):
c = MagicMock()
mod.set_relayhost(c, "mail.example.com")
2024-09-10 14:05:13 -05:00
c.run.assert_called_once_with("postconf -e 'relayhost=mail.example.com'")