Skip to content

Commit

Permalink
[IMP] Mute logging related to checkpoint notifications in tests
Browse files Browse the repository at this point in the history
```
2020-11-05 13:36:35,202 6822 INFO openerp_test odoo.tests: skip sending email in test mode
2020-11-05 13:36:35,206 6822 INFO openerp_test odoo.addons.mail.models.mail_mail: Mail with ID 1 and Message-Id '<342741149332557.1604583395.110157728195190-openerp-1-connector.checkpoint@travis-job-14c1db44-ca6c-40e2-82ff-03dcf3df66dc>' successfully sent
2020-11-05 13:36:35,227 6822 INFO openerp_test odoo.models.unlink: User OCA#1 deleted mail.mail records with IDs: [1]
2020-11-05 13:36:35,228 6822 INFO openerp_test odoo.addons.mail.models.mail_mail: Sent batch 1 emails via mail server ID #False
```
  • Loading branch information
StefanRijnhart authored and dreispt committed Apr 27, 2024
1 parent 2563ef8 commit 24d5514
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
25 changes: 18 additions & 7 deletions connector_magento/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from contextlib import contextmanager
from odoo import models
from odoo.addons.component.tests.common import SavepointComponentCase
from odoo.tools import mute_logger

from vcr import VCR

Expand Down Expand Up @@ -160,11 +161,16 @@ def _import_record(self, model_name, magento_id, cassette=True):
filename = 'import_%s_%s' % (table_name[8:], str(magento_id))

def run_import():
if self.backend.version != '1.7':
return self.env[model_name].import_record(
self.backend, magento_id)
with mock_urlopen_image():
self.env[model_name].import_record(self.backend, magento_id)
with mute_logger(
'odoo.addons.mail.models.mail_mail',
'odoo.models.unlink',
'odoo.tests'):
if self.backend.version != '1.7':
return self.env[model_name].import_record(
self.backend, magento_id)
with mock_urlopen_image():
self.env[model_name].import_record(
self.backend, magento_id)

if cassette:
with self.recorder.use_cassette(filename):
Expand Down Expand Up @@ -271,5 +277,10 @@ class MagentoSyncTestCase(MagentoTestCase):

def setUp(self):
super(MagentoSyncTestCase, self).setUp()
with recorder.use_cassette('metadata'):
self.backend.synchronize_metadata()
# Mute logging of notifications about new checkpoints
with mute_logger(
'odoo.addons.mail.models.mail_mail',
'odoo.models.unlink',
'odoo.tests'):
with recorder.use_cassette('metadata'):
self.backend.synchronize_metadata()
9 changes: 7 additions & 2 deletions connector_magento/tests/magento2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from os.path import dirname, join
from vcr import VCR

from odoo.tools import mute_logger
from ..common import MagentoTestCase


Expand All @@ -38,5 +39,9 @@ def setUp(self):
class Magento2SyncTestCase(Magento2TestCase):
def setUp(self):
super(Magento2SyncTestCase, self).setUp()
with recorder.use_cassette('metadata'):
self.backend.synchronize_metadata()
with mute_logger(
'odoo.addons.mail.models.mail_mail',
'odoo.models.unlink',
'odoo.tests'):
with recorder.use_cassette('metadata'):
self.backend.synchronize_metadata()

0 comments on commit 24d5514

Please sign in to comment.