def test_clinvar_submissions(app, institute_obj, clinvar_variant, clinvar_casedata): """"Test the web page containing the clinvar submissions for an institute""" # GIVEN an institute with a clinvar submission store.create_submission(institute_obj["_id"]) open_submission = store.get_open_clinvar_submission(institute_obj["_id"]) submission_with_data = store.add_to_submission( open_submission["_id"], ([clinvar_variant], [clinvar_casedata])) assert submission_with_data # GIVEN an initialized app and a valid user and institute with app.test_client() as client: # GIVEN that the user could be logged in resp = client.get(url_for("auto_login")) assert resp.status_code == 200 # When visiting the clinvar submission page (get request) resp = client.get( url_for( "overview.clinvar_submissions", institute_id=institute_obj["internal_id"], )) # a successful response should be returned assert resp.status_code == 200 assert str(submission_with_data["_id"]) in str(resp.data)
def test_rename_clinvar_samples(app, institute_obj, clinvar_variant, clinvar_casedata): """Test the form button triggering the renaming of samples for a clinvar submission""" # GIVEN an institute with a clinvar submission store.create_submission(institute_obj["_id"]) open_submission = store.get_open_clinvar_submission(institute_obj["_id"]) submission_with_data = store.add_to_submission( open_submission["_id"], ([clinvar_variant], [clinvar_casedata])) assert submission_with_data["_id"] # GIVEN an initialized app and a valid user with app.test_client() as client: # GIVEN that the user could be logged in resp = client.get(url_for("auto_login")) case_id = clinvar_casedata["case_id"] old_name = clinvar_casedata["individual_id"] form_data = dict(new_name="new_sample_name", ) referer = url_for("overview.clinvar_submissions", institute_id=institute_obj["internal_id"]) # WHEN the sample name is edited from the submission page (POST request) resp = client.post( url_for( f"overview.clinvar_rename_casedata", submission=submission_with_data["_id"], case=case_id, old_name=old_name, ), data=form_data, headers={"referer": referer}, ) # a successful response should be redirect to the submssions page assert resp.status_code == 302 # And the sample name should have been updated in the database updated_casedata = store.clinvar_collection.find_one( {"_id": clinvar_casedata["_id"]}) assert updated_casedata["individual_id"] != clinvar_casedata[ "individual_id"]