def test_init_basicNormalTwiceSameSource(self): """Check that creating 2 non-empty mimeObjects with the same source does not create duplicate references or overlapping objects""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj1 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) obj2 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) self.assertTrue(obj1 is not obj2, "The two objects should be different objects") self.assertTrue(obj1.header==obj2.header, "Headers have same value") self.assertTrue(obj1.header is not obj2.header, "Shouldn't be the same object...") self.assertTrue(obj1.body==obj2.body) self.assertTrue(obj1.body is obj2.body, "Strings are immutable, so the body should *be* the same as our argument!")
def test_init_basicNormalTwiceSameSource(self): """Check that creating 2 non-empty mimeObjects with the same source does not create duplicate references or overlapping objects""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj1 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) obj2 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) self.assert_(obj1 is not obj2, "The two objects should be different objects") self.assert_(obj1.header==obj2.header, "Headers have same value") self.assert_(obj1.header is not obj2.header, "Shouldn't be the same object...") self.assert_(obj1.body==obj2.body) self.assert_(obj1.body is obj2.body, "Strings are immutable, so the body should *be* the same as our argument!")
def test_str_Basic(self): """Check the str() of a normal non-empty object""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj = MimeRequestComponent.mimeObject(aHeader, theBody) # TODO: Oh noes, this test fails rather randomly on py3 self.assertTrue(str(obj) == 'A: 1\nB: 1\n\nmime body')
def test_init_basicNormalTwiceDifferentSources(self): """Check that creating 2 non-empty mimeObjects with differing source does not create duplicate references or overlapping objects""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" bHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } anotherBody = "mime body" self.assertTrue(theBody is anotherBody, "Due to immutable strings") self.assertTrue(aHeader is not bHeader, "Due to dicts being mutable") obj1 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) obj2 = MimeRequestComponent.mimeObject(header=bHeader, body=anotherBody) self.assertTrue(obj1.header==obj2.header, "Header have same value") self.assertTrue(obj1.header is not obj2.header, "Shouldn't be the same object...") self.assertTrue(obj1.body==obj2.body, "The body of both should be the same") self.assertTrue(obj1.body is obj2.body, "Strings are immutable, so the body should *be* the same as our argument!")
def test_init_basicNormalTwiceDifferentSources(self): """Check that creating 2 non-empty mimeObjects with differing source does not create duplicate references or overlapping objects""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" bHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } anotherBody = "mime body" self.assert_(theBody is anotherBody, "Due to immutable strings") self.assert_(aHeader is not bHeader, "Due to dicts being mutable") obj1 = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) obj2 = MimeRequestComponent.mimeObject(header=bHeader, body=anotherBody) self.assert_(obj1.header==obj2.header, "Header have same value") self.assert_(obj1.header is not obj2.header, "Shouldn't be the same object...") self.assert_(obj1.body==obj2.body, "The body of both should be the same") self.assert_(obj1.body is obj2.body, "Strings are immutable, so the body should *be* the same as our argument!")
def test_init_basicNormal(self): """Check creating a mimeObject with typical call values""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) self.assertTrue(obj.header==aHeader, "Header have same value") self.assertTrue(obj.header is not aHeader, "Header should be copied, not a reference to the original") self.assertTrue(obj.body==theBody, "The body of should be the same as the original") self.assertTrue(obj.body is theBody, "Strings are immutable, so the body should *be* the same as our argument!")
def test_init_basicNormal(self): """Check creating a mimeObject with typical call values""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj = MimeRequestComponent.mimeObject(header=aHeader, body=theBody) self.assert_(obj.header==aHeader, "Header have same value") self.assert_(obj.header is not aHeader, "Header should be copied, not a reference to the original") self.assert_(obj.body==theBody, "The body of should be the same as the original") self.assert_(obj.body is theBody, "Strings are immutable, so the body should *be* the same as our argument!")
def test_str_Empty(self): """Check the str() of the empty object""" obj = MimeRequestComponent.mimeObject() self.assertTrue(str(obj) == '\n')
def test_init_emptyTwice(self): """Check that creating 2 empty mimeObjects does not create duplicate references""" obj1 = MimeRequestComponent.mimeObject() obj2 = MimeRequestComponent.mimeObject() self.assertTrue(obj1.header is not obj2.header, "Dictionaries, even empty, should not be shared") self.assertTrue(obj1.body is obj2.body, "Strings are immutable hence ''==''")
def test_init_empty(self): """Test creating an empty mimeObject""" obj = MimeRequestComponent.mimeObject() self.assertTrue(obj is not None, "Smoke Test") self.assertTrue(obj.header=={}, "The header should be empty") self.assertTrue(obj.body=="", "The body should be empty")
def test_str_Basic(self): """Check the str() of a normal non-empty object""" aHeader = {"a" : ["A", "1"] , "B": ["B", "1"] } theBody = "mime body" obj = MimeRequestComponent.mimeObject(aHeader, theBody) self.assert_(str(obj) == 'A: 1\nB: 1\n\nmime body')
def test_str_Empty(self): """Check the str() of the empty object""" obj = MimeRequestComponent.mimeObject() self.assert_(str(obj) == '\n')
def test_init_emptyTwice(self): """Check that creating 2 empty mimeObjects does not create duplicate references""" obj1 = MimeRequestComponent.mimeObject() obj2 = MimeRequestComponent.mimeObject() self.assert_(obj1.header is not obj2.header, "Dictionaries, even empty, should not be shared") self.assert_(obj1.body is obj2.body, "Strings are immutable hence ''==''")
def test_init_empty(self): """Test creating an empty mimeObject""" obj = MimeRequestComponent.mimeObject() self.assert_(obj is not None, "Smoke Test") self.assert_(obj.header=={}, "The header should be empty") self.assert_(obj.body=="", "The body should be empty")