Skip to content

Commit

Permalink
[COV] l10n_it_sdi_channel: Test State tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTakobi committed Mar 20, 2023
1 parent 761ebef commit 4645612
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_it_sdi_channel/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_account_invoice
from . import test_fatturapa_attachment_out
37 changes: 37 additions & 0 deletions l10n_it_sdi_channel/tests/test_fatturapa_attachment_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.addons.l10n_it_sdi_channel.models.fatturapa_attachment_out import (
STATE_SUBTYPE_MAPPING,
)
from odoo.addons.mail.tests.common import MailCommon


class TestFatturaPAAttachmentOut(MailCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.attachment_model = cls.env["fatturapa.attachment.out"]

def test_track_subtype(self):
"""When the State of the Attachment is updated, a Message is sent."""
# Arrange
attachment = self.attachment_model.create(
{
"name": "Test Attachment",
}
)
self.flush_tracking()
creation_message = attachment.message_ids
self.assertEqual(len(creation_message), 1)

# Act
new_state = "sent"
attachment.state = new_state
self.flush_tracking()

# Assert
state_update_message = attachment.message_ids - creation_message
self.assertEqual(len(state_update_message), 1)
subtype_xmlid = STATE_SUBTYPE_MAPPING.get(new_state)
self.assertEqual(state_update_message.subtype_id, self.env.ref(subtype_xmlid))

0 comments on commit 4645612

Please sign in to comment.