feat(clients): cloudai: Translation, Vision, Language, Video, Document AI, Speech v2, long audio TTS
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// Routes: POST /google/cloudai/translate{,/detect,/list,/glossary}
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
|
||||
GoogleRig rig(false);
|
||||
Fixture f(rig.client);
|
||||
const char* j = "application/json";
|
||||
auto dry = f.client->post("/google/cloudai/translate", "{\"texts\":[\"hi\"],\"target\":\"nl\"}", j);
|
||||
check(dry.status == 200 && contains(dry.body, "\"dry_run\":true") && contains(dry.body, "targetLanguageCode"), "default is a dry run");
|
||||
auto real = f.client->post("/google/cloudai/translate", "{\"text\":\"hi\",\"target\":\"nl\",\"confirm\":true}", j);
|
||||
check(real.status == 503 && contains(real.body, "google_not_configured"), "confirmed without credential is 503");
|
||||
check(f.client->post("/google/cloudai/translate", "{}", j).status == 422, "missing target is 422");
|
||||
check(f.client->post("/google/cloudai/translate", "{\"text\":\"hi\",\"target\":\"n l\"}", j).status == 422, "bad language is 422");
|
||||
check(f.client->post("/google/cloudai/translate", "{\"texts\":[],\"target\":\"nl\"}", j).status == 422, "no text is 422");
|
||||
check(f.client->post("/google/cloudai/translate", "{\"text\":\"hi\",\"target\":\"nl\",\"confirm\":\"yes\"}", j).status == 422, "non-bool confirm is 422");
|
||||
check(f.client->post("/google/cloudai/translate", "{\"text\":\"hi\",\"target\":\"nl\",\"location\":\"../x\"}", j).status == 422, "bad location is 422");
|
||||
check(f.client->post("/google/cloudai/translate", "not json", j).status == 422, "bad json is 422");
|
||||
check(f.client->get("/google/cloudai/translate").status == 405, "get is 405");
|
||||
check(f.client->post("/google/cloudai/translate/detect", "{\"text\":\"bonjour\"}", j).status == 200, "detect dry run");
|
||||
auto det = f.client->post("/google/cloudai/translate/detect", "{\"text\":\"bonjour\",\"confirm\":true}", j);
|
||||
check(det.status == 503, "detect confirmed is 503");
|
||||
check(f.client->post("/google/cloudai/translate/detect", "{}", j).status == 422, "detect needs text");
|
||||
auto lang = f.client->post("/google/cloudai/translate/list", "{\"what\":\"languages\"}", j);
|
||||
check(lang.status == 503 && contains(lang.body, "google_not_configured"), "read without credential is 503");
|
||||
check(f.client->post("/google/cloudai/translate/list", "{\"what\":\"nope\"}", j).status == 422, "bad what is 422");
|
||||
check(f.client->post("/google/cloudai/translate/list", "{\"what\":\"glossaries\",\"location\":\"bad loc\"}", j).status == 422, "bad location");
|
||||
auto gdry = f.client->post("/google/cloudai/translate/glossary", "{\"action\":\"delete\",\"id\":\"g1\"}", j);
|
||||
check(gdry.status == 200 && contains(gdry.body, "\"dry_run\":true"), "glossary delete is a dry run");
|
||||
auto gmake = f.client->post("/google/cloudai/translate/glossary",
|
||||
"{\"action\":\"create\",\"id\":\"g1\",\"inputUri\":\"gs://b/g.csv\",\"source\":\"en\",\"target\":\"nl\"}", j);
|
||||
check(gmake.status == 200 && contains(gmake.body, "languagePair"), "glossary create is a dry run");
|
||||
auto greal = f.client->post("/google/cloudai/translate/glossary", "{\"action\":\"delete\",\"id\":\"g1\",\"confirm\":true}", j);
|
||||
check(greal.status == 503, "confirmed delete without credential is 503");
|
||||
check(f.client->post("/google/cloudai/translate/glossary", "{\"action\":\"create\",\"id\":\"g1\",\"inputUri\":\"http://x\",\"source\":\"en\",\"target\":\"nl\"}", j).status == 422, "bad inputUri is 422");
|
||||
check(f.client->post("/google/cloudai/translate/glossary", "{\"action\":\"get\",\"id\":\"a/b\"}", j).status == 422, "bad id is 422");
|
||||
check(rig.mock->send_count() == 0, "nothing reached Google");
|
||||
return finish("google/cloudai/translate");
|
||||
}
|
||||
Reference in New Issue
Block a user