def stub_message_from_raw(db, raw_message): namespace_id = default_namespace(db).id new_msg = new_message_from_synced(db, default_namespace(db).account, raw_message) fake_thread = add_fake_thread(db.session, namespace_id) new_msg.thread = fake_thread db.session.add_all([new_msg, fake_thread]) db.session.commit() return new_msg
def stub_message_from_raw(db, new_message_from_synced): NAMESPACE_ID = default_namespace(db).id new_msg = new_message_from_synced fake_thread = add_fake_thread(db.session, NAMESPACE_ID) new_msg.thread = fake_thread db.session.add_all([new_msg, fake_thread]) db.session.commit() return new_msg
def stub_message(db): namespace_id = default_namespace(db).id # new_msg = new_message_from_synced # fake_thread = add_fake_thread(db.session, NAMESPACE_ID) # new_msg.thread = fake_thread # db.session.add_all([new_msg, fake_thread]) # db.session.commit() # return new_msg thread = add_fake_thread(db.session, namespace_id) message = add_fake_message(db.session, namespace_id, thread, subject="Golden Gate Park next Sat", from_addr=[('alice', '*****@*****.**')], to_addr=[('bob', '*****@*****.**')]) message.snippet = 'Banh mi paleo pickled, sriracha' message.body = """ Banh mi paleo pickled, sriracha biodiesel chambray seitan mumblecore mustache. Raw denim gastropub 8-bit, butcher PBR sartorial photo booth Pinterest blog Portland roof party cliche bitters aesthetic. Ugh. """ message = add_fake_message(db.session, namespace_id, thread, subject="Re:Golden Gate Park next Sat", from_addr=[('bob', '*****@*****.**')], to_addr=[('alice', '*****@*****.**')], cc_addr=[('Cheryl', '*****@*****.**')]) message.snippet = 'Bushwick meggings ethical keffiyeh' message.body = """ Bushwick meggings ethical keffiyeh. Chambray lumbersexual wayfarers, irony Banksy cred bicycle rights scenester artisan tote bag YOLO gastropub. """ draft = add_fake_message(db.session, namespace_id, thread, subject="Re:Golden Gate Park next Sat", from_addr=[('alice', '*****@*****.**')], to_addr=[('bob', '*****@*****.**')], cc_addr=[('Cheryl', '*****@*****.**')]) draft.snippet = 'Hey there friend writing a draft' draft.body = """ DIY tousled Tumblr, VHS meditation 3 wolf moon listicle fingerstache viral bicycle rights. Thundercats kale chips church-key American Apparel. """ draft.is_draft = True draft.reply_to_message = message db.session.commit() return message
def stub_message(db, new_message_from_synced): NAMESPACE_ID = default_namespace(db).id # new_msg = new_message_from_synced # fake_thread = add_fake_thread(db.session, NAMESPACE_ID) # new_msg.thread = fake_thread # db.session.add_all([new_msg, fake_thread]) # db.session.commit() # return new_msg thread = add_fake_thread(db.session, NAMESPACE_ID) message = add_fake_message(db.session, NAMESPACE_ID, thread, subject="Golden Gate Park next Sat", from_addr=[('alice', '*****@*****.**')], to_addr=[('bob', '*****@*****.**')]) message.snippet = 'Banh mi paleo pickled, sriracha' message.sanitized_body = """ Banh mi paleo pickled, sriracha biodiesel chambray seitan mumblecore mustache. Raw denim gastropub 8-bit, butcher PBR sartorial photo booth Pinterest blog Portland roof party cliche bitters aesthetic. Ugh. """ message = add_fake_message(db.session, NAMESPACE_ID, thread, subject="Re:Golden Gate Park next Sat", from_addr=[('bob', '*****@*****.**')], to_addr=[('alice', '*****@*****.**')], cc_addr=[('Cheryl', '*****@*****.**')]) message.snippet = 'Bushwick meggings ethical keffiyeh' message.sanitized_body = """ Bushwick meggings ethical keffiyeh. Chambray lumbersexual wayfarers, irony Banksy cred bicycle rights scenester artisan tote bag YOLO gastropub. """ draft = add_fake_message(db.session, NAMESPACE_ID, thread, subject="Re:Golden Gate Park next Sat", from_addr=[('alice', '*****@*****.**')], to_addr=[('bob', '*****@*****.**')], cc_addr=[('Cheryl', '*****@*****.**')]) draft.snippet = 'Hey there friend writing a draft' draft.sanitized_body = """ DIY tousled Tumblr, VHS meditation 3 wolf moon listicle fingerstache viral bicycle rights. Thundercats kale chips church-key American Apparel. """ draft.is_draft = True draft.reply_to_message = message db.session.commit() return message
def test_rfc822_format(db, api_client, new_message_from_synced): """ Test the API response to retreive raw message contents """ NAMESPACE_ID = default_namespace(db).id new_msg = new_message_from_synced fake_thread = add_fake_thread(db.session, NAMESPACE_ID) new_msg.thread = fake_thread db.session.add_all([new_msg, fake_thread]) db.session.commit() full_path = api_client.full_path('/messages/{}'.format(new_msg.public_id), ns_id=NAMESPACE_ID) results = api_client.client.get(full_path, headers={'Accept': 'message/rfc822'}) assert results.data == raw_message()