diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py b/.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py new file mode 100644 index 00000000..19ee5de1 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py @@ -0,0 +1,49 @@ +import argparse +import unittest + +from sendgrid.helpers.inbound import send + +try: + import unittest.mock as mock +except ImportError: + import mock + + +class UnitTests(unittest.TestCase): + def setUp(self): + self.client_mock = mock.patch('sendgrid.helpers.inbound.send.Client') + self.open_mock = mock.patch('sendgrid.helpers.inbound.send.open', + mock.mock_open(), create=True) + self.client_mock.start() + self.open_mock.start() + + def tearDown(self): + self.client_mock.stop() + self.open_mock.stop() + + def test_send(self): + + fake_url = 'https://fake_url' + x = send.Send(fake_url) + x.test_payload(fake_url) + + send.Client.assert_called_once_with( + host=fake_url, + request_headers={ + 'User-Agent': 'SendGrid-Test', + 'Content-Type': 'multipart/form-data; boundary=xYzZY' + }) + + def test_main_call(self): + fake_url = 'https://fake_url' + + with mock.patch( + 'argparse.ArgumentParser.parse_args', + return_value=argparse.Namespace( + host=fake_url, data='test_file.txt')): + send.main() + send.Client.assert_called_once_with( + host=fake_url, + request_headers={ + 'User-Agent': 'SendGrid-Test', + 'Content-Type': 'multipart/form-data; boundary=xYzZY'}) |