    def add_spawner(user, name='', active=True, ready=True):
        """Add a spawner in a requested state

        If active, should turn up in an active query
        If active and ready, should turn up in a ready query
        If not active, should turn up in an inactive query
        """
        spawner = user.spawners[name]
        db.commit()
        if active:
            orm_server = orm.Server()
            db.add(orm_server)
            db.commit()
            spawner.server = Server(orm_server=orm_server)
            db.commit()
            if not ready:
                spawner._spawn_pending = True
        return spawner
Add a spawner in a requested state

If active, should turn up in an active query
If active and ready, should turn up in a ready query
If not active, should turn up in an inactive query
jupyterhub/tests/test_api.py