def test_toggle_quality_check(rf, admin, member): """Tests the view that mutes/unmutes quality checks.""" qc_filter = dict( false_positive=False, unit__state=TRANSLATED, unit__store__translation_project__project__disabled=False, ) qc = QualityCheck.objects.filter(**qc_filter).first() unit = qc.unit unit.change.reviewed_by = member unit.change.save() # Explicit POST data present, mute data = 'mute=' request = create_api_request(rf, method='post', user=admin, data=data, encode_as_json=False) response = toggle_qualitycheck(request, unit.id, qc.id) assert response.status_code == 200 assert QualityCheck.objects.get(id=qc.id).false_positive is True sub = unit.submission_set.get(quality_check=qc) assert sub.submitter == admin unit.change.refresh_from_db() assert unit.change.reviewed_by == admin unit.change.reviewed_by = member unit.change.save() # No POST data present, unmute request = create_api_request(rf, method='post', user=admin) response = toggle_qualitycheck(request, unit.id, qc.id) assert response.status_code == 200 assert QualityCheck.objects.get(id=qc.id).false_positive is False sub = unit.submission_set.get(id__gt=sub.id, quality_check=qc) assert sub.submitter == admin unit.change.refresh_from_db() assert unit.change.reviewed_by == admin
def test_toggle_quality_check(rf, admin): """Tests the view that mutes/unmutes quality checks.""" qc_filter = dict( false_positive=False, unit__state=TRANSLATED, unit__store__translation_project__project__disabled=False, ) qc = QualityCheck.objects.filter(**qc_filter).first() unit = qc.unit # Explicit POST data present, mute data = 'mute=' request = create_api_request(rf, method='post', user=admin, data=data, encode_as_json=False) response = toggle_qualitycheck(request, unit.id, qc.id) assert response.status_code == 200 assert QualityCheck.objects.get(id=qc.id).false_positive is True # No POST data present, unmute request = create_api_request(rf, method='post', user=admin) response = toggle_qualitycheck(request, unit.id, qc.id) assert response.status_code == 200 assert QualityCheck.objects.get(id=qc.id).false_positive is False