mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 15:12:08 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,44 @@
|
|||
# Copyright 2016 ABF OSIELL <https://osiell.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
import time
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestAuditlogAutovacuum(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestAuditlogAutovacuum, self).setUp()
|
||||
self.groups_model_id = self.env.ref("base.model_res_groups").id
|
||||
self.groups_rule = self.env["auditlog.rule"].create(
|
||||
{
|
||||
"name": "testrule for groups",
|
||||
"model_id": self.groups_model_id,
|
||||
"log_read": True,
|
||||
"log_create": True,
|
||||
"log_write": True,
|
||||
"log_unlink": True,
|
||||
"state": "subscribed",
|
||||
"log_type": "full",
|
||||
}
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.groups_rule.unlink()
|
||||
super(TestAuditlogAutovacuum, self).tearDown()
|
||||
|
||||
def test_autovacuum(self):
|
||||
log_model = self.env["auditlog.log"]
|
||||
autovacuum_model = self.env["auditlog.autovacuum"]
|
||||
group = self.env["res.groups"].create({"name": "testgroup1"})
|
||||
nb_logs = log_model.search_count(
|
||||
[("model_id", "=", self.groups_model_id), ("res_id", "=", group.id)]
|
||||
)
|
||||
self.assertGreater(nb_logs, 0)
|
||||
# Milliseconds are ignored by autovacuum, waiting 1s ensure that
|
||||
# the logs generated will be processed by the vacuum
|
||||
time.sleep(1)
|
||||
autovacuum_model.autovacuum(days=0)
|
||||
nb_logs = log_model.search_count(
|
||||
[("model_id", "=", self.groups_model_id), ("res_id", "=", group.id)]
|
||||
)
|
||||
self.assertEqual(nb_logs, 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue