From 9e38a69a7913f019c2ce621757fb054f4baf9e05 Mon Sep 17 00:00:00 2001 From: Davit Lomauridze Date: Tue, 13 Aug 2024 16:18:17 +0400 Subject: [PATCH] [FIX]doument_page_portal: added test cases --- .../tests/test_document_controller.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/document_page_portal/tests/test_document_controller.py b/document_page_portal/tests/test_document_controller.py index 021ddeb48a2..c86b83025fd 100644 --- a/document_page_portal/tests/test_document_controller.py +++ b/document_page_portal/tests/test_document_controller.py @@ -1,3 +1,5 @@ +from unittest.mock import patch + from odoo.tests import common from odoo.tests.common import tagged @@ -17,11 +19,22 @@ def setUp(self): } ) - def test_get_archive_groups(self): + def _mock_request(self): + mock_request = type("MockRequest", (), {})() + mock_request.env = self.env + mock_request.session = {} + return mock_request + + @patch("odoo.http.request") + def test_get_archive_groups(self, mock_request): + mock_request.env = self.env groups = self.customer_portal._get_archive_groups("document.page") self.assertTrue(groups) - def test_document_page_get_page_view_values(self): + @patch("odoo.http.request") + def test_document_page_get_page_view_values(self, mock_request): + mock_request.env = self.env + mock_request.session = {} values = self.customer_portal._document_page_get_page_view_values( self.document_page, "test_token" ) @@ -29,6 +42,7 @@ def test_document_page_get_page_view_values(self): self.assertEqual(values["document_page"], self.document_page) def test_portal_my_knowledge_document_pages(self): + self.authenticate("admin", "admin") response = self.url_open("/my/knowledge/documents/") self.assertEqual(response.status_code, 200) @@ -39,6 +53,7 @@ def test_portal_my_knowledge_document_pages(self): self.assertEqual(response.status_code, 200) def test_document_pages_followup(self): + self.authenticate("admin", "admin") response = self.url_open(f"/knowledge/document/{self.document_page.id}") self.assertEqual(response.status_code, 200)