def test_account(db, api_client, generic_account, gmail_account): # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data('/account') assert resp_data['id'] == generic_account.namespace.public_id assert resp_data['object'] == 'account' assert resp_data['account_id'] == generic_account.namespace.public_id assert resp_data['email_address'] == generic_account.email_address assert resp_data['name'] == generic_account.name assert resp_data['organization_unit'] == 'folder' assert 'sync_state' in resp_data assert 'server_settings' not in resp_data # Because we're using the gmail account namespace api_client = new_api_client(db, gmail_account.namespace) resp_data = api_client.get_data('/account') assert resp_data['id'] == gmail_account.namespace.public_id assert resp_data['provider'] == 'gmail' assert resp_data['organization_unit'] == 'label' assert 'sync_state' in resp_data assert 'server_settings' not in resp_data
def test_account(db, api_client, generic_account, gmail_account): # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == generic_account.namespace.public_id assert resp_data["object"] == "account" assert resp_data["account_id"] == generic_account.namespace.public_id assert resp_data["email_address"] == generic_account.email_address assert resp_data["name"] == generic_account.name assert resp_data["organization_unit"] == "folder" assert "sync_state" in resp_data assert "server_settings" not in resp_data # Because we're using the gmail account namespace api_client = new_api_client(db, gmail_account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == gmail_account.namespace.public_id assert resp_data["provider"] == "gmail" assert resp_data["organization_unit"] == "label" assert "sync_state" in resp_data assert "server_settings" not in resp_data
def test_account_expanded(db, api_client, generic_account, gmail_account): # Generic accounts expose a `server_settings` attribute # Custom IMAP api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data('/account/?view=expanded') assert resp_data['provider'] == 'custom' assert 'server_settings' in resp_data assert set(resp_data['server_settings']) == set({ 'imap_host': 'imap.custom.com', 'smtp_host': 'smtp.custom.com', 'imap_port': 993, 'smtp_port': 587, 'ssl_required': True}) # Yahoo yahoo_account = add_fake_yahoo_account(db.session) api_client = new_api_client(db, yahoo_account.namespace) resp_data = api_client.get_data('/account/?view=expanded') assert resp_data['provider'] == 'yahoo' assert 'server_settings' in resp_data assert set(resp_data['server_settings']) == set({ 'imap_host': 'imap.mail.yahoo.com', 'smtp_host': 'smtp.mail.yahoo.com', 'imap_port': 993, 'smtp_port': 587, 'ssl_required': True}) # Gmail accounts don't expose a `server_settings` attribute api_client = new_api_client(db, gmail_account.namespace) resp_data = api_client.get_data('/account/?view=expanded') assert resp_data['provider'] == 'gmail' assert 'server_settings' not in resp_data
def test_account_expanded(db, api_client, generic_account, gmail_account): # Generic accounts expose a `server_settings` attribute # Custom IMAP api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data("/account/?view=expanded") assert resp_data["provider"] == "custom" assert "server_settings" in resp_data assert set(resp_data["server_settings"]) == set({ "imap_host": "imap.custom.com", "smtp_host": "smtp.custom.com", "imap_port": 993, "smtp_port": 587, }) # Yahoo yahoo_account = add_fake_yahoo_account(db.session) api_client = new_api_client(db, yahoo_account.namespace) resp_data = api_client.get_data("/account/?view=expanded") assert resp_data["provider"] == "yahoo" assert "server_settings" in resp_data assert set(resp_data["server_settings"]) == set({ "imap_host": "imap.mail.yahoo.com", "smtp_host": "smtp.mail.yahoo.com", "imap_port": 993, "smtp_port": 587, }) # Gmail accounts don't expose a `server_settings` attribute api_client = new_api_client(db, gmail_account.namespace) resp_data = api_client.get_data("/account/?view=expanded") assert resp_data["provider"] == "gmail" assert "server_settings" not in resp_data
def test_message_delete(db, gmail_account): """ Ensure that all associated MessageCategories are deleted when a Message is deleted """ api_client = new_api_client(db, gmail_account.namespace) generic_thread = add_fake_thread(db.session, gmail_account.namespace.id) gen_message = add_fake_message(db.session, gmail_account.namespace.id, generic_thread) category_ids = [] for i in xrange(10): po_data = api_client.post_data('/labels/', {"display_name": str(i)}) assert po_data.status_code == 200 category_ids.append(json.loads(po_data.data)['id']) data = {"label_ids": category_ids} resp = api_client.put_data('/messages/{}'. format(gen_message.public_id), data) assert resp.status_code == 200 associated_mcs = db.session.query(MessageCategory). \ filter(MessageCategory.message_id == gen_message.id).all() assert len(associated_mcs) == 10 db.session.delete(gen_message) db.session.commit() assert db.session.query(MessageCategory). \ filter(MessageCategory.message_id == gen_message.id).all() == []
def test_resource_views( resource_name, db, api_client, generic_account, message, thread, event, label, contact, folder, ): """Exercises various tests for views, mostly related to filtering. Note: this only tests views, it assumes the resources are working as expected.""" # Folders don't work with GMail accounts, need generic IMAP if resource_name == "folders": api_client = new_api_client(db, generic_account.namespace) elements = api_client.get_data("/{}".format(resource_name)) count = api_client.get_data("/{}?view=count".format(resource_name)) assert count["count"] == len(elements) ids = api_client.get_data("/{}?view=ids".format(resource_name)) for i, elem in enumerate(elements): assert isinstance(ids[i], basestring), "&views=ids should return string" assert elem["id"] == ids[i], "view=ids should preserve order"
def test_category_delete(db, gmail_account): """ Ensure that all associated MessageCategories are deleted when a Category is deleted """ api_client = new_api_client(db, gmail_account.namespace) po_data = api_client.post_data('/labels/', {"display_name": "Test_Label"}) assert po_data.status_code == 200 category_public_id = json.loads(po_data.data)['id'] category = db.session.query(Category).filter( Category.public_id == category_public_id).one() category_id = category.id for i in xrange(10): generic_thread = add_fake_thread(db.session, gmail_account.namespace.id) gen_message = add_fake_message(db.session, gmail_account.namespace.id, generic_thread) data = {"label_ids": [category_public_id]} resp = api_client.put_data('/messages/{}'. format(gen_message.public_id), data) assert resp.status_code == 200 associated_mcs = db.session.query(MessageCategory). \ filter(MessageCategory.category_id == category_id).all() assert len(associated_mcs) == 10 db.session.delete(category) db.session.commit() assert db.session.query(MessageCategory). \ filter(MessageCategory.category_id == category_id).all() == []
def test_gmail_pagination(db, default_account, patch_crispin_client, patch_handler_from_provider, folder): for i in range(10): thread = add_fake_thread(db.session, default_account.namespace.id) message = add_fake_message(db.session, default_account.namespace.id, thread=thread, from_addr=[{ 'name': '', 'email': '{}@test.com'.format(str(i)) }], subject='hi', g_msgid=i, received_date=datetime.datetime( 2000 + i, 1, 1, 1, 0, 0)) add_fake_imapuid(db.session, default_account.id, message, folder, i) first_ten_messages_db = db.session.query(Message)\ .filter(Message.namespace_id == default_account.namespace.id). \ order_by(desc(Message.received_date)). \ limit(10).all() api_client = new_api_client(db, default_account.namespace) first_ten_messages_api = api_client.get_data('/messages/search?q=hi' '&limit=10') assert len(first_ten_messages_api) == len(first_ten_messages_db) for db_message, api_message in zip(first_ten_messages_db, first_ten_messages_api): assert db_message.public_id == api_message['id'] imap_uids = db.session.query(ImapUid).join(Message) \ .filter( ImapUid.message_id == Message.id, Message.g_msgid != None).all() uids = [uid.msg_uid for uid in imap_uids] first_ten_threads_db = db.session.query(Thread) \ .join(Message) \ .join(ImapUid) \ .filter(ImapUid.account_id == default_account.id, ImapUid.msg_uid.in_(uids), Thread.id == Message.thread_id)\ .order_by(desc(Message.received_date)) \ .limit(10).all() first_ten_threads_api = api_client.get_data('/threads/search?q=hi' '&limit=10') assert len(first_ten_threads_api) == len(first_ten_threads_db) for db_thread, api_thread in zip(first_ten_threads_db, first_ten_threads_api): assert db_thread.public_id == api_thread['id']
def test_no_auth(db, generic_account): # noqa # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) api_client.auth_header = {} response = api_client.get_raw('/account') assert response.status_code == 401
def test_smtp_ssl_verification_bad_cert(db, bad_cert_smtp_server, example_draft, local_smtp_account, api_client, patched_smtp): api_client = new_api_client(db, local_smtp_account.namespace) gevent.sleep(0.2) # let SMTP daemon start up r = api_client.post_data('/send', example_draft) assert r.status_code == 200
def test_invalid_basic_auth(db, generic_account): # noqa api_client = new_api_client(db, generic_account.namespace) api_client.auth_header = { 'Authorization': 'Basic {}'.format(b64encode(BAD_TOKEN + ':')) } response = api_client.get_raw('/account') assert response.status_code == 401
def test_basic_auth(db, generic_account): # noqa api_client = new_api_client(db, generic_account.namespace) response = api_client.get_raw('/account') assert response.status_code == 200 resp_data = json.loads(response.data) assert resp_data['id'] == generic_account.namespace.public_id
def test_folders_labels_delete(db, api_client, generic_account, gmail_account): api_client = new_api_client(db, generic_account.namespace) # Generic IMAP threads, messages have a 'folders' field generic_thread = add_fake_thread(db.session, generic_account.namespace.id) generic_message = add_fake_message(db.session, generic_account.namespace.id, generic_thread) resp = api_client.post_data('/folders/', {"display_name": "Test_Folder"}) assert resp.status_code == 200 generic_folder = json.loads(resp.data) data = {"folder_id": generic_folder['id']} # Add message to folder api_client.put_data('/messages/{}'.format(generic_message.public_id), data) # try deleting folder that contains a message delete_data = api_client.delete('/folders/{}'.format(generic_folder['id'])) assert delete_data.status_code == 403 resp = api_client.post_data('/folders/', {"display_name": "Test_Folder2"}) empty_folder = json.loads(resp.data) # try deleting folder that contains a message delete_data = api_client.delete('/folders/{}'.format(empty_folder['id'])) assert delete_data.status_code == 200 # Because we're using the generic_account namespace api_client = new_api_client(db, gmail_account.namespace) # Gmail threads, messages have a 'labels' field gmail_thread = add_fake_thread(db.session, gmail_account.namespace.id) gmail_message = add_fake_message(db.session, gmail_account.namespace.id, gmail_thread) resp = api_client.post_data('/labels/', {"display_name": "Test_Labels"}) assert resp.status_code == 200 gmail_label = json.loads(resp.data) data = {"folder_id": gmail_label['id']} # Add label to message api_client.put_data('/messages/{}'.format(gmail_message.public_id), data) # try deleting label delete_data = api_client.delete('/labels/{}'.format(gmail_label['id'])) assert delete_data.status_code == 200
def test_folders_labels(db, api_client, generic_account, gmail_account): # Generic IMAP threads, messages have a 'folders' field generic_thread = add_fake_thread(db.session, generic_account.namespace.id) generic_message = add_fake_message(db.session, generic_account.namespace.id, generic_thread) # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data( '/threads/{}'.format(generic_thread.public_id)) assert resp_data['id'] == generic_thread.public_id assert resp_data['object'] == 'thread' assert 'folders' in resp_data and 'labels' not in resp_data resp_data = api_client.get_data( '/messages/{}'.format(generic_message.public_id)) assert resp_data['id'] == generic_message.public_id assert resp_data['object'] == 'message' assert 'folder' in resp_data and 'labels' not in resp_data # Because we're using the generic_account namespace api_client = new_api_client(db, gmail_account.namespace) # Gmail threads, messages have a 'labels' field gmail_thread = add_fake_thread(db.session, gmail_account.namespace.id) gmail_message = add_fake_message(db.session, gmail_account.namespace.id, gmail_thread) resp_data = api_client.get_data( '/threads/{}'.format(gmail_thread.public_id)) assert resp_data['id'] == gmail_thread.public_id assert resp_data['object'] == 'thread' assert 'labels' in resp_data and 'folders' not in resp_data resp_data = api_client.get_data( '/messages/{}'.format(gmail_message.public_id)) assert resp_data['id'] == gmail_message.public_id assert resp_data['object'] == 'message' assert 'labels' in resp_data and 'folders' not in resp_data
def test_folders_labels(db, api_client, generic_account, gmail_account): # Generic IMAP threads, messages have a 'folders' field generic_thread = add_fake_thread(db.session, generic_account.namespace.id) generic_message = add_fake_message(db.session, generic_account.namespace.id, generic_thread) # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data('/threads/{}'.format( generic_thread.public_id)) assert resp_data['id'] == generic_thread.public_id assert resp_data['object'] == 'thread' assert 'folders' in resp_data and 'labels' not in resp_data resp_data = api_client.get_data('/messages/{}'.format( generic_message.public_id)) assert resp_data['id'] == generic_message.public_id assert resp_data['object'] == 'message' assert 'folder' in resp_data and 'labels' not in resp_data # Because we're using the generic_account namespace api_client = new_api_client(db, gmail_account.namespace) # Gmail threads, messages have a 'labels' field gmail_thread = add_fake_thread(db.session, gmail_account.namespace.id) gmail_message = add_fake_message(db.session, gmail_account.namespace.id, gmail_thread) resp_data = api_client.get_data('/threads/{}'.format( gmail_thread.public_id)) assert resp_data['id'] == gmail_thread.public_id assert resp_data['object'] == 'thread' assert 'labels' in resp_data and 'folders' not in resp_data resp_data = api_client.get_data('/messages/{}'.format( gmail_message.public_id)) assert resp_data['id'] == gmail_message.public_id assert resp_data['object'] == 'message' assert 'labels' in resp_data and 'folders' not in resp_data
def test_invalid_basic_auth(db, generic_account): # noqa api_client = new_api_client(db, generic_account.namespace) api_client.auth_header = { "Authorization": "Basic {}".format(b64encode((BAD_TOKEN + ":").encode()).decode()) } response = api_client.get_raw("/account") assert response.status_code == 401
def test_correct_thread_count(db, default_account, patch_crispin_client, patch_handler_from_provider, sorted_gmail_messages): api_client = new_api_client(db, default_account.namespace) first_two_threads = api_client.get_data('/threads/search?q=hi' '&limit=2') assert len(first_two_threads) == 2
def test_gmail_pagination(db, default_account, patch_crispin_client, patch_handler_from_provider, folder): for i in range(10): thread = add_fake_thread(db.session, default_account.namespace.id) message = add_fake_message(db.session, default_account.namespace.id, thread=thread, from_addr=[{'name': '', 'email': '{}@test.com'.format(str(i))}], subject='hi', g_msgid=i, received_date=datetime. datetime(2000 + i, 1, 1, 1, 0, 0)) add_fake_imapuid(db.session, default_account.id, message, folder, i) first_ten_messages_db = db.session.query(Message)\ .filter(Message.namespace_id == default_account.namespace.id). \ order_by(desc(Message.received_date)). \ limit(10).all() api_client = new_api_client(db, default_account.namespace) first_ten_messages_api = api_client.get_data('/messages/search?q=hi' '&limit=10') assert len(first_ten_messages_api) == len(first_ten_messages_db) for db_message, api_message in zip(first_ten_messages_db, first_ten_messages_api): assert db_message.public_id == api_message['id'] imap_uids = db.session.query(ImapUid).join(Message) \ .filter( ImapUid.message_id == Message.id, Message.g_msgid != None).all() uids = [uid.msg_uid for uid in imap_uids] first_ten_threads_db = db.session.query(Thread) \ .join(Message) \ .join(ImapUid) \ .filter(ImapUid.account_id == default_account.id, ImapUid.msg_uid.in_(uids), Thread.id == Message.thread_id)\ .order_by(desc(Message.received_date)) \ .limit(10).all() first_ten_threads_api = api_client.get_data('/threads/search?q=hi' '&limit=10') assert len(first_ten_threads_api) == len(first_ten_threads_db) for db_thread, api_thread in zip(first_ten_threads_db, first_ten_threads_api): assert db_thread.public_id == api_thread['id']
def test_smtp_ssl_verification_bad_cert(db, bad_cert_smtp_server, example_draft, local_smtp_account, api_legacy_client): error_msg = 'SMTP server SSL certificate verify failed' api_client = new_api_client(db, local_smtp_account.namespace) gevent.sleep(0.2) # let SMTP daemon start up r = api_client.post_data('/send', example_draft) assert r.status_code == 503 assert json.loads(r.data)['message'] == error_msg
def test_account_repr_for_new_account(db): account = add_fake_yahoo_account(db.session) # Sync for the account has not started yet. assert account.sync_state is None # However the API-returned account object has `sync_state=running` # so API clients can do the right thing. api_client = new_api_client(db, account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == account.namespace.public_id assert resp_data["sync_state"] == "running" # Verify other sync_states are not masked. account.sync_state = "invalid" db.session.commit() api_client = new_api_client(db, account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == account.namespace.public_id assert resp_data["sync_state"] == "invalid"
def test_account_repr_for_new_account(db): account = add_fake_yahoo_account(db.session) # Sync for the account has not started yet. assert account.sync_state is None # However the API-returned account object has `sync_state=running` # so API clients can do the right thing. api_client = new_api_client(db, account.namespace) resp_data = api_client.get_data('/account') assert resp_data['id'] == account.namespace.public_id assert resp_data['sync_state'] == 'running' # Verify other sync_states are not masked. account.sync_state = 'invalid' db.session.commit() api_client = new_api_client(db, account.namespace) resp_data = api_client.get_data('/account') assert resp_data['id'] == account.namespace.public_id assert resp_data['sync_state'] == 'invalid'
def test_bearer_token_auth(db, generic_account): # noqa api_client = new_api_client(db, generic_account.namespace) api_client.auth_header = { 'Authorization': 'Bearer {}'.format(generic_account.namespace.public_id) } response = api_client.get_raw('/account') assert response.status_code == 200 resp_data = json.loads(response.data) assert resp_data['id'] == generic_account.namespace.public_id
def test_label_post(db, gmail_account): api_client = new_api_client(db, gmail_account.namespace) po_data = api_client.post_data('/labels/', {"display_name": "Test_Label"}) assert po_data.status_code == 200 category_id = json.loads(po_data.data)['id'] category = db.session.query(Category).filter( Category.public_id == category_id).one() assert category.display_name == 'Test_Label' assert category.name == '' assert category.type == 'label' assert category.deleted_at == EPOCH assert category.is_deleted is False
def label_client(db, gmail_account): api_client = new_api_client(db, gmail_account.namespace) # Whereas calling generic_account always makes a new IMAP account, # calling gmail_account checks first to see if there's an existing # Gmail account and uses it if so. This can cause namespace # conflicts if a label is "created" more than once. Since # labels can't be deleted and then re-created, this fixture only # makes a new label if there are no existing labels. g_data = api_client.get_raw('/labels/') if not json.loads(g_data.data): api_client.post_data('/labels/', {"display_name": "Test_Label"}) return api_client
def test_folders_labels(db, api_client, generic_account, gmail_account): # Generic IMAP threads, messages have a 'folders' field generic_thread = add_fake_thread(db.session, generic_account.namespace.id) generic_message = add_fake_message(db.session, generic_account.namespace.id, generic_thread) # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data("/threads/{}".format(generic_thread.public_id)) assert resp_data["id"] == generic_thread.public_id assert resp_data["object"] == "thread" assert "folders" in resp_data and "labels" not in resp_data resp_data = api_client.get_data("/messages/{}".format(generic_message.public_id)) assert resp_data["id"] == generic_message.public_id assert resp_data["object"] == "message" assert "folder" in resp_data and "labels" not in resp_data # Because we're using the generic_account namespace api_client = new_api_client(db, gmail_account.namespace) # Gmail threads, messages have a 'labels' field gmail_thread = add_fake_thread(db.session, gmail_account.namespace.id) gmail_message = add_fake_message(db.session, gmail_account.namespace.id, gmail_thread) resp_data = api_client.get_data("/threads/{}".format(gmail_thread.public_id)) assert resp_data["id"] == gmail_thread.public_id assert resp_data["object"] == "thread" assert "labels" in resp_data and "folders" not in resp_data resp_data = api_client.get_data("/messages/{}".format(gmail_message.public_id)) assert resp_data["id"] == gmail_message.public_id assert resp_data["object"] == "message" assert "labels" in resp_data and "folders" not in resp_data
def test_folder_post(db, generic_account): api_client = new_api_client(db, generic_account.namespace) po_data = api_client.post_data("/folders/", {"display_name": "Test_Folder"}) assert po_data.status_code == 200 category_id = json.loads(po_data.data)["id"] category = ( db.session.query(Category).filter(Category.public_id == category_id).one() ) assert category.display_name == "Test_Folder" assert category.name == "" assert category.type == "folder" assert category.deleted_at == EPOCH assert category.is_deleted is False
def test_smtp_ssl_verification_bad_cert( db, bad_cert_smtp_server, example_draft, local_smtp_account, api_client, patched_smtp, ): api_client = new_api_client(db, local_smtp_account.namespace) while len(asyncore.socket_map) < 1: gevent.sleep(0) # let SMTP daemon start up r = api_client.post_data("/send", example_draft) assert r.status_code == 200
def test_account(db, api_client, generic_account, gmail_account): # Because we're using the generic_account namespace api_client = new_api_client(db, generic_account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == generic_account.namespace.public_id assert resp_data["object"] == "account" assert resp_data["account_id"] == generic_account.namespace.public_id assert resp_data["email_address"] == generic_account.email_address assert resp_data["name"] == generic_account.name assert resp_data["organization_unit"] == "folder" assert "sync_state" in resp_data # Because we're using the gmail account namespace api_client = new_api_client(db, gmail_account.namespace) resp_data = api_client.get_data("/account") assert resp_data["id"] == gmail_account.namespace.public_id assert resp_data["provider"] == "gmail" assert resp_data["organization_unit"] == "label" assert "sync_state" in resp_data
def test_resource_views(resource_name, db, api_client, generic_account, message, thread, event, label, contact, folder): """Exercises various tests for views, mostly related to filtering. Note: this only tests views, it assumes the resources are working as expected.""" # Folders don't work with GMail accounts, need generic IMAP if resource_name == 'folders': api_client = new_api_client(db, generic_account.namespace) elements = api_client.get_data('/{}'.format(resource_name)) count = api_client.get_data('/{}?view=count'.format(resource_name)) assert count["count"] == len(elements) ids = api_client.get_data('/{}?view=ids'.format(resource_name)) for i, elem in enumerate(elements): assert isinstance(ids[i], basestring), \ "&views=ids should return string" assert elem["id"] == ids[i], "view=ids should preserve order"
def test_message_labels(db, gmail_account): # Because we're using the gmail_account namespace api_client = new_api_client(db, gmail_account.namespace) # Gmail threads, messages have a 'labels' field gmail_thread = add_fake_thread(db.session, gmail_account.namespace.id) gmail_message = add_fake_message(db.session, gmail_account.namespace.id, gmail_thread) resp_data = api_client.get_data("/threads/{}".format( gmail_thread.public_id)) assert resp_data["id"] == gmail_thread.public_id assert resp_data["object"] == "thread" assert "labels" in resp_data and "folders" not in resp_data resp_data = api_client.get_data("/messages/{}".format( gmail_message.public_id)) assert resp_data["id"] == gmail_message.public_id assert resp_data["object"] == "message" assert "labels" in resp_data and "folders" not in resp_data
def test_invalid_bearer_token_auth(db, generic_account): # noqa api_client = new_api_client(db, generic_account.namespace) api_client.auth_header = {'Authorization': 'Bearer {}'.format(BAD_TOKEN)} response = api_client.get_raw('/account') assert response.status_code == 401
def imap_api_client(db, generic_account): return new_api_client(db, generic_account.namespace)
def test_folder_post(db, generic_account): api_client = new_api_client(db, generic_account.namespace) po_data = api_client.post_data('/folders/', {"display_name": "Test_Folder"}) assert po_data.status_code == 200
def folder_client(db, generic_account): api_client = new_api_client(db, generic_account.namespace) api_client.post_data('/folders/', {"display_name": "Test_Folder"}) return api_client
def test_label_post(db, gmail_account): api_client = new_api_client(db, gmail_account.namespace) po_data = api_client.post_data('/labels/', {"display_name": "Test_Label"}) assert po_data.status_code == 200