@tdd_bug @tdd_bug_990 @tdd_issue @tdd_issue_990
Feature: TDD Bug #990 — automation_profile._get_service() bypasses DI container
  As a developer relying on the DI container for service wiring
  I want _get_service() in automation_profile.py to resolve AutomationProfileService
  through the DI container
  So that service construction is consistent and dependencies are correctly injected

  This feature captures bug #990. Previously, _get_service() bypassed the DI
  container by directly constructing the persistence layer with create_engine()
  and sessionmaker() rather than delegating to container.automation_profile_service().
  This caused service wiring to diverge from the canonical DI path and broke
  dependency injection for AutomationProfileService.

  Bug #990 was fixed by PR #1181, which updated _get_service() to resolve the
  service through the DI container. The @tdd_expected_fail tag has been omitted
  because the fix landed on master before this TDD test PR merged; these scenarios
  serve as permanent regression tests confirming the DI bypass remains fixed.

  Scenario: Bug #990 — _get_service resolves AutomationProfileService through the DI container
    Given ap990- the DI container has an automation_profile_service provider
    When ap990- _get_service is called with the mocked container
    Then ap990- the returned service should be the one from container.automation_profile_service

  Scenario: Bug #990 — _get_service does not call create_engine directly
    Given ap990- create_engine is patched to detect direct calls
    When ap990- _get_service is called with a valid DI container
    Then ap990- create_engine should not have been called

  Scenario: Bug #990 — _get_service does not call sessionmaker directly
    Given ap990- sessionmaker is patched to detect direct calls
    When ap990- _get_service is called with a valid DI container
    Then ap990- sessionmaker should not have been called
