diff --git a/eox_nelp/api_clients/mt.py b/eox_nelp/api_clients/mt.py deleted file mode 100644 index 3e3c0d8a..00000000 --- a/eox_nelp/api_clients/mt.py +++ /dev/null @@ -1,58 +0,0 @@ -"""Client module for minister of tourism API integration. - -Classes: - MinisterOfTourismApiClient: Class to interact with Minister of tourism external service. -""" -from django.conf import settings - -from eox_nelp.api_clients import AbstractAPIRestClient -from eox_nelp.api_clients.authenticators import BasicAuthAuthenticator - -try: - from eox_audit_model.decorators import audit_method -except ImportError: - def audit_method(action): # pylint: disable=unused-argument - """Identity audit_method""" - return lambda x: x - - -class MinisterOfTourismApiClient(AbstractAPIRestClient): - """Allow to perform multiple external certificates operations.""" - - authentication_class = BasicAuthAuthenticator - - def __init__(self): - self.user = getattr(settings, "MINISTER_OF_TOURISM_USER") - self.password = getattr(settings, "MINISTER_OF_TOURISM_PASSWORD") - - super().__init__() - - @property - def base_url(self): - return getattr(settings, "MINISTER_OF_TOURISM_API_URL") - - def update_training_stage(self, course_id, national_id, stage_result): - """This updates the training stage, changes the status to pass or fail, and stores them in HCD - database. If the training stage is already updated or some parameters are missing or wrong, an error - message is returned. - - Arguments: - course_id: Course identifier as string, e.g, course-v1:edx+cos104+T4_2023 - national_id: User national identifier, e.g. 1087583085 - stage_result: Representation of pass or fail result, 1 for pass 2 for fail. - - Returns: - response: requests response as dictionary. - """ - @audit_method(action="Publish MT course completion stage") - def update_training_stage_request(course_id, national_id, stage_result): - """This is a wrapper that allows to make audit-able the update_training_stage method.""" - path = "api/v2/LMSCourse/UpdateTrainingStage" - payload = { - "courseLMSId": course_id, - "userNationalId": national_id, - "applicationStageResult": stage_result, - } - return self.make_post(path, payload) - - return update_training_stage_request(course_id, national_id, stage_result) diff --git a/eox_nelp/api_clients/tests/test_mt.py b/eox_nelp/api_clients/tests/test_mt.py deleted file mode 100644 index 01f60f16..00000000 --- a/eox_nelp/api_clients/tests/test_mt.py +++ /dev/null @@ -1,55 +0,0 @@ -"""This file contains all the test for mt api client file. - -Classes: - TestMinisterOfTourismApiClient: Test for eox-nelp/api_clients/mt.py. -""" -import unittest - -from django.conf import settings -from mock import Mock, patch - -from eox_nelp.api_clients.mt import MinisterOfTourismApiClient -from eox_nelp.api_clients.tests.mixins import TestBasicAuthAuthenticatorMixin, TestRestApiClientMixin - - -class TestMinisterOfTourismApiClient(TestRestApiClientMixin, TestBasicAuthAuthenticatorMixin, unittest.TestCase): - """Tests MinisterOfTourismApiClient""" - - def setUp(self): - """Setup common conditions for every test case""" - self.api_class = MinisterOfTourismApiClient - self.user = settings.MINISTER_OF_TOURISM_USER - self.password = settings.MINISTER_OF_TOURISM_PASSWORD - - @patch.object(MinisterOfTourismApiClient, "make_post") - @patch.object(MinisterOfTourismApiClient, "_authenticate", Mock) - def test_create_certificate(self, post_mock): - """Test successful post request. - - Expected behavior: - - Response is the expected value - """ - expected_value = { - "correlationID": "f3e013f8-a9e4-4714-8162-4e3384f81578", - "responseCode": 100, - "responseMessage": "The update has been successfully", - "data": { - "result": True - }, - "elapsedTime": 0.2972466 - } - post_mock.return_value = expected_value - course_id = "course-v1:FutureX+guide+2023" - national_id = "1222555888" - stage_result = 1 - api_client = self.api_class() - - response = api_client.update_training_stage( - course_id=course_id, - national_id=national_id, - stage_result=stage_result, - ) - - self.assertDictEqual(response, expected_value) - - self.assertDictEqual(response, expected_value) diff --git a/eox_nelp/signals/tasks.py b/eox_nelp/signals/tasks.py index 2e714a2b..e119f5fd 100644 --- a/eox_nelp/signals/tasks.py +++ b/eox_nelp/signals/tasks.py @@ -17,9 +17,9 @@ from eventtracking import tracker from nelc_api_clients.clients.certificates import ExternalCertificatesApiClient from nelc_api_clients.clients.futurex import FuturexApiClient +from nelc_api_clients.clients.mt import MinisterOfTourismApiClient from opaque_keys.edx.keys import UsageKey -from eox_nelp.api_clients.mt import MinisterOfTourismApiClient from eox_nelp.edxapp_wrapper.course_blocks import get_student_module_as_dict from eox_nelp.edxapp_wrapper.course_overviews import CourseOverview from eox_nelp.edxapp_wrapper.grades import SubsectionGradeFactory