def test_login(): response = client.post("/", json={ "query": """mutation{{ CreateUser(email: "{email}", password: "******"){{ user{{ id email }} }} }}""".format(email=EMAIL_TEST, password=PASSWORD_TEST) }) data = response.json() assert 'errors' not in data user_id = data['data']['CreateUser']['user']['id'] response = client.post("/", json={ "query": """{{ login(email: "{email}",password:"******") }}""".format(email=EMAIL_TEST, password=PASSWORD_TEST) }) data = response.json() assert 'errors' not in data assert data['data']['login'] delete_user(Session, user_id)
def test_feed(): response = client.post("/", json={ "query": """mutation{{ CreateUser(email: "{email}", password: "******"){{ user{{ id email }} }} }}""".format(email=EMAIL_TEST, password=PASSWORD_TEST) }) user_id = response.json()['data']['CreateUser']['user']['id'] response = client.post("/", json={ "query": """ mutation{{ SubscribeFeed( urlFeed: "{url_feed}", userId: {user_id}, title:"{title}"){{ idRss }} }}""".format(url_feed=TEST_RSS, user_id=user_id, title=TITLE_TEST) }) data = response.json() assert 'errors' not in data rss_id = data['data']['SubscribeFeed']['idRss'] assert rss_id save_feeds(Session) response = client.post("/", json={ "query": """ query{{ feed(rssId:{rss_id}){{ title summary published image author }} }} """.format(rss_id=rss_id) }) data = response.json() assert 'errors' not in data assert [] != data['data']['feed'] delete_user(Session, user_id) delete_rss(Session, rss_id) delete_feeds_by_rss_id(Session, rss_id)
def remove_user(): """Remove a user""" try: crud.delete_user(session['user']) session.pop('user', None) return jsonify({'success': True}) except Exception as err: return jsonify({'success': False, 'error': str(err)})
def delete_user(user_name: str, db: Session = Depends(get_db)): if not crud.user_username_exists(db, user_name): raise HTTPException(status_code=400, detail="Username not registered!") user_workouts = crud.get_user_workouts(db, user_name=user_name) is_deleted = [] for workout in user_workouts: is_deleted.append(crud.delete_workout(workout_id=workout.workoutID, db=db)) is_deleted.append(s3_bucket.delete_bucket(workout_id=workout.workoutID)) crud.delete_user(db=db, user_name=user_name) return (not crud.user_username_exists(db, user_name)) and all(is_deleted)
async def delete_user(userId: int, response: Response, db: Session = Depends(get_db)): db_user = crud.delete_user(db, userId) if db_user is None: response.status_code = status.HTTP_404_NOT_FOUND return None
def test_subscribe_feed(): response = client.post("/", json={ "query": """mutation{{ CreateUser(email: "{email}", password: "******"){{ user{{ id email }} }} }}""".format(email=EMAIL_TEST, password=PASSWORD_TEST) }) user_id = response.json()['data']['CreateUser']['user']['id'] response = client.post("/", json={ "query": """ mutation{{ SubscribeFeed( urlFeed: "{url_feed}", userId: {user_id}, title:"{title}"){{ idRss }} }}""".format(url_feed=TEST_RSS, user_id=user_id, title=TITLE_TEST) }) data = response.json() assert 'errors' not in data feed_id = data['data']['SubscribeFeed']['idRss'] assert feed_id delete_user(Session, user_id) delete_rss(Session, feed_id)
def delete_user(db: Session=Depends(get_db), id: int = None): if id is None: raise HTTPException(status_code=400, detail="Id must be included in parameter") return crud.delete_user(db=db, id=id)
def delete_user(user_id: int, db: Session = Depends(get_db)): crud.delete_user(db=db, user_id=user_id)
from mk_legacy_client import make_keystone_client from crud import delete_domain, delete_group, delete_user cli = make_keystone_client() delete_domain("SBT") delete_group("Usuarios SBT") delete_user("Silvio Santos") domainSBT = cli.domains.create(name="SBT", description="Dominio SBT", enabled=True) print "Domain SBT criado com sucesso" print domainSBT print "-----------" group1 = cli.groups.create(name="Usuarios SBT", description="Usuarios SBT", domain=domainSBT) print "Grupo criado com sucesso" print group1 print "-----------" silvio = cli.users.create(name="Silvio Santos", description="Dono do SBT", password="******", email="*****@*****.**", enabled=True) print "Usuario Silvio criado com sucesso" print silvio print "-----------"
def delete_user(email: str, db: Session = Depends(get_db)): db_user = crud.get_user_by_email(db, email=email) if db_user is None: raise HTTPException(status_code=400, detail="User does not exist.") return crud.delete_user(db, email)
async def mutate(self, info, name): detail = crud.delete_user(name) print(detail) return DeleteAccount(success=UploadResponse(result=detail))
async def delete_user(id, db: Session = Depends(get_db),) -> str: # noqa return crud.delete_user(db=db, id=id)