Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c7f52b7
[IMP] spp_registry_approval: improve test coverage
emjay0921 Aug 4, 2025
f5936ba
[IMP] spp_change_request: test coverage
emjay0921 Aug 8, 2025
28fc5ea
[FIX] spp_data_export: remove tests for now
emjay0921 Aug 8, 2025
21b9060
[FIX] spp_change_request: tests
emjay0921 Aug 8, 2025
43d725a
[IMP] spp_change_request: tests
emjay0921 Aug 8, 2025
e3e4dad
[IMP] data export test
emjay0921 Sep 4, 2025
2c268be
[IMP] remove test data export
emjay0921 Sep 4, 2025
72ed81b
[FIX] pre-commit error
emjay0921 Sep 4, 2025
b34ac16
[IMP] data export test
emjay0921 Sep 4, 2025
13de3f7
[FIX] data export test
emjay0921 Sep 4, 2025
98901a4
[REM] test for data export for now
emjay0921 Sep 4, 2025
27b2bf5
[IMP] spp_change_request_base tests
emjay0921 Sep 4, 2025
2e5d071
[IMP] spp_change_request_base test
emjay0921 Sep 4, 2025
2b7f977
[IMP] spp_change_request_base source mixin test
emjay0921 Sep 5, 2025
cb5b14d
[IMP] source mixin tests
emjay0921 Sep 5, 2025
7e84a99
[ADD] more test on source mixin test
emjay0921 Sep 5, 2025
6b3e3eb
[ADD] more tests on source mixin test
emjay0921 Sep 5, 2025
efd2301
[ADD] more tests for spp_change_request_base
emjay0921 Sep 5, 2025
6e1396d
[IMP] spp_change_request_base test
emjay0921 Sep 5, 2025
8143cd5
[IMP] add wizards test
emjay0921 Sep 5, 2025
e9f2dc0
[IMP] improve tests on cr base
emjay0921 Sep 5, 2025
645c7ec
[ADD] test for spp_base
emjay0921 Sep 8, 2025
b6e114f
[ADD] test for spp_programs
emjay0921 Sep 8, 2025
d239319
[ADD] tests for spp_event_data
emjay0921 Sep 8, 2025
6820ddd
Merge branch '17.0' into test-coverage-high-prio
emjay0921 Sep 12, 2025
d6737d2
[FIX] spp_change_request tests
emjay0921 Sep 12, 2025
c7e1fb3
[FIX] test error
emjay0921 Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spp_base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

from . import models
from .tests import test_model_unique_id
1 change: 1 addition & 0 deletions spp_base/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Part of OpenSPP Registry. See LICENSE file for full copyright and licensing details.

from . import test_top_up_id
from . import test_unique_id
19 changes: 19 additions & 0 deletions spp_base/tests/test_model_unique_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

from odoo import fields, models


class SppUniqueIdTest(models.Model):
_name = "spp.unique.id.test"
_inherit = "spp.unique.id"
_description = "Test Model for spp.unique.id"
_log_access = False # Avoid creating unnecessary log entries

name = fields.Char("Name")
create_date = fields.Datetime("Creation Date", default=fields.Datetime.now)

def _get_spp_id_prefix(self):
return "TEST"

def _get_match_spp_id_pattern(self):
return r"^TEST_[2-9A-HJ-NP-Z]{8}$"
61 changes: 61 additions & 0 deletions spp_base/tests/test_unique_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Part of OpenSPP Registry. See LICENSE file for full copyright and licensing details.
import re

from psycopg2 import IntegrityError

from odoo.exceptions import ValidationError
from odoo.tests import TransactionCase
from odoo.tools import mute_logger


class TestSppUniqueID(TransactionCase):
@mute_logger("py.warnings")
def test_01_spp_id_generation_and_format(self):
"""Test that spp_id is generated correctly on creation."""
test_record = self.env["spp.unique.id.test"].create({"name": "Test Record 1"})
self.assertTrue(test_record.spp_id, "spp_id should be generated on creation.")
self.assertTrue(
test_record.spp_id.startswith("TEST_"),
"spp_id should start with the correct prefix.",
)

# Check format using regex
pattern = re.compile(r"^TEST_[2-9A-HJ-NP-Z]{8}$")
self.assertIsNotNone(pattern.match(test_record.spp_id), "spp_id has an invalid format.")

@mute_logger("odoo.sql_db")
def test_02_spp_id_uniqueness(self):
"""Test the SQL constraint for spp_id uniqueness."""
test_record_1 = self.env["spp.unique.id.test"].create({"name": "Test Record 2"})
self.assertTrue(test_record_1.spp_id)

with self.assertRaises(IntegrityError), self.cr.savepoint():
self.env["spp.unique.id.test"].create({"name": "Test Record 3", "spp_id": test_record_1.spp_id})

@mute_logger("py.warnings")
def test_03_spp_id_format_constraint_invalid_prefix(self):
"""Test the python constraint on spp_id with an invalid prefix."""
test_record = self.env["spp.unique.id.test"].new({"name": "Invalid Prefix", "spp_id": "FAIL_ABCDE123"})
with self.assertRaisesRegex(ValidationError, "Unique ID is not following correct format!"):
test_record._check_spp_id()

@mute_logger("py.warnings")
def test_04_spp_id_format_constraint_invalid_chars(self):
"""Test the python constraint on spp_id with forbidden characters."""
test_record = self.env["spp.unique.id.test"].new({"name": "Invalid Chars", "spp_id": "TEST_ABCDE123"})
with self.assertRaisesRegex(ValidationError, "Unique ID is not following correct format!"):
test_record._check_spp_id()

@mute_logger("py.warnings")
def test_05_spp_id_not_recomputed(self):
"""Test that spp_id is not recomputed on subsequent writes."""
test_record = self.env["spp.unique.id.test"].create({"name": "Initial Name"})
original_spp_id = test_record.spp_id
self.assertTrue(original_spp_id)

test_record.write({"name": "Updated Name"})
self.assertEqual(
test_record.spp_id,
original_spp_id,
"spp_id should not change on update.",
)
1 change: 1 addition & 0 deletions spp_change_request/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

from . import models
from .tests import test_models
53 changes: 0 additions & 53 deletions spp_change_request/tests/common.py

This file was deleted.

Loading
Loading