mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
test(composite): align empty-mapping deepseek fixtures with official model whitelist
组合 fix/deepseek-model-name-validation 后,DeepSeek 空 mapping 账号的 IsModelSupported 改按官方白名单判定,deepseek-chat 已不在白名单。composite 规则B(空 mapping native claim)语义不变,测试夹具从已退役的 deepseek-chat 换成白名单名 deepseek-flash / deepseek-v4-pro。
This commit is contained in:
1 parent
006ed5af25
commit
16612cd6a7
3 files changed
+16
-13
No files matched your search
@@ -52,13 +52,14 @@ func TestCompositeAccountClaimsModel_NormalizedLookupHit(t *testing.T) {
|
||||
// 规则B:空 mapping 仅当 detector 平台一致且 IsModelSupported 通过。
|
||||
func TestCompositeAccountClaimsModel_EmptyMappingNativeOnly(t *testing.T) {
|
||||
deepseek := &Account{Platform: PlatformDeepseek}
|
||||
require.True(t, CompositeAccountClaimsModel(deepseek, "deepseek-chat"))
|
||||
// 使用受支持的 DeepSeek 模型名(空 mapping native claim 受官方白名单约束)。
|
||||
require.True(t, CompositeAccountClaimsModel(deepseek, "deepseek-flash"))
|
||||
|
||||
// detector 平台不一致的空 mapping 账号不得冒领(测试 b 的谓词面)。
|
||||
openAI := &Account{Platform: PlatformOpenAI}
|
||||
require.False(t, CompositeAccountClaimsModel(openAI, "deepseek-chat"))
|
||||
require.False(t, CompositeAccountClaimsModel(openAI, "deepseek-flash"))
|
||||
zhipu := &Account{Platform: PlatformZhipu}
|
||||
require.False(t, CompositeAccountClaimsModel(zhipu, "deepseek-chat"))
|
||||
require.False(t, CompositeAccountClaimsModel(zhipu, "deepseek-flash"))
|
||||
|
||||
// detector 不认识的模型,空 mapping 任何平台都不得 claim。
|
||||
require.False(t, CompositeAccountClaimsModel(deepseek, "unknown-alias"))
|
||||
@@ -144,9 +145,9 @@ func TestCompositeAccountClaimStrength(t *testing.T) {
|
||||
}
|
||||
require.Equal(t, CompositeClaimNone, CompositeAccountClaimStrength(emptyTarget, "empty-alias"))
|
||||
|
||||
// 受控 native 空 mapping 与精确同强等级。
|
||||
// 受控 native 空 mapping 与精确同强等级(模型名须在 deepseek 官方白名单内)。
|
||||
native := &Account{Platform: PlatformDeepseek}
|
||||
require.Equal(t, CompositeClaimExplicit, CompositeAccountClaimStrength(native, "deepseek-chat"))
|
||||
require.Equal(t, CompositeClaimExplicit, CompositeAccountClaimStrength(native, "deepseek-flash"))
|
||||
// detector 不认识的模型无声明。
|
||||
require.Equal(t, CompositeClaimNone, CompositeAccountClaimStrength(native, "unknown-alias"))
|
||||
require.Equal(t, CompositeClaimNone, CompositeAccountClaimStrength(nil, "gpt-5"))
|
||||
@@ -176,5 +177,5 @@ func TestCompositeAccountClaimsModel_IgnoresTransientState(t *testing.T) {
|
||||
RateLimitResetAt: &now,
|
||||
OverloadUntil: &now,
|
||||
}
|
||||
require.True(t, CompositeAccountClaimsModel(account, "deepseek-chat"))
|
||||
require.True(t, CompositeAccountClaimsModel(account, "deepseek-flash"))
|
||||
}
|
||||
@@ -63,8 +63,9 @@ func TestCompositePoolOwnershipDualPlatformExplicitAlias(t *testing.T) {
|
||||
require.Equal(t, []string{PlatformDeepseek, PlatformOpenAI, PlatformZhipu}, ownership.CandidatePlatforms)
|
||||
}
|
||||
|
||||
// b. 官方 deepseek 空 mapping(规则B,强声明)+ opencode 显式 mapping(规则A
|
||||
// 精确,强声明)→ 双平台 pool;空 mapping 的无关 openai/zhipu 账号不入池。
|
||||
// b. 官方 deepseek 空 mapping(规则B,强声明,使用受支持的 DeepSeek 模型名)
|
||||
// + opencode 显式 mapping(规则A 精确,强声明)→ 双平台 pool;空 mapping 的
|
||||
// 无关 openai/zhipu 账号不入池。
|
||||
func TestCompositePoolOwnershipDeepseekNativePlusOpenCodeMapping(t *testing.T) {
|
||||
groupID := int64(7)
|
||||
repo := compositePoolOwnershipRepo([]Account{
|
||||
@@ -73,7 +74,7 @@ func TestCompositePoolOwnershipDeepseekNativePlusOpenCodeMapping(t *testing.T) {
|
||||
ID: 2,
|
||||
Platform: PlatformOpenCodeGo,
|
||||
Credentials: map[string]any{
|
||||
"model_mapping": map[string]any{"deepseek-chat": "deepseek-chat"},
|
||||
"model_mapping": map[string]any{"deepseek-flash": "deepseek-flash"},
|
||||
},
|
||||
},
|
||||
{ID: 3, Platform: PlatformOpenAI},
|
||||
@@ -81,14 +82,14 @@ func TestCompositePoolOwnershipDeepseekNativePlusOpenCodeMapping(t *testing.T) {
|
||||
})
|
||||
svc := &GatewayService{accountRepo: repo}
|
||||
|
||||
ownership, err := svc.resolveCompositeModelOwnership(context.Background(), groupID, "deepseek-chat")
|
||||
ownership, err := svc.resolveCompositeModelOwnership(context.Background(), groupID, "deepseek-flash")
|
||||
require.NoError(t, err)
|
||||
require.True(t, ownership.Matched)
|
||||
require.Empty(t, ownership.TargetPlatform)
|
||||
require.Equal(t, []string{PlatformDeepseek, PlatformOpenCodeGo}, ownership.CandidatePlatforms)
|
||||
|
||||
// 仅 deepseek 空 mapping 声明时保持 single(既有语义)。
|
||||
single, err := svc.resolveCompositeModelOwnership(context.Background(), groupID, "deepseek-reasoner")
|
||||
single, err := svc.resolveCompositeModelOwnership(context.Background(), groupID, "deepseek-v4-pro")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, CompositeModelOwnership{TargetPlatform: PlatformDeepseek, Matched: true}, single)
|
||||
}
|
||||
|
||||
@@ -425,7 +425,8 @@ func TestOpenAICompositePool_ClaimsPredicateGatesPoolMembership(t *testing.T) {
|
||||
opencodeMapped := compositePoolTestAccount(35003, PlatformOpenCodeGo, 22007, 0, map[string]any{"my-model": "deepseek-chat"})
|
||||
|
||||
// 官方 deepseek 空 mapping:native detector 命中 → 可 claim。
|
||||
require.True(t, openAISchedulingModelSupported(poolCtx, &deepseekAccount, "deepseek-chat"))
|
||||
// 使用受支持的 DeepSeek 模型名(空 mapping native claim 受官方白名单约束)。
|
||||
require.True(t, openAISchedulingModelSupported(poolCtx, &deepseekAccount, "deepseek-flash"))
|
||||
// 无关平台空 mapping:不得凭 IsModelSupported 的 allow-all 冒领。
|
||||
require.False(t, openAISchedulingModelSupported(poolCtx, &kimiAccount, "deepseek-chat"))
|
||||
require.True(t, kimiAccount.IsModelSupported("deepseek-chat"), "旧语义 allow-all 仍成立,池路径必须改用 claims 谓词")
|
||||
@@ -444,7 +445,7 @@ func TestOpenAICompositePool_ClaimsPredicateGatesPoolMembership(t *testing.T) {
|
||||
repo := &compositePoolTestRepo{accounts: []Account{deepseekAccount, kimiAccount}}
|
||||
cache := &compositePoolTestCache{}
|
||||
svc := newCompositePoolTestService(repo.accounts, cache)
|
||||
selection, err := svc.SelectAccountForModelWithExclusions(poolCtx, &groupID, "", "deepseek-chat", nil)
|
||||
selection, err := svc.SelectAccountForModelWithExclusions(poolCtx, &groupID, "", "deepseek-flash", nil)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 35001, selection.ID)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user