aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/test/unit/test_inbound_send.py
diff options
context:
space:
mode:
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.py49
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'})