Skip to content

Commit 3f93d12

Browse files
committed
[OF-1805] feat: Add new GoogleGenAI Quota tier feature
1 parent f62bd69 commit 3f93d12

File tree

3 files changed

+48
-18
lines changed

3 files changed

+48
-18
lines changed

Library/include/CSP/Systems/Quota/Quota.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum class TierFeatures
5656
OpenAI,
5757
Shopify,
5858
TicketedSpace,
59+
GoogleGenAI,
5960
Invalid
6061
};
6162

Library/src/Systems/Quota/Quota.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ const csp::common::String TierFeatureEnumToString(const TierFeatures& Value)
256256
return "TotalUploadSizeInKilobytes";
257257
case TierFeatures::SpaceOwner:
258258
return "SpaceOwner";
259+
case TierFeatures::GoogleGenAI:
260+
return "GoogleGenAI";
259261
case TierFeatures::Invalid:
260262
return "Invalid";
261263
default:
@@ -343,6 +345,11 @@ TierFeatures StringToTierFeatureEnum(const csp::common::String& Value)
343345
return TierFeatures::SpaceOwner;
344346
}
345347

348+
if (Value == "GoogleGenAI")
349+
{
350+
return TierFeatures::GoogleGenAI;
351+
}
352+
346353
CSP_LOG_ERROR_FORMAT("QuotaSystem TierFeature not recognized: %s. Defaulting to Invalid", Value.c_str());
347354
return TierFeatures::Invalid;
348355
}

Tests/src/PublicAPITests/QuotaSystemTests.cpp

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, TierFeatureEnumTesttoStringTest)
6262
EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::SpaceOwner), "SpaceOwner");
6363
EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::TicketedSpace), "TicketedSpace");
6464
EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::TotalUploadSizeInKilobytes), "TotalUploadSizeInKilobytes");
65+
EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::GoogleGenAI), "GoogleGenAI");
6566
}
6667

6768
CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, StringToTierFeatureEnumTestTest)
@@ -75,6 +76,7 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, StringToTierFeatureEnumTestTest)
7576
EXPECT_EQ(StringToTierFeatureEnum("SpaceOwner"), csp::systems::TierFeatures::SpaceOwner);
7677
EXPECT_EQ(StringToTierFeatureEnum("TicketedSpace"), csp::systems::TierFeatures::TicketedSpace);
7778
EXPECT_EQ(StringToTierFeatureEnum("TotalUploadSizeInKilobytes"), csp::systems::TierFeatures::TotalUploadSizeInKilobytes);
79+
EXPECT_EQ(StringToTierFeatureEnum("GoogleGenAI"), csp::systems::TierFeatures::GoogleGenAI);
7880
}
7981

8082
CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetTotalSpacesOwnedByUserTest)
@@ -210,31 +212,54 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetTierFeaturesQuota)
210212
auto UserSystem = SystemsManager.GetUserSystem();
211213
auto QuotaSystem = SystemsManager.GetQuotaSystem();
212214

213-
csp::common::Array<FeatureQuotaInfo> ExpectedInfoArray
214-
= { FeatureQuotaInfo(TierFeatures::SpaceOwner, TierNames::Basic, 3, PeriodEnum::Total, true),
215-
FeatureQuotaInfo(TierFeatures::ScopeConcurrentUsers, TierNames::Basic, 5, PeriodEnum::Hours24, true),
216-
FeatureQuotaInfo(TierFeatures::ObjectCaptureUpload, TierNames::Basic, 5, PeriodEnum::CalendarMonth, false),
217-
FeatureQuotaInfo(TierFeatures::AudioVideoUpload, TierNames::Basic, -1, PeriodEnum::Total, false),
218-
FeatureQuotaInfo(TierFeatures::TotalUploadSizeInKilobytes, TierNames::Basic, 10000000, PeriodEnum::Total, true),
219-
FeatureQuotaInfo(TierFeatures::Agora, TierNames::Basic, 0, PeriodEnum::Total, false),
220-
FeatureQuotaInfo(TierFeatures::OpenAI, TierNames::Basic, 0, PeriodEnum::Total, false),
221-
FeatureQuotaInfo(TierFeatures::Shopify, TierNames::Basic, 0, PeriodEnum::Total, false),
222-
FeatureQuotaInfo(TierFeatures::TicketedSpace, TierNames::Basic, 0, PeriodEnum::Total, false) };
215+
csp::common::Array<TierFeatures> TierFeaturesArray = { TierFeatures::SpaceOwner, TierFeatures::ScopeConcurrentUsers,
216+
TierFeatures::ObjectCaptureUpload, TierFeatures::AudioVideoUpload, TierFeatures::TotalUploadSizeInKilobytes, TierFeatures::Agora,
217+
TierFeatures::OpenAI, TierFeatures::Shopify, TierFeatures::TicketedSpace };
223218

224219
csp::common::String UserId;
225220
LogInAsNewTestUser(UserSystem, UserId);
226221

227222
auto [Result] = AWAIT_PRE(QuotaSystem, GetTierFeaturesQuota, RequestPredicate, TierNames::Basic);
228223

229224
EXPECT_EQ(Result.GetResultCode(), csp::systems::EResultCode::Success);
230-
EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), ExpectedInfoArray.Size());
225+
226+
// Please note: In service of OF-1805 a new TierFeature 'GoogleGenAI' was added in CSP to the 'TierFeatures' enum.
227+
// However, until this has also been added by the backend services, calls to 'GetTierFeaturesQuota()' will not return this feature.
228+
// The following test has been temporaily modified to account for this. Once this work has been completed, and the backend
229+
// services have added this tier feature, this test should be reverted to its original form (though with the addition of the new
230+
// feature in the 'TierFeaturesArray' array).
231+
bool IsGoogleGenAITierFeatureEnabled = false;
231232

232233
for (size_t i = 0; i < Result.GetFeaturesQuotaInfo().Size(); i++)
233234
{
234-
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, ExpectedInfoArray[i].FeatureName);
235-
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].TierName, ExpectedInfoArray[i].TierName);
236-
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].Limit, ExpectedInfoArray[i].Limit);
237-
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].Period, ExpectedInfoArray[i].Period);
235+
if (Result.GetFeaturesQuotaInfo()[i].FeatureName == TierFeatures::GoogleGenAI)
236+
{
237+
IsGoogleGenAITierFeatureEnabled = true;
238+
break;
239+
}
240+
}
241+
242+
if (IsGoogleGenAITierFeatureEnabled)
243+
{
244+
EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), TierFeaturesArray.Size() + 1);
245+
}
246+
else
247+
{
248+
EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), TierFeaturesArray.Size());
249+
}
250+
251+
// We do not validate the full FeatureQuotaInfo object here as its data is subject to change.
252+
for (size_t i = 0; i < Result.GetFeaturesQuotaInfo().Size(); i++)
253+
{
254+
if (IsGoogleGenAITierFeatureEnabled)
255+
{
256+
if (i == Result.GetFeaturesQuotaInfo().Size() - 1)
257+
{
258+
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, TierFeatures::GoogleGenAI);
259+
break;
260+
}
261+
}
262+
EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, TierFeaturesArray[i]);
238263
}
239264
}
240265

@@ -245,9 +270,6 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetConcurrentUsersInSpace)
245270
auto QuotaSystem = SystemsManager.GetQuotaSystem();
246271
auto SpaceSystem = SystemsManager.GetSpaceSystem();
247272

248-
csp::common::Array<TierFeatures> TierFeaturesArray = { TierFeatures::SpaceOwner, TierFeatures::ObjectCaptureUpload,
249-
TierFeatures::AudioVideoUpload, TierFeatures::OpenAI, TierFeatures::TicketedSpace };
250-
251273
const char* TestSpaceName = "CSP-UNITTEST-SPACE-MAG";
252274
const char* TestSpaceDescription = "CSP-UNITTEST-SPACEDESC-MAG";
253275

0 commit comments

Comments
 (0)