11# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2- """Extended coverage tests for spp_aggregation module.
2+ """Extended coverage tests for spp_analytics module.
33
44Covers edge cases in access rules, cache key generation,
55scope resolver, and aggregation service convenience methods.
1010from odoo .exceptions import ValidationError
1111from odoo .tests import tagged
1212
13- from .common import AggregationTestCase
13+ from .common import AnalyticsTestCase
1414
1515
1616@tagged ("post_install" , "-at_install" )
17- class TestAccessRuleValidation (AggregationTestCase ):
18- """Tests for spp.aggregation .access.rule constraint and validation edge cases."""
17+ class TestAccessRuleValidation (AnalyticsTestCase ):
18+ """Tests for spp.analytics .access.rule constraint and validation edge cases."""
1919
2020 def test_constraint_both_user_and_group_raises (self ):
2121 """Setting both user_id and group_id must raise ValidationError."""
2222 with self .assertRaises (ValidationError ):
23- self .env ["spp.aggregation .access.rule" ].create (
23+ self .env ["spp.analytics .access.rule" ].create (
2424 {
2525 "name" : "Invalid Rule" ,
2626 "access_level" : "aggregate" ,
@@ -38,7 +38,7 @@ def test_constraint_neither_user_nor_group_raises(self):
3838 def test_constraint_k_anonymity_below_1_raises (self ):
3939 """minimum_k_anonymity < 1 must raise ValidationError."""
4040 with self .assertRaises (ValidationError ):
41- self .env ["spp.aggregation .access.rule" ].create (
41+ self .env ["spp.analytics .access.rule" ].create (
4242 {
4343 "name" : "K Too Low" ,
4444 "access_level" : "aggregate" ,
@@ -50,7 +50,7 @@ def test_constraint_k_anonymity_below_1_raises(self):
5050 def test_constraint_k_anonymity_above_100_raises (self ):
5151 """minimum_k_anonymity > 100 must raise ValidationError."""
5252 with self .assertRaises (ValidationError ):
53- self .env ["spp.aggregation .access.rule" ].create (
53+ self .env ["spp.analytics .access.rule" ].create (
5454 {
5555 "name" : "K Too High" ,
5656 "access_level" : "aggregate" ,
@@ -62,7 +62,7 @@ def test_constraint_k_anonymity_above_100_raises(self):
6262 def test_constraint_max_dimensions_negative_raises (self ):
6363 """max_group_by_dimensions < 0 must raise ValidationError."""
6464 with self .assertRaises (ValidationError ):
65- self .env ["spp.aggregation .access.rule" ].create (
65+ self .env ["spp.analytics .access.rule" ].create (
6666 {
6767 "name" : "Negative Dims" ,
6868 "access_level" : "aggregate" ,
@@ -74,7 +74,7 @@ def test_constraint_max_dimensions_negative_raises(self):
7474 def test_constraint_max_dimensions_above_10_raises (self ):
7575 """max_group_by_dimensions > 10 must raise ValidationError."""
7676 with self .assertRaises (ValidationError ):
77- self .env ["spp.aggregation .access.rule" ].create (
77+ self .env ["spp.analytics .access.rule" ].create (
7878 {
7979 "name" : "Too Many Dims" ,
8080 "access_level" : "aggregate" ,
@@ -216,7 +216,7 @@ def test_get_effective_rule_user_over_group(self):
216216 }
217217 )
218218 # Create group-based rule
219- self .env ["spp.aggregation .access.rule" ].create (
219+ self .env ["spp.analytics .access.rule" ].create (
220220 {
221221 "name" : "Group Rule" ,
222222 "access_level" : "aggregate" ,
@@ -226,7 +226,7 @@ def test_get_effective_rule_user_over_group(self):
226226 }
227227 )
228228 # Create user-specific rule
229- user_rule = self .env ["spp.aggregation .access.rule" ].create (
229+ user_rule = self .env ["spp.analytics .access.rule" ].create (
230230 {
231231 "name" : "User Rule" ,
232232 "access_level" : "individual" ,
@@ -236,20 +236,20 @@ def test_get_effective_rule_user_over_group(self):
236236 }
237237 )
238238 # User-specific rule should win regardless of sequence
239- AccessRule = self .env ["spp.aggregation .access.rule" ]
239+ AccessRule = self .env ["spp.analytics .access.rule" ]
240240 effective = AccessRule .get_effective_rule_for_user (test_user )
241241 self .assertEqual (effective .id , user_rule .id )
242242 self .assertEqual (effective .access_level , "individual" )
243243
244244
245245@tagged ("post_install" , "-at_install" )
246- class TestCacheServiceKeyGeneration (AggregationTestCase ):
246+ class TestCacheServiceKeyGeneration (AnalyticsTestCase ):
247247 """Tests for cache key generation across all scope types."""
248248
249249 @classmethod
250250 def setUpClass (cls ):
251251 super ().setUpClass ()
252- cls .cache_service = cls .env ["spp.aggregation .cache" ]
252+ cls .cache_service = cls .env ["spp.analytics .cache" ]
253253
254254 def test_scope_key_parts_dict_area (self ):
255255 """Cache key parts for dict area scope must include area_id and children flag."""
@@ -336,27 +336,27 @@ def test_get_ttl_for_scope_type(self):
336336
337337 def test_cron_cleanup_expired (self ):
338338 """cron_cleanup_expired on cache.entry must delegate to cache service."""
339- cache_entry_model = self .env ["spp.aggregation .cache.entry" ]
339+ cache_entry_model = self .env ["spp.analytics .cache.entry" ]
340340 # Should run without error and return an integer
341341 result = cache_entry_model .cron_cleanup_expired ()
342342 self .assertIsInstance (result , int )
343343
344344 def test_store_result_serialization_error (self ):
345345 """store_result must return False when result cannot be serialized."""
346346 scope = self .create_scope ("area" , area_id = self .area_region .id )
347- with patch ("odoo.addons.spp_aggregation .models.service_cache.json.dumps" , side_effect = TypeError ("bad" )):
347+ with patch ("odoo.addons.spp_analytics .models.service_cache.json.dumps" , side_effect = TypeError ("bad" )):
348348 stored = self .cache_service .store_result (scope , ["count" ], [], {"total" : 1 })
349349 self .assertFalse (stored )
350350
351351
352352@tagged ("post_install" , "-at_install" )
353- class TestScopeResolverEdgeCases (AggregationTestCase ):
353+ class TestScopeResolverEdgeCases (AnalyticsTestCase ):
354354 """Tests for scope resolver edge cases and error handling."""
355355
356356 @classmethod
357357 def setUpClass (cls ):
358358 super ().setUpClass ()
359- cls .resolver = cls .env ["spp.aggregation .scope.resolver" ]
359+ cls .resolver = cls .env ["spp.analytics .scope.resolver" ]
360360
361361 def test_resolve_inline_missing_scope_type (self ):
362362 """Inline scope dict without scope_type must return empty list."""
@@ -403,13 +403,13 @@ def test_resolve_intersect_empty_scopes(self):
403403
404404
405405@tagged ("post_install" , "-at_install" )
406- class TestAggregationServiceExtended (AggregationTestCase ):
407- """Extended tests for spp.aggregation .service convenience methods and scope resolution."""
406+ class TestAggregationServiceExtended (AnalyticsTestCase ):
407+ """Extended tests for spp.analytics .service convenience methods and scope resolution."""
408408
409409 @classmethod
410410 def setUpClass (cls ):
411411 super ().setUpClass ()
412- cls .service = cls .env ["spp.aggregation .service" ]
412+ cls .service = cls .env ["spp.analytics .service" ]
413413
414414 def test_resolve_scope_dict (self ):
415415 """_resolve_scope with dict must return the same dict."""
@@ -422,7 +422,7 @@ def test_resolve_scope_int(self):
422422 scope = self .create_scope ("area" , area_id = self .area_region .id )
423423 result = self .service ._resolve_scope (scope .id )
424424 self .assertEqual (result .id , scope .id )
425- self .assertEqual (result ._name , "spp.aggregation .scope" )
425+ self .assertEqual (result ._name , "spp.analytics .scope" )
426426
427427 def test_resolve_scope_record (self ):
428428 """_resolve_scope with record must return the same record."""
0 commit comments