'Check database upgraded successfully for domain specific roles.
The following items need to be checked:
- The domain_id column has been added
- That it has been added to the uniqueness constraints
- Existing roles have their domain_id columns set to the specific
string of \'<<null>>\''

def test_add_domain_specific_roles(self):

    NULL_DOMAIN_ID = '<<null>>'
    self.upgrade(87)
    session = self.sessionmaker()
    role_table = sqlalchemy.Table('role', self.metadata, autoload=True)
    role_id = uuid.uuid4().hex
    self.insert_dict(session, 'role', {'id': role_id, 'name': uuid.uuid4().hex})
    session.close()
    self.upgrade(88)
    session = self.sessionmaker()
    self.assertTableColumns('role', ['id', 'name', 'domain_id', 'extra'])
    inspector = reflection.Inspector.from_engine(self.engine)
    constraints = inspector.get_unique_constraints('role')
    constraint_columns = [constraint['column_names'] for constraint in constraints if (constraint['name'] == 'ixu_role_name_domain_id')]
    self.assertIn('domain_id', constraint_columns[0])
    role_table = sqlalchemy.Table('role', self.metadata, autoload=True)
    cols = [role_table.c.domain_id]
    filter = (role_table.c.id == role_id)
    statement = sqlalchemy.select(cols).where(filter)
    role_entry = session.execute(statement).fetchone()
    self.assertEqual(NULL_DOMAIN_ID, role_entry[0])
