Skip to content

Commit fb9fad2

Browse files
committed
[IMP] fastapi_log_mail: Use dedicated cursor in tests
1 parent b4e4643 commit fb9fad2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

fastapi_log_mail/tests/test_fastapi_log_mail.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@
1515

1616
@unittest.skipIf(os.getenv("SKIP_HTTP_CASE"), "TestFastapiLogMail skipped")
1717
class TestFastapiLogMail(Common, MailCase):
18-
@classmethod
19-
def setUpClass(cls):
20-
super().setUpClass()
21-
cls.fastapi_demo_app.api_log_mail_exception_activity_type_id = cls.env[
18+
def _set_mail_exception_activity_type(self, app):
19+
app.api_log_mail_exception_activity_type_id = app.env[
2220
"mail.activity.type"
2321
].create(
2422
{
2523
"name": "Test exception activity type",
2624
"res_model": "api.log",
2725
}
2826
)
29-
cls.fastapi_demo_app.api_log_mail_exception_template_id = cls.env[
30-
"mail.template"
31-
].create(
27+
28+
def _set_mail_exception_template(self, app):
29+
app.api_log_mail_exception_template_id = app.env["mail.template"].create(
3230
{
3331
"name": "Test exception email template",
34-
"model_id": cls.env.ref("api_log.model_api_log").id,
32+
"model_id": app.env.ref("api_log.model_api_log").id,
3533
}
3634
)
3735

@@ -40,7 +38,8 @@ def test_endpoint_exception_create_activity(self):
4038
when an exception occurs an activity of the configured type is created.
4139
"""
4240
# Arrange
43-
app = self.fastapi_demo_app
41+
app = self._get_log_env_records(self.fastapi_demo_app)
42+
self._set_mail_exception_activity_type(app)
4443
activity_type = app.api_log_mail_exception_activity_type_id
4544
route = (
4645
"/fastapi_demo/test/demo/exception?"
@@ -65,7 +64,8 @@ def test_endpoint_exception_send_email(self):
6564
when an exception occurs an email is sent using the configured template.
6665
"""
6766
# Arrange
68-
app = self.fastapi_demo_app
67+
app = self._get_log_env_records(self.fastapi_demo_app)
68+
self._set_mail_exception_template(app)
6969
mail_template = app.api_log_mail_exception_template_id
7070
route = (
7171
"/fastapi_demo/test/demo/exception?"

0 commit comments

Comments
 (0)