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,37 @@
|
||||
// Routes: POST /google/cloudai/vision/{annotate,list}, /google/cloudai/language/analyze
|
||||
#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";
|
||||
std::string ok = "{\"images\":[{\"uri\":\"gs://b/i.png\"}],\"features\":[{\"type\":\"LABEL_DETECTION\",\"maxResults\":3}]";
|
||||
auto dry = f.client->post("/google/cloudai/vision/annotate", ok + "}", j);
|
||||
check(dry.status == 200 && contains(dry.body, "\"dry_run\":true") && contains(dry.body, "gcsImageUri"), "annotate dry run");
|
||||
check(f.client->post("/google/cloudai/vision/annotate", ok + ",\"confirm\":true}", j).status == 503, "confirmed is 503");
|
||||
check(f.client->post("/google/cloudai/vision/annotate", "{}", j).status == 422, "images required");
|
||||
check(f.client->post("/google/cloudai/vision/annotate", "{\"images\":[{\"uri\":\"gs://b/i\"}],\"features\":[\"NOPE\"]}", j).status == 422, "unknown feature is 422");
|
||||
check(f.client->post("/google/cloudai/vision/annotate", "{\"images\":[{}],\"features\":[\"LABEL_DETECTION\"]}", j).status == 422, "empty image is 422");
|
||||
check(f.client->post("/google/cloudai/vision/annotate", "{\"images\":[{\"uri\":\"gs://b/i\"}],\"features\":[{\"type\":\"LABEL_DETECTION\",\"maxResults\":500}]}", j).status == 422, "maxResults over cap is 422");
|
||||
auto small = f.client->post("/google/cloudai/vision/annotate", "{\"images\":[{\"content\":\"" + std::string(100, 'A') + "\"}],\"features\":[\"LABEL_DETECTION\"]}", j);
|
||||
check(small.status == 200, "small inline image dry run");
|
||||
auto sets = f.client->post("/google/cloudai/vision/list", "{\"what\":\"productSets\"}", j);
|
||||
check(sets.status == 503, "list without credential is 503");
|
||||
check(f.client->post("/google/cloudai/vision/list", "{\"what\":\"referenceImages\"}", j).status == 422, "productId required");
|
||||
check(f.client->get("/google/cloudai/vision/list").status == 405, "get is 405");
|
||||
|
||||
auto nl = f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"sentiment\",\"content\":\"great\"}", j);
|
||||
check(nl.status == 200 && contains(nl.body, "\"dry_run\":true"), "analyze dry run");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"sentiment\",\"content\":\"great\",\"confirm\":true}", j).status == 503, "confirmed is 503");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"syntax\",\"content\":\"great\",\"confirm\":true}", j).status == 503, "v1 syntax is 503");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"sentiment\"}", j).status == 422, "content required");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"other\",\"content\":\"x\"}", j).status == 422, "unknown kind");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"annotate\",\"content\":\"x\"}", j).status == 422, "annotate needs a feature");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"annotate\",\"content\":\"x\",\"classifyText\":true}", j).status == 200, "annotate with a feature");
|
||||
check(f.client->post("/google/cloudai/language/analyze", "{\"kind\":\"sentiment\",\"content\":\"x\",\"type\":\"MD\"}", j).status == 422, "bad type");
|
||||
check(rig.mock->send_count() == 0, "nothing reached Google");
|
||||
return finish("google/cloudai/vision_language");
|
||||
}
|
||||
Reference in New Issue
Block a user