From 4a52a71956a8d46fcb7294ac71734504bb09bcc2 Mon Sep 17 00:00:00 2001 From: S. Solomon Darnell Date: Fri, 28 Mar 2025 21:52:21 -0500 Subject: two version of R2R are here --- .../site-packages/test/unit/test_inbound_send.py | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py (limited to '.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py') 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'}) -- cgit v1.2.3