def test_message_with_photo(self): raw = { u'from': { u'username': u'mybot', u'first_name': u'My bot', u'id': 100000000 }, u'photo': [{ u'width': 90, u'height': 67, u'file_id': u'AgADBAADrqcxG-n9AQZgjPT5D4Qen5rhjjAABFpmaP_GKjtNk28BAAEC', u'file_size': 629 }, { u'width': 100, u'height': 75, u'file_id': u'AgADBAADrqcxG-n9AQZgjPT5D4Qen5rhjjAABFpmaP_GKjtNk28BAAEC', u'file_size': 1345 }], u'caption': u'What is this?', u'chat': { u'username': u'jbloggs', u'first_name': u'Joe', u'type': u'private', u'id': 20000000 }, u'date': 1446672894, u'message_id': 131 } m = Message() m._from_raw(raw)
def test_message_with_photo2(self): raw = {'date': 1446760513, 'photo': [{'width': 40, 'file_size': 823, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMtswAASsEEgWRcFfw0EVAQABAg', 'height': 90}, {'width': 143, 'file_size': 9252, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMtswAASsEEgWRcFfw0EVAQABAg', 'height': 320}, {'width': 164, 'file_size': 11766, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMoswAAS1BhTBUPT5Tj8VAQABAg', 'height': 366}], 'from': {'username': u'jbloggs', 'first_name': u'Joe', 'id': 20000000}, 'message_id': 137, 'chat': {'username': u'jbloggs', 'first_name': u'Joe', 'type': u'private', 'id': 2000000}} m = Message() m._from_raw(raw) self.assertFalse(hasattr(m, 'text')) def g(): m.text self.assertRaises(AttributeError, g)
def test_message_with_photo2(self): raw = { 'date': 1446760513, 'photo': [{ 'width': 40, 'file_size': 823, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMtswAASsEEgWRcFfw0EVAQABAg', 'height': 90 }, { 'width': 143, 'file_size': 9252, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMtswAASsEEgWRcFfw0EVAQABAg', 'height': 320 }, { 'width': 164, 'file_size': 11766, 'file_id': u'AgADBAADOqoxG396-QAB_l-8dsikQCIjMoswAAS1BhTBUPT5Tj8VAQABAg', 'height': 366 }], 'from': { 'username': u'jbloggs', 'first_name': u'Joe', 'id': 20000000 }, 'message_id': 137, 'chat': { 'username': u'jbloggs', 'first_name': u'Joe', 'type': u'private', 'id': 2000000 } } m = Message() m._from_raw(raw) self.assertFalse(hasattr(m, 'text')) def g(): m.text self.assertRaises(AttributeError, g)
def test_message_with_photo(self): raw = {u'from': {u'username': u'mybot', u'first_name': u'My bot', u'id': 100000000}, u'photo': [{u'width': 90, u'height': 67, u'file_id': u'AgADBAADrqcxG-n9AQZgjPT5D4Qen5rhjjAABFpmaP_GKjtNk28BAAEC', u'file_size': 629}, {u'width': 100, u'height': 75, u'file_id': u'AgADBAADrqcxG-n9AQZgjPT5D4Qen5rhjjAABFpmaP_GKjtNk28BAAEC', u'file_size': 1345}], u'caption': u'What is this?', u'chat': {u'username': u'jbloggs', u'first_name': u'Joe', u'type': u'private', u'id': 20000000}, u'date': 1446672894, u'message_id': 131} m = Message() m._from_raw(raw)