From 1966df0e8e942e97d299d2300c6ec542626b5f6a Mon Sep 17 00:00:00 2001 From: Ranjan Shrestha Date: Tue, 21 Nov 2023 11:45:51 +0545 Subject: [PATCH] fixes on test case for entry preds; --- analysis_module/mockserver.py | 2 +- analysis_module/tests/test_apis.py | 4 ++-- analysis_module/views/predictions.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/analysis_module/mockserver.py b/analysis_module/mockserver.py index e1c5d5d..c7a18d3 100644 --- a/analysis_module/mockserver.py +++ b/analysis_module/mockserver.py @@ -17,7 +17,7 @@ from core.models import NLPRequest from core_server.settings import ENDPOINT_NAME -from .mock_templates import MOCK_ENTRY_CLASSIFICATION_FORMATTED, MOCK_GEOLOCATION +from .mock_templates import MOCK_ENTRY_CLASSIFICATION, MOCK_ENTRY_CLASSIFICATION_FORMATTED, MOCK_GEOLOCATION from .utils import send_callback_url_request diff --git a/analysis_module/tests/test_apis.py b/analysis_module/tests/test_apis.py index e2ac4f5..46fc26a 100644 --- a/analysis_module/tests/test_apis.py +++ b/analysis_module/tests/test_apis.py @@ -420,11 +420,11 @@ def test_prediction_valid_data(self, model_prediction_class): for item in predictions: assert "client_id" in item assert "model_preds" in item - assert NLPRequest.objects.filter( + assert not NLPRequest.objects.filter( client_id=self.CLIENT_ID, created_by=self.user, status=NLPRequest.RequestStatus.SUCCESS, - ).exists(), "NLP request should be created with success status" + ).exists(), "No nlp request should be created" @patch("analysis_module.views.predictions.ModelTagsPrediction") def test_prediction_mock(self, model_prediction_class): diff --git a/analysis_module/views/predictions.py b/analysis_module/views/predictions.py index 3ca362d..72e6856 100644 --- a/analysis_module/views/predictions.py +++ b/analysis_module/views/predictions.py @@ -7,7 +7,7 @@ from core_server.settings import IS_MOCKSERVER from core.models import NLPRequest from analysis_module.serializers import TagsMappingRequestSerializer, PredictionRequestSerializer -from analysis_module.mockserver import MOCK_ENTRY_CLASSIFICATION_FORMATTED +from analysis_module.mockserver import MOCK_ENTRY_CLASSIFICATION from nlp_scripts.model_prediction.tags_mapping import AF2NLPMapping from nlp_scripts.model_prediction.model_prediction import ModelTagsPrediction from nlp_scripts.model_prediction.utils import get_vf_list @@ -60,7 +60,7 @@ def entry_classification(request: Request): serializer = PredictionRequestSerializer(data=request.data) serializer.is_valid(raise_exception=True) if serializer.validated_data.get("mock") or IS_MOCKSERVER: - return Response(MOCK_ENTRY_CLASSIFICATION_FORMATTED) + return Response(MOCK_ENTRY_CLASSIFICATION) entries = serializer.validated_data["entries"] if not entries: return Response({"classifications": []})