The current test implementation in test_services.py is not testing the correct committed session. The session variable is being overwritten in the wrong place.
Current Implementation
https://github.com/cosmicpython/code/blob/chapter_05_high_gear_low_gear/tests/unit/test_services.py#L49C1-L54C37
def test_commits():
repo, session = FakeRepository([]), FakeSession()
session = FakeSession() # useless overwrite
services.add_batch("b1", "OMINOUS-MIRROR", 100, None, repo, session)
services.allocate("o1", "OMINOUS-MIRROR", 10, repo, session)
assert session.committed is True
The correct test implementation should pass independent sessions or ensure the tracked session is the one actually being asserted:
def test_commits():
repo = FakeRepository([])
services.add_batch("b1", "OMINOUS-MIRROR", 100, None, repo, FakeSession())
session = FakeSession()
services.allocate("o1", "OMINOUS-MIRROR", 10, repo, session)
assert session.committed is True
The current test implementation in
test_services.pyis not testing the correct committed session. Thesessionvariable is being overwritten in the wrong place.Current Implementation
https://github.com/cosmicpython/code/blob/chapter_05_high_gear_low_gear/tests/unit/test_services.py#L49C1-L54C37
The correct test implementation should pass independent sessions or ensure the tracked session is the one actually being asserted: