@pytest.mark.parametrize('api_version', API_VERSIONS)
def test_message_label_updates(db, api_client, default_account, api_version, custom_label):
 headers = dict()
 headers['Api-Version'] = api_version
 gmail_thread = add_fake_thread(db.session, default_account.namespace.id)
 gmail_message = add_fake_message(db.session, default_account.namespace.id, gmail_thread)
 resp_data = api_client.get_data('/messages/{}'.format(gmail_message.public_id), headers=headers)
 assert (resp_data['labels'] == [])
 category = custom_label.category
 update = dict(labels=[category.public_id])
 resp = api_client.put_data('/messages/{}'.format(gmail_message.public_id), update, headers=headers)
 resp_data = json.loads(resp.data)
 if (api_version == API_VERSIONS[0]):
  assert (len(resp_data['labels']) == 1)
  assert (resp_data['labels'][0]['id'] == category.public_id)
 else:
  assert (resp_data['labels'] == [])

@ pytest . mark . parametrize ( 'api_version' , API_VERSIONS ) def test_message_label_updates ( db , api_client , default_account , api_version , custom_label ) : headers = dict ( ) headers [ 'Api-Version' ] = api_version gmail_thread = add_fake_thread ( db . session , default_account . namespace . id ) gmail_message = add_fake_message ( db . session , default_account . namespace . id , gmail_thread ) resp_data = api_client . get_data ( '/messages/{}' . format ( gmail_message . public_id ) , headers = headers ) assert ( resp_data [ 'labels' ] == [ ] ) category = custom_label . category update = dict ( labels = [ category . public_id ] ) resp = api_client . put_data ( '/messages/{}' . format ( gmail_message . public_id ) , update , headers = headers ) resp_data = json . loads ( resp . data ) if ( api_version == API_VERSIONS [ 0 ] ) : assert ( len ( resp_data [ 'labels' ] ) == 1 ) assert ( resp_data [ 'labels' ] [ 0 ] [ 'id' ] == category . public_id ) else : assert ( resp_data [ 'labels' ] == [ ] )
check that you can update a message .