• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

unioslo / mreg / 22035978934

15 Feb 2026 12:50PM UTC coverage: 97.961% (-0.03%) from 97.995%
22035978934

Pull #596

github

terjekv
Refacgtor policy parity logging and batching functionality

- Add detailed docstrings for clarity on function purposes and side effects.
- Deduplicate policy-engine authorize + metrics/error handling
Pull Request #596: Treetop support

779 of 799 new or added lines in 12 files covered. (97.5%)

2 existing lines in 1 file now uncovered.

10761 of 10985 relevant lines covered (97.96%)

4.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/mreg/api/test_utils.py
1
"""Test utilities for parity checking and permission management."""
2

3
import pytest
5✔
4
from mreg.api.treetop import disable_policy_parity
5✔
5

6

7
# Pytest marker for tests that modify permissions
8
def pytest_configure(config):
5✔
9
    """Register custom pytest markers."""
NEW
10
    config.addinivalue_line(
×
11
        "markers",
12
        "modifies_permissions: mark test as modifying permissions (will skip parity checking)"
13
    )
14

15

16
class PermissionModifyingTestCase:
5✔
17
    """Mixin for test classes that modify permissions during tests.
18
    
19
    This mixin automatically disables parity checking for all tests in the class
20
    since modifying permissions mid-test would cause the legacy and policy
21
    systems to be out of sync.
22
    
23
    Usage:
24
        class TestSomePermissions(PermissionModifyingTestCase, TestCase):
25
            def test_something(self):
26
                # This test can safely modify permissions
27
                user.groups.add(some_group)
28
                # Parity checking will be skipped
29
    """
30
    
31
    def setUp(self) -> None:
5✔
32
        """Set up test with parity checking disabled."""
33
        self._parity_context = disable_policy_parity()
5✔
34
        self._parity_context.__enter__()
5✔
35
        if hasattr(super(), "setUp"):
5✔
36
            super().setUp()  # type: ignore[misc]
5✔
37
    
38
    def tearDown(self) -> None:
5✔
39
        """Clean up parity checking context."""
40
        self._parity_context.__exit__(None, None, None)
5✔
41
        if hasattr(super(), "tearDown"):
5✔
42
            super().tearDown()  # type: ignore[misc]
5✔
43

44

45
@pytest.fixture
5✔
46
def no_parity_check():
5✔
47
    """Pytest fixture to disable parity checking for a test.
48
    
49
    Usage:
50
        def test_modify_permissions(no_parity_check):
51
            # Parity checking is disabled in this test
52
            user.groups.add(some_group)
53
            # Make API calls
54
    """
NEW
55
    with disable_policy_parity():
×
NEW
56
        yield
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc