def test_contact_search(api_client): """Basic smoke tests for search.""" search_data = [{'name': 'Some Dude', 'email': '*****@*****.**'}, {'name': 'Some Other Dude', 'email': '*****@*****.**'}, {'name': 'Somebody Else', 'email': '*****@*****.**'}] for contact in search_data: api_client.add_contact(ACCOUNT_ID, contact) result = api_client.search_contacts(ACCOUNT_ID, 'Some') assert len(result) == 3 result = api_client.search_contacts(ACCOUNT_ID, 'Some', 1) assert len(result) == 1 result = api_client.search_contacts(ACCOUNT_ID, 'Some Other') assert len(result) == 1 assert result[0]['name'] == 'Some Other Dude' assert result[0]['email'] == '*****@*****.**' result = api_client.search_contacts(ACCOUNT_ID, 'Other') assert len(result) == 1 assert result[0]['name'] == 'Some Other Dude' assert result[0]['email'] == '*****@*****.**' result = api_client.search_contacts(ACCOUNT_ID, 'somebody.else') assert len(result) == 1 assert result[0]['name'] == 'Somebody Else' assert result[0]['email'] == '*****@*****.**'
def test_search_missing_fields(api_client): api_client.add_contact(ACCOUNT_ID, {'name': 'Some Dude', 'email': None}) api_client.add_contact(ACCOUNT_ID, {'name': None, 'email': 'someemail'}) result = api_client.search_contacts(ACCOUNT_ID, 'Some') assert len(result) == 2