From fa69dba2536e62aa636be052948f4310e5ebd932 Mon Sep 17 00:00:00 2001 From: Luis Felipe Castano Date: Mon, 6 May 2024 15:44:21 -0500 Subject: [PATCH] add test integration --- eox_hooks/tests/test_integration.py | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 eox_hooks/tests/test_integration.py diff --git a/eox_hooks/tests/test_integration.py b/eox_hooks/tests/test_integration.py new file mode 100644 index 0000000..5b850df --- /dev/null +++ b/eox_hooks/tests/test_integration.py @@ -0,0 +1,48 @@ +""" +Test views file. +""" +from django.test import TestCase +from unittest.mock import patch, MagicMock +from eox_hooks.actions import post_to_webhook_url + + +class TutorIntegrationTestCase(TestCase): + """ + POC code to run tests that cover the integration with openedx + """ + + def test_runs_code(self): + """ + Just to make sure our test infrastructure is behaving + """ + assert True + + # pylint: disable=import-outside-toplevel,unused-import + def test_current_settings_code_imports(self): + """ + Running this imports means that our backends import the right signature + """ + import eox_hooks.edxapp_wrapper.backends.course_modes_j_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.course_modes_l_v1_test # isort:skip + import eox_hooks.edxapp_wrapper.backends.course_modes_l_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.courses_j_v1_test # isort:skip + import eox_hooks.edxapp_wrapper.backends.courses_j_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.courses_l_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.courses_p_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.enrollments_l_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.enrollments_l_v1_test # isort:skip + import eox_hooks.edxapp_wrapper.backends.enrollments_j_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.models_j_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.models_l_v1 # isort:skip + import eox_hooks.edxapp_wrapper.backends.models_l_v1_test # isort:skip + +class TestPostToWebhook(TestCase): + @patch('eox_hooks.actions.requests.post') # Mock de la funciĆ³n requests.post + def test_post_to_webhook_url(self, mock_post): + mock_trigger_event = "trigger_event" + + mock_post.return_value = MagicMock(status_code=200) # Simula una respuesta exitosa + + result = post_to_webhook_url(trigger_event=mock_trigger_event) + + self.assertTrue(result)