refactor(test): remove all unittest.mock usage from Robot Framework integration tests #703

Closed
freemo wants to merge 5 commits from refactor/m3-remove-unittest-mock-integration into master

5 Commits

Author SHA1 Message Date
freemo 1a584563a7 fix(test): fix IndentationError in provider env-gating inside Robot Catenate blocks
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 17s
CI / typecheck (pull_request) Successful in 38s
CI / security (pull_request) Successful in 40s
CI / integration_tests (pull_request) Successful in 3m28s
CI / unit_tests (pull_request) Successful in 5m17s
CI / docker (pull_request) Successful in 22s
CI / coverage (pull_request) Successful in 5m35s
CI / benchmark-regression (pull_request) Successful in 35m54s
Robot Framework's Catenate with SEPARATOR=\n strips leading whitespace
from continuation lines, so a multi-line if/body block:

    ...    if not api_key:
    ...        print('SKIP: ...'); sys.exit(0)

becomes invalid Python (print at column 0 after the if). Collapse the
if and its body onto a single line so indentation is not needed.
2026-03-12 08:36:29 +00:00
freemo 72ddf83fdf fix(test): use model_id instead of model in provider attribute checks
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 40s
CI / security (pull_request) Successful in 38s
CI / quality (pull_request) Successful in 34s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 19s
CI / unit_tests (pull_request) Successful in 5m12s
CI / integration_tests (pull_request) Successful in 6m7s
CI / docker (pull_request) Successful in 4m12s
CI / coverage (pull_request) Successful in 6m54s
CI / benchmark-regression (pull_request) Has been cancelled
GoogleChatProvider and OpenAIChatProvider store the model name as
model_id (inherited from LangChainChatProvider), not model. The
attribute check tests were asserting the wrong attribute name.
2026-03-12 08:16:27 +00:00
freemo 34ad85e4ae fix: resolve FK constraint, resource handler, and plan lifecycle errors in integration tests
- Add create_test_decision_service() and create_plan_for_decisions() to
  _test_container.py so DecisionService shares the same in-memory SQLite
  DB as PlanLifecycleService (fixes FK constraint on decisions.plan_id)
- Fix helper_plan_correct_tree_wiring.py: use shared DB for decisions
- Fix helper_event_bus.py: use shared DB for decision_service_emits_event
- Fix helper_m4_e2e_verification.py: use shared DB for cli-plan-tree,
  add regex-based JSON extraction to handle interleaved log lines
- Fix helper_resource_handlers.py: use real temp dirs with
  SandboxStrategy.NONE for git-resolve and fs-resolve tests
- Fix helper_m1_sourcecode_smoke.py: plan_diff() now creates a real
  PlanApplyService with InMemoryChangeSetStore and changeset_id
- Fix helper_actor_cli_show.py: upsert() instead of save(), flexible
  list assertion for built-in actors
- Fix helper_apply_pipeline.py: set terminal APPLIED state for
  already-applied test
- Fix helper_cli_extensions.py: set inputs_schema on action object
  (not via create_action kwarg)
- Fix helper_m3_decision_validation_smoke.py: dict access for
  attach_validation() return value
- Fix helper_plan_cli_spec.py: project_links with ProjectLink objects
- Add prepare_plan_for_execute/apply calls across lifecycle helpers

All 110 targeted robot tests pass. Quality gates: typecheck (0 errors),
lint (all passed), format (1415 files formatted).
2026-03-12 07:36:10 +00:00
freemo 30b6bfc810 refactor: replace all unittest.mock patterns with real dependencies in robot integration tests
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / quality (pull_request) Successful in 18s
CI / build (pull_request) Successful in 18s
CI / security (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 41s
CI / unit_tests (pull_request) Successful in 3m5s
CI / integration_tests (pull_request) Failing after 3m27s
CI / docker (pull_request) Successful in 53s
CI / coverage (pull_request) Successful in 5m31s
CI / benchmark-regression (pull_request) Successful in 35m29s
- Delete _testing_stubs.py (382 lines of Stub/SpyStub/patch_attr/fake_settings)
- Create _test_container.py with real service factories backed by in-memory SQLite
- Replace all .return_value/.assert_called/.call_args patterns across 41 helper files
- Use real PlanLifecycleService, CorrectionService, DecisionService, InvariantService
- Use real ResourceRegistryService, NamespacedProjectRepository, ProjectResourceLinkRepository
- Use real ActorService + ActorRegistry for TDD actor validation tests
- Use types.SimpleNamespace for lightweight structural interfaces (DI container resolve)
- Use InMemoryChangeSetStore (production class) for changeset tests
- Tag LLM-dependent tests with [Tags] llm-required for CI skip
- All modified files pass ruff check, ruff format, and pyright with zero errors

Implements CONTRIBUTING.md line 568: no mocking in integration tests.
2026-03-12 05:35:02 +00:00
freemo 1067ed5e40 refactor(test): remove all unittest.mock usage from Robot Framework integration tests
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 17s
CI / security (pull_request) Successful in 38s
CI / typecheck (pull_request) Successful in 39s
CI / unit_tests (pull_request) Successful in 3m5s
CI / integration_tests (pull_request) Successful in 3m42s
CI / docker (pull_request) Successful in 59s
CI / coverage (pull_request) Successful in 7m15s
CI / benchmark-regression (pull_request) Successful in 36m40s
Replace MagicMock, patch, create_autospec, and PropertyMock with custom
lightweight test doubles in robot/_testing_stubs.py:

- Stub: drop-in for MagicMock with call tracking, return_value,
  side_effect, context-manager and iteration protocol support
- SpyStub: wraps a real object while tracking calls
- patch_attr(): replaces unittest.mock.patch/patch.object with
  context-manager and start/stop API support
- fake_settings(): replaces create_autospec(Settings, instance=True)
- _CallRecord: lightweight replacement for unittest.mock.call

All 42 files in robot/ directory updated. No file in robot/ imports
from unittest.mock. Features/mocks directory left untouched.

Passes: nox -e lint, nox -e typecheck (0 errors), nox -e unit_tests
(372 features, 10553 scenarios, 0 failed).

Closes #699
2026-03-12 00:21:42 +00:00