def testGMailRelField(self):
    feed = self._CreateGoogleContactFeed([{'emails': [('mike@emailscrubbed.com', None)],
                                           'name': 'Mike Purtell'},
                                          {'phones': [('+13191234567', 'Work')],
                                           'name': 'J. Smith'},
                                          {'phones': [('+13195550210', 'cabin')],
                                           'name': 'K. Smith'}])

    # Check that the feed generated what we intend to test.
    # 'None' should generate the 'other' schema identifier for the rel field and no label field:
    self.assertEqual(feed['feed']['entry'][0]['gd$email'][0]['rel'], 'http://schemas.google.com/g/2005#other')
    self.assertNotIn('label', feed['feed']['entry'][0]['gd$email'][0])

    # Check that we got the desired rel value and that the label field didn't get set.
    self.assertEqual(feed['feed']['entry'][1]['gd$phoneNumber'][0]['rel'], 'http://schemas.google.com/g/2005#work')
    self.assertNotIn('label', feed['feed']['entry'][1]['gd$phoneNumber'][0])

    # We just care that the label got set, regardless of the rel field, because we give it priority.
    self.assertEqual(feed['feed']['entry'][2]['gd$phoneNumber'][0]['label'], 'cabin')

    self._TestFetchContacts(self._andy_google, self._andy_user.user_id, feed)

    # Check the actual contacts, not the ones in the model.
    contacts = self._RunAsync(Contact.RangeQuery, self._client, self._andy_user.user_id, None, 10, None)

    self.assertEqual(len(contacts), 3)
    contacts.sort(key=lambda x: x.name)
    self.assertEqual(contacts[0].name, 'J. Smith')
    # This one translates from the well known value in the rel field.
    self.assertEqual(contacts[0].identities_properties[0][1], 'Work')
    self.assertEqual(contacts[1].name, 'K. Smith')
    # This one takes the label field.
    self.assertEqual(contacts[1].identities_properties[0][1], 'cabin')
    self.assertEqual(contacts[2].name, 'Mike Purtell')
    # This one has the well known value, '...#other, in the rel field and we translate that to None.
    self.assertEqual(contacts[2].identities_properties[0][1], None)
Check mapping of Google's wellknown contact relations.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/test/fetch_contacts_test.py/FetchContactsTestCase.testGMailRelField