From 5b182b68c6b56db431ecf6fc393d40e699928bcf Mon Sep 17 00:00:00 2001 From: William B <7444334+whabanks@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:56:39 -0400 Subject: [PATCH] Revert "send freshdesk api (#1896)" (#1900) This reverts commit 63b3cdbb7e67c7343f7651f72b4e068383eb1948. --- app/main/views/templates.py | 40 +------------- app/models/user.py | 7 --- tests/app/main/views/test_templates.py | 73 -------------------------- tests/conftest.py | 5 -- 4 files changed, 1 insertion(+), 124 deletions(-) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 8ef078bab9..b59ea324c3 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -741,7 +741,7 @@ def get_template_data(template_id): methods=["GET", "POST"], ) @user_has_permissions("manage_templates") -def add_service_template(service_id, template_type, template_folder_id=None): # noqa: C901 +def add_service_template(service_id, template_type, template_folder_id=None): if template_type not in ["sms", "email", "letter"]: abort(404) if not current_service.has_permission("letter") and template_type == "letter": @@ -791,26 +791,6 @@ def add_service_template(service_id, template_type, template_folder_id=None): # template_folder_id, form.template_category_id.data if current_app.config["FF_TEMPLATE_CATEGORY"] else None, ) - # Send the information in form's template_category_other field to Freshdesk - # This code path is a little complex - We do not want to raise an error if the request to Freshdesk fails, only if template creation fails - if form.template_category_other.data: - is_english = get_current_locale(current_app) == "en" - try: - current_user.send_new_template_category_request( - current_user.id, - current_service.id, - form.template_category_other.data if is_english else None, - form.template_category_other.data if not is_english else None, - new_template["data"]["id"], - ) - except HTTPError as e: - current_app.logger.error( - f"Failed to send new template category request to Freshdesk: {e} for template {new_template['data']['id']}, data is {form.template_category_other.data}" - ) - except AttributeError as e: - current_app.logger.error( - f"Failed to send new template category request to Freshdesk: {e} for template {new_template['data']['id']}, data is {form.template_category_other.data}" - ) except HTTPError as e: if ( e.status_code == 400 @@ -941,7 +921,6 @@ def edit_service_template(service_id, template_id): # noqa: C901 TODO: remove t new_template = get_template(new_template_data, current_service) template_change = get_template(template, current_service).compare_to(new_template) - if template_change.placeholders_added and not request.form.get("confirm"): example_column_headings = first_column_headings[new_template.template_type] + list(new_template.placeholders) return render_template( @@ -977,23 +956,6 @@ def edit_service_template(service_id, template_id): # noqa: C901 TODO: remove t None if form.process_type.data == TC_PRIORITY_VALUE else form.process_type.data, form.template_category_id.data if current_app.config["FF_TEMPLATE_CATEGORY"] else None, ) - # Send the information in form's template_category_other field to Freshdesk - # This code path is a little complex - We do not want to raise an error if the request to Freshdesk fails, only if template creation fails - if form.template_category_other.data: - is_english = get_current_locale(current_app) == "en" - try: - current_user.send_new_template_category_request( - current_user.id, - current_service.id, - form.template_category_other.data if is_english else None, - form.template_category_other.data if not is_english else None, - template_id, - ) - except HTTPError as e: - current_app.logger.error( - f"Failed to send new template category request to Freshdesk: {e} for template {template_id}, data is {form.template_category_other.data}" - ) - flash(_("'{}' template saved").format(form.name.data), "default_with_tick") return redirect( url_for( diff --git a/app/models/user.py b/app/models/user.py index f00faa2b62..0e17eab1e0 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -394,13 +394,6 @@ def send_branding_request( self.id, serviceID, service_name, org_id, org_name, filename, alt_text_en, alt_text_fr, branding_logo_name ) - def send_new_template_category_request( - self, user_id, service_id, template_category_name_en, template_category_name_fr, template_id - ): - user_api_client.send_new_template_category_request( - user_id, service_id, template_category_name_en, template_category_name_fr, template_id - ) - def refresh_session_id(self): self.current_session_id = user_api_client.get_user(self.id).get("current_session_id") session["current_session_id"] = self.current_session_id diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index ba02bff11d..43e83d6d1a 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -103,79 +103,6 @@ def test_delete(self, fake_uuid, mocker): assert actual_data == {} -class TestSendOtherCategoryInfo: - def test_create_email_template_cat_other_to_freshdesk( - self, - client_request, - mock_create_service_template, - mock_get_template_folders, - mock_get_service_template_when_no_template_exists, - mock_get_template_categories, - mock_send_other_category_to_freshdesk, - active_user_with_permissions, - fake_uuid, - ): - client_request.post( - ".add_service_template", - service_id=SERVICE_ONE_ID, - template_type="email", - _data={ - "name": "new name", - "subject": "Food incoming!", - "template_content": "here's a burrito 🌯", - "template_type": "email", - "template_category_id": TESTING_TEMPLATE_CATEGORY, - "service": SERVICE_ONE_ID, - "process_type": DEFAULT_PROCESS_TYPE, - "button_pressed": "save", - "template_category_other": "hello", - }, - _follow_redirects=True, - ) - assert mock_create_service_template.called is True - assert mock_send_other_category_to_freshdesk.called is True - mock_send_other_category_to_freshdesk.assert_called_once_with( - active_user_with_permissions["id"], SERVICE_ONE_ID, "hello", None, fake_uuid - ) - - def test_edit_email_template_cat_other_to_freshdesk( - self, - client_request, - mock_get_template_categories, - mock_get_service_template, - mock_update_service_template, - mock_send_other_category_to_freshdesk, - active_user_with_permissions, - fake_uuid, - ): - name = "new name" - content = "template content with & entity" - client_request.post( - ".edit_service_template", - service_id=SERVICE_ONE_ID, - template_id=fake_uuid, - _data={ - "id": fake_uuid, - "name": name, - "template_content": content, - "template_type": "sms", - "template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW, - "service": SERVICE_ONE_ID, - "template_category_other": "hello", - "reply_to_text": "reply@go.com", - }, - _follow_redirects=True, - ) - - mock_update_service_template.assert_called_with( - fake_uuid, name, "sms", content, SERVICE_ONE_ID, None, DEFAULT_PROCESS_TYPE, DEFAULT_TEMPLATE_CATEGORY_LOW - ) - assert mock_send_other_category_to_freshdesk.called is True - mock_send_other_category_to_freshdesk.assert_called_once_with( - active_user_with_permissions["id"], SERVICE_ONE_ID, "hello", None, fake_uuid - ) - - def test_should_show_empty_page_when_no_templates( client_request, service_one, diff --git a/tests/conftest.py b/tests/conftest.py index 1c36e45bb4..9175160f55 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -970,11 +970,6 @@ def _create(name, type_, content, service, subject=None, process_type=None, pare return mocker.patch("app.service_api_client.create_service_template", side_effect=_create) -@pytest.fixture(scope="function") -def mock_send_other_category_to_freshdesk(mocker): - return mocker.patch("app.user_api_client.send_new_template_category_request") - - @pytest.fixture(scope="function") def mock_update_service_template(mocker): def _update(