'Assert that the given user result is valid'

def assertUserIsValid(self, user):

    self.assertItemsEqual(user.keys(), ['email', 'id', 'name', 'username', 'preferences', 'url'])
    self.assertItemsEqual(user['preferences'].items(), [(pref.key, pref.value) for pref in self.prefs if (pref.user.id == user['id'])])
    self.assertSelfReferential(user)
