Skip to content

Commit

Permalink
feat: geolocation setter in sendgrid-python for GDPR compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
manisha1997 committed Nov 16, 2023
1 parent 2a9930f commit 5885985
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/unit/test_sendgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
class UnitTests(unittest.TestCase):
def test_host_with_no_region(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
self.assertEqual("https://api.sendgrid.com",sg.host)
self.assertEqual("https://api.sendgrid.com",sg.client.host)

def test_host_with_eu_region(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
sg.set_data_residency("eu")
self.assertEqual("https://api.eu.sendgrid.com",sg.host)
self.assertEqual("https://api.eu.sendgrid.com",sg.client.host)

def test_host_with_global_region(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
sg.set_data_residency("global")
self.assertEqual("https://api.sendgrid.com",sg.host)
self.assertEqual("https://api.sendgrid.com",sg.client.host)

def test_host_with_host_first_eu_region_second(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
sg.set_host("https://sendgrid.com")
sg.set_data_residency("eu")
self.assertEqual("https://api.eu.sendgrid.com",sg.host)
self.assertEqual("https://api.eu.sendgrid.com",sg.client.host)

def test_host_with_eu_first_host_second(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
sg.set_data_residency("eu")
sg.set_host("https://sendgrid.com")
self.assertEqual("https://sendgrid.com",sg.host)
self.assertEqual("https://sendgrid.com",sg.client.host)

def test_host_using_constructor(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY',host='https://sendgrid.com')
self.assertEqual("https://sendgrid.com",sg.host)
self.assertEqual("https://sendgrid.com",sg.client.host)

def test_with_region_is_none(self):
sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY')
Expand Down

0 comments on commit 5885985

Please sign in to comment.