'Check user is in correct backend.
As part of the tests, we want to force ourselves to manually
select the driver for a given domain, to make sure the entity
ended up in the correct backend.'

def check_user(self, user, domain_id, expected_status):

    driver = self.identity_api._select_identity_driver(domain_id)
    (unused, unused, entity_id) = self.identity_api._get_domain_driver_and_entity_id(user['id'])
    if (expected_status == http_client.OK):
        ref = driver.get_user(entity_id)
        ref = self.identity_api._set_domain_id_and_mapping(ref, domain_id, driver, map.EntityType.USER)
        user = user.copy()
        del user['password']
        self.assertDictEqual(user, ref)
    else:
        try:
            driver.get_user(entity_id)
        except expected_status:
            pass
