-
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[COV] l10n_it_sdi_channel: Test State tracking
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
l10n_it_sdi_channel/tests/test_fatturapa_attachment_out.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |