forked from cleveragents/cleveragents-core
650b1038b6
Introduce DomainBaseModel in src/cleveragents/domain/models/base.py that defines the single shared model_config (str_strip_whitespace, validate_assignment, arbitrary_types_allowed=False, populate_by_name, use_enum_values) previously duplicated verbatim across five domain model files. Update 14 classes across five files to inherit from DomainBaseModel instead of pydantic.BaseModel directly, removing all inline model_config duplication: - aimodelscredentials/ai_models_credentials.py (ModelProviderOption) - aimodelserrors/ai_models_errors.py (ModelError, FallbackResult) - aimodelsproviders/ai_models_providers.py (ModelProviderExtraAuthVars, ModelProviderConfigSchema) - auth/auth.py (AuthHeader, TrialPlansExceededError, TrialMessagesExceededError, BillingError, ApiError, ClientAccount, ClientAuth) - planconfig/plan_config.py (PlanConfig, ConfigSetting) Pure structural refactor — no behavioral changes. Models with different configurations (acms, aimodels_custom, etc.) are left untouched. Add BDD feature (22 scenarios) and Robot integration tests (8 test cases) verifying inheritance, config correctness, and no-duplication invariants. ISSUES CLOSED: #1941
139 lines
6.7 KiB
Gherkin
139 lines
6.7 KiB
Gherkin
Feature: DomainBaseModel shared configuration
|
|
As a developer working on the domain layer
|
|
I want all domain models to inherit from DomainBaseModel
|
|
So that the shared model_config is defined in exactly one place
|
|
|
|
Scenario: DomainBaseModel is importable from the domain models package
|
|
Given the cleveragents package is available
|
|
When I import DomainBaseModel from the domain models base module
|
|
Then the DomainBaseModel class should be available
|
|
And DomainBaseModel should be a subclass of pydantic BaseModel
|
|
|
|
Scenario: DomainBaseModel carries the expected model_config
|
|
Given the cleveragents package is available
|
|
When I inspect the DomainBaseModel model_config
|
|
Then the DomainBaseModel str_strip_whitespace should be True
|
|
And the DomainBaseModel validate_assignment should be True
|
|
And the DomainBaseModel arbitrary_types_allowed should be False
|
|
And the DomainBaseModel populate_by_name should be True
|
|
And the DomainBaseModel use_enum_values should be True
|
|
|
|
Scenario: ModelProviderOption inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ModelProviderOption from aimodelscredentials
|
|
Then ModelProviderOption should be a subclass of DomainBaseModel
|
|
And the ModelProviderOption model_config should match DomainBaseModel
|
|
|
|
Scenario: ModelError inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ModelError from aimodelserrors
|
|
Then ModelError should be a subclass of DomainBaseModel
|
|
And the ModelError model_config should match DomainBaseModel
|
|
|
|
Scenario: FallbackResult inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import FallbackResult from aimodelserrors
|
|
Then FallbackResult should be a subclass of DomainBaseModel
|
|
And the FallbackResult model_config should match DomainBaseModel
|
|
|
|
Scenario: ModelProviderExtraAuthVars inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ModelProviderExtraAuthVars from aimodelsproviders
|
|
Then ModelProviderExtraAuthVars should be a subclass of DomainBaseModel
|
|
And the ModelProviderExtraAuthVars model_config should match DomainBaseModel
|
|
|
|
Scenario: ModelProviderConfigSchema inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ModelProviderConfigSchema from aimodelsproviders
|
|
Then ModelProviderConfigSchema should be a subclass of DomainBaseModel
|
|
And the ModelProviderConfigSchema model_config should match DomainBaseModel
|
|
|
|
Scenario: AuthHeader inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import AuthHeader from auth
|
|
Then AuthHeader should be a subclass of DomainBaseModel
|
|
And the AuthHeader model_config should match DomainBaseModel
|
|
|
|
Scenario: TrialPlansExceededError inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import TrialPlansExceededError from auth
|
|
Then TrialPlansExceededError should be a subclass of DomainBaseModel
|
|
And the TrialPlansExceededError model_config should match DomainBaseModel
|
|
|
|
Scenario: TrialMessagesExceededError inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import TrialMessagesExceededError from auth
|
|
Then TrialMessagesExceededError should be a subclass of DomainBaseModel
|
|
And the TrialMessagesExceededError model_config should match DomainBaseModel
|
|
|
|
Scenario: BillingError inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import BillingError from auth
|
|
Then BillingError should be a subclass of DomainBaseModel
|
|
And the BillingError model_config should match DomainBaseModel
|
|
|
|
Scenario: ApiError inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ApiError from auth
|
|
Then ApiError should be a subclass of DomainBaseModel
|
|
And the ApiError model_config should match DomainBaseModel
|
|
|
|
Scenario: ClientAccount inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ClientAccount from auth
|
|
Then ClientAccount should be a subclass of DomainBaseModel
|
|
And the ClientAccount model_config should match DomainBaseModel
|
|
|
|
Scenario: ClientAuth inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ClientAuth from auth
|
|
Then ClientAuth should be a subclass of DomainBaseModel
|
|
And the ClientAuth model_config should match DomainBaseModel
|
|
|
|
Scenario: PlanConfig inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import PlanConfig from planconfig
|
|
Then PlanConfig should be a subclass of DomainBaseModel
|
|
And the PlanConfig model_config should match DomainBaseModel
|
|
|
|
Scenario: ConfigSetting inherits from DomainBaseModel
|
|
Given the cleveragents package is available
|
|
When I import ConfigSetting from planconfig
|
|
Then ConfigSetting should be a subclass of DomainBaseModel
|
|
And the ConfigSetting model_config should match DomainBaseModel
|
|
|
|
Scenario: DomainBaseModel config is applied to ModelProviderOption instances
|
|
Given the cleveragents package is available
|
|
When I create a ModelProviderOption with only priority set to 1
|
|
Then the ModelProviderOption should have priority 1
|
|
And the ModelProviderOption str_strip_whitespace should be True
|
|
And the ModelProviderOption validate_assignment should be True
|
|
And the ModelProviderOption arbitrary_types_allowed should be False
|
|
And the ModelProviderOption populate_by_name should be True
|
|
And the ModelProviderOption use_enum_values should be True
|
|
|
|
Scenario: No inline model_config duplication in aimodelscredentials
|
|
Given the cleveragents package is available
|
|
When I inspect the ModelProviderOption class definition
|
|
Then ModelProviderOption should not define its own model_config
|
|
|
|
Scenario: No inline model_config duplication in aimodelserrors
|
|
Given the cleveragents package is available
|
|
When I inspect the ModelError class definition
|
|
Then ModelError should not define its own model_config
|
|
|
|
Scenario: No inline model_config duplication in aimodelsproviders
|
|
Given the cleveragents package is available
|
|
When I inspect the ModelProviderConfigSchema class definition
|
|
Then ModelProviderConfigSchema should not define its own model_config
|
|
|
|
Scenario: No inline model_config duplication in auth
|
|
Given the cleveragents package is available
|
|
When I inspect the AuthHeader class definition
|
|
Then AuthHeader should not define its own model_config
|
|
|
|
Scenario: No inline model_config duplication in planconfig
|
|
Given the cleveragents package is available
|
|
When I inspect the PlanConfig class definition
|
|
Then PlanConfig should not define its own model_config
|