class EmailTests(unittest.TestCase): def setUp(self): self.mg_a = MailGun() self.mg_b = MailGun() self.md_a = Mandrill() self.md_b = Mandrill() def test_singleton_same_object(self): """ From the python manual Return the ``identity'' of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. (Implementation note: this is the address of the object.) :return: """ self.assertEqual(id(self.mg_a), id(self.mg_b)) self.assertEqual(id(self.md_a), id(self.md_b)) def test_singleton_member_variable_change(self): self.mg_a.timeout = True self.md_a.timeout = True self.assertEqual(self.mg_a.timeout, self.mg_b.timeout) self.assertEqual(self.md_a.timeout, self.md_b.timeout) def test_send_email(self): import requests the_json = json.loads(UBER_JSON_STR) r = self.mg_a.send_email(the_json['to_name'], the_json['to'], the_json['from_name'], the_json['from'], the_json['subject'], the_json['body']) self.assertEqual(r.status_code == requests.codes.ok, True) r = self.md_a.send_email(the_json['to_name'], the_json['to'], the_json['from_name'], the_json['from'], the_json['subject'], the_json['body']) self.assertEqual(r.status_code == requests.codes.ok, True)
def setUp(self): self.mg_a = MailGun() self.mg_b = MailGun() self.md_a = Mandrill() self.md_b = Mandrill()