2021-01-08 19:35:16 -05:00
|
|
|
import unittest
|
|
|
|
|
2021-08-19 11:39:29 -04:00
|
|
|
from aprsd.plugins import email
|
2021-01-08 19:35:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestEmail(unittest.TestCase):
|
|
|
|
def test_get_email_from_shortcut(self):
|
2021-10-04 15:22:10 -04:00
|
|
|
config = {"aprsd": {"email": {"shortcuts": {}}}}
|
2021-01-08 19:35:16 -05:00
|
|
|
email_address = "something@something.com"
|
2021-08-23 12:14:19 -04:00
|
|
|
addr = f"-{email_address}"
|
2021-10-04 15:22:10 -04:00
|
|
|
actual = email.get_email_from_shortcut(config, addr)
|
2021-01-08 19:35:16 -05:00
|
|
|
self.assertEqual(addr, actual)
|
|
|
|
|
2021-10-04 15:22:10 -04:00
|
|
|
config = {"aprsd": {"email": {"nothing": "nothing"}}}
|
|
|
|
actual = email.get_email_from_shortcut(config, addr)
|
2021-01-08 19:35:16 -05:00
|
|
|
self.assertEqual(addr, actual)
|
|
|
|
|
2021-10-04 15:22:10 -04:00
|
|
|
config = {"aprsd": {"email": {"shortcuts": {"not_used": "empty"}}}}
|
|
|
|
actual = email.get_email_from_shortcut(config, addr)
|
2021-01-08 19:35:16 -05:00
|
|
|
self.assertEqual(addr, actual)
|
|
|
|
|
2021-10-04 15:22:10 -04:00
|
|
|
config = {"aprsd": {"email": {"shortcuts": {"-wb": email_address}}}}
|
2021-01-08 19:35:16 -05:00
|
|
|
short = "-wb"
|
2021-10-04 15:22:10 -04:00
|
|
|
actual = email.get_email_from_shortcut(config, short)
|
2021-01-08 19:35:16 -05:00
|
|
|
self.assertEqual(email_address, actual)
|