def test_add_evaluation_comments_only(self): """Add comments""" str_item = STRFactory() current_version = str_item.panel.version str_item.evaluation.all().delete() url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) str_data = { "comments": fake.sentence(), } res = self.client.post(url, str_data) assert res.status_code == 302 v01gene = str_item.panel.panel.active_panel.get_str(str_item.name) assert v01gene.evaluation.get(user=self.gel_user).comments.count() == 1 str_data = { "comments": fake.sentence(), } res = self.client.post(url, str_data) assert v01gene.evaluation.get(user=self.gel_user).comments.count() == 2 assert current_version == str_item.panel.panel.active_panel.version
def test_form_should_be_prefilled(self): str_item = STRFactory() str_item.evaluation.all().delete() url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) str_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "publications": ";".join([fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } self.client.post(url, str_data) url = reverse_lazy('panels:evaluation', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) res = self.client.get(url) assert res.content.find( str.encode('<option value="{}" selected>'.format( str_data['moi']))) != -1
def test_change_penetrance(self): """Test if a curator can change Gene penetrance""" str_item = STRFactory( penetrance=GenePanelEntrySnapshot.PENETRANCE.Incomplete ) url = reverse_lazy('panels:edit_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) str_data = { 'name': str_item.name, 'chromosome': '1', 'position_37_0': '12345', 'position_37_1': '12346', 'position_38_0': '12345', 'position_38_1': '123456', 'repeated_sequence': 'ATAT', 'normal_repeats': '2', 'pathogenic_repeats': '5', "gene": str_item.gene_core.pk, "gene_name": "Gene name", "source": set([ev.name for ev in str_item.evidence.all()]), "tags": [tag.pk for tag in str_item.tags.all()], "publications": ";".join([publication for publication in str_item.publications]), "phenotypes": ";".join([phenotype for phenotype in str_item.phenotypes]), "moi": str_item.moi, "penetrance": GenePanelEntrySnapshot.PENETRANCE.Complete, } res = self.client.post(url, str_data) assert res.status_code == 302 new_str = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert new_str.penetrance != str_item.penetrance
def test_update_rating(self): str_item = STRFactory() str_item.evaluation.all().delete() url = reverse_lazy('panels:update_entity_rating', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) new_status = 0 data = {'comment': fake.sentence(), 'status': new_status} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count() == 1 assert res.content.find(str.encode(data['comment'])) != -1 assert gene.saved_gel_status == new_status new_status = 1 data = {'comment': fake.sentence(), 'status': new_status} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count( ) == 3 # FIXME old comments are deleted even for the current object... assert gene.saved_gel_status == new_status new_status = 2 data = {'comment': fake.sentence(), 'status': new_status} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count() == 6 assert gene.saved_gel_status == new_status new_status = 3 data = {'comment': fake.sentence(), 'status': new_status} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count() == 10 assert gene.saved_gel_status == new_status assert gene.panel.version != str_item.panel.version
def test_download_panel_contains_strs(self): gpes = GenePanelEntrySnapshotFactory() gps = gpes.panel strs = STRFactory(repeated_sequence="ATATCGCGN", panel=gps) res = self.client.get(reverse_lazy('panels:download_panel_tsv', args=(gps.panel.pk, '01234'))) self.assertEqual(res.status_code, 200) self.assertTrue(res.content.find(strs.repeated_sequence.encode()) != 1)
def test_str_evaluation(self): str_item = STRFactory() url = reverse_lazy('panels:evaluation', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) res = self.client.get(url) assert res.status_code == 200
def test_delete_comment(self): str_item = STRFactory() current_version = str_item.panel.version evaluation_url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) gene_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "comments": fake.sentence(), "publications": ";".join([fake.sentence(), fake.sentence()]), "phenotypes": ";".join([fake.sentence(), fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } self.client.post(evaluation_url, gene_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) evaluation = gene.evaluation.get(user=self.gel_user) assert evaluation.comments.count() == 1 delete_comment_url = reverse_lazy('panels:delete_comment_by_user', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name, 'comment_pk': evaluation.comments.first().pk }) res = self.client.get(delete_comment_url, HTTP_X_REQUESTED_WITH='XMLHttpRequest') assert res.json().get('status') == 200 assert evaluation.comments.count() == 0 assert res.content.find(str.encode('Your review')) != -1 assert current_version == str_item.panel.panel.active_panel.version
def test_str_review_view(self): gene = GeneFactory() gps = GenePanelSnapshotFactory() str_item = STRFactory(panel=gps, gene_core=gene) url = reverse_lazy('panels:review_entity', args=( str_item.panel.panel.pk, 'str', str_item.name, )) r = self.client.get(url) self.assertEqual(r.status_code, 200)
def setUp(self): super().setUp() self.gps = GenePanelSnapshotFactory(panel__status=GenePanel.STATUS.public) self.gps_public = GenePanelSnapshotFactory(panel__status=GenePanel.STATUS.public) self.gpes = GenePanelEntrySnapshotFactory(panel=self.gps_public) self.gpes_internal = GenePanelEntrySnapshotFactory(panel__panel__status=GenePanel.STATUS.internal) self.gpes_retired = GenePanelEntrySnapshotFactory(panel__panel__status=GenePanel.STATUS.retired) self.gpes_deleted = GenePanelEntrySnapshotFactory(panel__panel__status=GenePanel.STATUS.deleted) self.genes = GenePanelEntrySnapshotFactory.create_batch(4, panel=self.gps) self.str = STRFactory(panel__panel__status=GenePanel.STATUS.public) self.region = RegionFactory(panel__panel__status=GenePanel.STATUS.public) self.region2 = RegionFactory(panel__panel__status=GenePanel.STATUS.public, position_37=None)
def test_mark_as_ready_no_gene(self): str_item = STRFactory(gene=None) str_item.evaluation.all().delete() url = reverse_lazy('panels:mark_entity_as_ready', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) self.client.post(url, {'ready_comment': fake.sentence()}) gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert gene.ready is True
def test_edit_str_name_unit(self): str_item = STRFactory() old_str_name = str_item.name ap = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel assert ap.has_str(old_str_name) is True new_data = { "name": 'NewSTR' } ap.update_str(self.verified_user, old_str_name, new_data) new_ap = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel assert new_ap.has_str(old_str_name) is False assert new_ap.has_str('NewSTR') is True
def test_remove_gene_from_str(self): """We need ability to remove genes from STRs""" str_item = STRFactory() url = reverse_lazy('panels:edit_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) number_of_strs = str_item.panel.stats.get('number_of_strs', 0) # make sure new data has at least 1 of the same items source = str_item.evidence.last().name publication = str_item.publications[0] phenotype = str_item.publications[1] new_evidence = Evidence.ALL_SOURCES[randint(0, 9)] original_evidences = set([ev.name for ev in str_item.evidence.all()]) original_evidences.add(new_evidence) str_data = { 'name': str_item.name, 'chromosome': '1', 'position_37_0': '12345', 'position_37_1': '12346', 'position_38_0': '12345', 'position_38_1': '123456', 'repeated_sequence': 'ATAT', 'normal_repeats': '2', 'pathogenic_repeats': '5', "gene_name": "Gene name", "source": set([source, new_evidence]), "tags": [TagFactory().pk, ] + [tag.pk for tag in str_item.tags.all()], "publications": ";".join([publication, fake.sentence()]), "phenotypes": ";".join([phenotype, fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, } res = self.client.post(url, str_data) assert res.status_code == 302 new_str = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert not new_str.gene_core assert not new_str.gene assert str_item.panel.panel.active_panel.version != str_item.panel.version new_current_number = new_str.panel.panel.active_panel.stats.get('number_of_strs') assert number_of_strs == new_current_number
def prepare_compare(self): gene = GeneFactory() gps = GenePanelSnapshotFactory(panel__status=GenePanel.STATUS.internal) GenePanelEntrySnapshotFactory.create_batch(2, panel=gps) # random genes GenePanelEntrySnapshotFactory.create(gene_core=gene, panel=gps) gps2 = GenePanelSnapshotFactory(panel__status=GenePanel.STATUS.public) GenePanelEntrySnapshotFactory.create_batch(2, panel=gps2) # random genes GenePanelEntrySnapshotFactory.create(gene_core=gene, panel=gps2) STRFactory(panel=gps, position_37=None) return gene, gps, gps2
def test_edit_str_name_ajax(self): str_item = STRFactory() url = reverse_lazy('panels:edit_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) old_str_name = str_item.name # make sure new data has at least 1 of the same items source = str_item.evidence.last().name publication = str_item.publications[0] phenotype = str_item.publications[1] gene_data = { 'name': 'NewSTR', 'chromosome': '1', 'position_37_0': '12345', 'position_37_1': '12346', 'position_38_0': '12345', 'position_38_1': '123456', 'repeated_sequence': 'ATAT', 'normal_repeats': '2', 'pathogenic_repeats': '5', "gene": str_item.gene_core.pk, "gene_name": "Other name", "source": set([source, Evidence.ALL_SOURCES[randint(0, 9)]]), "tags": [TagFactory().pk, ] + [tag.pk for tag in str_item.tags.all()], "publications": ";".join([publication, fake.sentence()]), "phenotypes": ";".join([phenotype, fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, } res = self.client.post(url, gene_data) assert res.status_code == 302 new_gps = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel old_gps = GenePanelSnapshot.objects.get(pk=str_item.panel.pk) # check panel has no previous gene assert new_gps.has_str(old_str_name) is False # test previous panel contains old gene assert old_gps.has_str(old_str_name) is True
def test_change_evaluation(self): str_item = STRFactory() current_version = str_item.panel.version str_item.evaluation.all().delete() url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) old_phenotypes = [fake.sentence(), fake.sentence(), fake.sentence()] gene_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "comments": fake.sentence(), "publications": ";".join([fake.sentence(), fake.sentence()]), "phenotypes": ";".join(old_phenotypes), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } self.client.post(url, gene_data) assert Evaluation.objects.filter(user=self.gel_user).count() == 1 gene_data = { "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } self.client.post(url, gene_data) assert Evaluation.objects.filter(user=self.gel_user).count() == 1 assert Evaluation.objects.get( user=self.gel_user).phenotypes == old_phenotypes assert current_version == str_item.panel.panel.active_panel.version
def test_edit_incorrect_repeated_sequence(self): str_item = STRFactory() url = reverse_lazy('panels:edit_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) number_of_strs = str_item.panel.stats.get('number_of_strs') # make sure new data has at least 1 of the same items source = str_item.evidence.last().name publication = str_item.publications[0] phenotype = str_item.publications[1] new_evidence = Evidence.ALL_SOURCES[randint(0, 9)] original_evidences = set([ev.name for ev in str_item.evidence.all()]) original_evidences.add(new_evidence) str_data = { 'name': str_item.name, 'chromosome': '1', 'position_37_0': '12345', 'position_37_1': '12346', 'position_38_0': '12345', 'position_38_1': '123456', 'repeated_sequence': 'ATATBC', 'normal_repeats': '2', 'pathogenic_repeats': '5', "gene": str_item.gene_core.pk, "gene_name": "Gene name", "source": set([source, new_evidence]), "tags": [TagFactory().pk, ] + [tag.pk for tag in str_item.tags.all()], "publications": ";".join([publication, fake.sentence()]), "phenotypes": ";".join([phenotype, fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, } res = self.client.post(url, str_data) assert res.status_code == 200 assert res.content.find(b'Repeated sequence contains incorrect nucleotides') != -1
def test_add_evaluation(self): """Add an evaluation""" str_item = STRFactory() str_item.evaluation.all().delete() str_item.panel.update_saved_stats() url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) current_version = str_item.panel.version number_of_evaluated_genes = str_item.panel.stats.get( 'number_of_evaluated_strs') str_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "comments": fake.sentence(), "publications": ";".join([fake.sentence(), fake.sentence()]), "phenotypes": ";".join([fake.sentence(), fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } res = self.client.post(url, str_data) assert res.status_code == 302 assert number_of_evaluated_genes + 1 == str_item.panel.panel.active_panel.stats.get( 'number_of_evaluated_strs') assert current_version == str_item.panel.panel.active_panel.version
def test_update_tags(self): str_item = STRFactory() current_version = str_item.panel.version str_item.evaluation.all().delete() url = reverse_lazy('panels:update_entity_tags', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) tag1 = TagFactory() tag2 = TagFactory() res = self.client.post(url, {'tags': [tag1.pk, tag2.pk]}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert gene.tags.count() == 2 assert current_version == str_item.panel.panel.active_panel.version
def test_curator_comment_added(self): str_item = STRFactory() str_item.evaluation.all().delete() url = reverse_lazy('panels:update_entity_rating', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) new_status = 0 data = {'comment': fake.sentence(), 'status': new_status} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.content.find(str.encode(data['comment'])) != -1 assert gene.evaluation.count() > 0
def test_add_review_after_comment(self): """When you add a comment and then want to add a review it should be logged""" str_item = STRFactory() current_version = str_item.panel.version str_item.evaluation.all().delete() url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) gene_data = { "comments": fake.sentence(), } res = self.client.post(url, gene_data) assert res.status_code == 302 v01gene = str_item.panel.panel.active_panel.get_str(str_item.name) assert v01gene.evaluation.get(user=self.gel_user).comments.count() == 1 review_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "comments": fake.sentence(), "publications": ";".join([fake.sentence(), fake.sentence()]), } url_review = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) self.client.post(url_review, review_data) res_review = self.client.get(url_review) assert res_review.content.find(str.encode( review_data['publications'])) != -1 assert current_version == str_item.panel.panel.active_panel.version
def test_remove_tag_via_edit_details(self): """Remove tags via edit gene detail section""" str_item = STRFactory( penetrance=GenePanelEntrySnapshot.PENETRANCE.Incomplete ) tag = TagFactory(name='some tag') str_item.tags.add(tag) url = reverse_lazy('panels:edit_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) str_data = { 'name': str_item.name, 'chromosome': '1', 'position_37_0': '12345', 'position_37_1': '12346', 'position_38_0': '12345', 'position_38_1': '123456', 'repeated_sequence': 'ATAT', 'normal_repeats': '2', 'pathogenic_repeats': '5', "gene": str_item.gene_core.pk, "gene_name": "Gene name", "source": set([ev.name for ev in str_item.evidence.all()]), "tags": [], "publications": ";".join([publication for publication in str_item.publications]), "phenotypes": ";".join([phenotype for phenotype in str_item.phenotypes]), "moi": str_item.moi, "penetrance": GenePanelEntrySnapshot.PENETRANCE.Complete, } res = self.client.post(url, str_data) assert res.status_code == 302 new_str = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert list(new_str.tags.all()) == []
def test_update_moi(self): str_item = STRFactory() str_item.evaluation.all().delete() url = reverse_lazy('panels:update_entity_moi', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) moi = [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 2)] data = {'comment': fake.sentence(), 'moi': moi[1]} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count() == 1 assert gene.moi == moi[1] assert gene.panel.version != str_item.panel.version
def test_update_str_preserves_comments_order(self): str_item = STRFactory() comments = list(CommentFactory.create_batch(4, user=self.verified_user)) for ev in str_item.evaluation.all(): ev.comments.add(comments.pop()) max_comments_num = max([e.comments.count() for e in str_item.evaluation.all()]) self.assertEqual(1, max_comments_num) old_str_name = str_item.name ap = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel new_data = { "name": 'NewSTR' } ap.update_str(self.verified_user, old_str_name, new_data) new_ap = GenePanel.objects.get(pk=str_item.panel.panel.pk).active_panel new_str = new_ap.get_str('NewSTR') max_comments_num_after_update = max([e.comments.count() for e in new_str.evaluation.all()]) self.assertEqual(1, max_comments_num_after_update)
def test_update_phenotypes(self): str_item = STRFactory() str_item.evaluation.all().delete() url = reverse_lazy('panels:update_entity_phenotypes', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) phenotypes_array = [fake.word(), fake.word()] phenotypes = "{}; {}".format(phenotypes_array[0], phenotypes_array[1]) data = {'comment': fake.sentence(), 'phenotypes': phenotypes} res = self.client.post(url, data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) assert res.json().get('status') == 200 assert Comment.objects.count() == 1 assert gene.phenotypes == phenotypes_array assert gene.panel.version != str_item.panel.version
def test_edit_comment(self): str_item = STRFactory() current_version = str_item.panel.version evaluation_url = reverse_lazy('panels:review_entity', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name }) comment = fake.sentence() gene_data = { "rating": Evaluation.RATINGS.AMBER, "current_diagnostic": True, "comments": comment, "publications": ";".join([fake.sentence(), fake.sentence()]), "phenotypes": ";".join([fake.sentence(), fake.sentence(), fake.sentence()]), "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], } self.client.post(evaluation_url, gene_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') gene = GenePanel.objects.get( pk=str_item.panel.panel.pk).active_panel.get_str(str_item.name) evaluation = gene.evaluation.get(user=self.gel_user) assert evaluation.comments.first().comment == comment get_comment_url = reverse_lazy('panels:edit_comment_by_user', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name, 'comment_pk': evaluation.comments.first().pk }) res = self.client.get(get_comment_url, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(res.status_code, 200) new_comment = fake.sentence() edit_comment_url = reverse_lazy('panels:submit_edit_comment_by_user', kwargs={ 'pk': str_item.panel.panel.pk, 'entity_type': 'str', 'entity_name': str_item.name, 'comment_pk': evaluation.comments.first().pk }) res = self.client.post(edit_comment_url, {'comment': new_comment}) assert res.status_code == 302 assert evaluation.comments.first().comment == new_comment assert current_version == str_item.panel.panel.active_panel.version