Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Text.RegularExpressions;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.Test.HttpRecorder;
using Vision = Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;

namespace ComputerVisionSDK.Tests
Expand All @@ -8,6 +13,43 @@ public abstract class BaseTests
{
public static bool IsTestTenant = false;
private static readonly string ComputerVisionSubscriptionKey;
private static Lazy<string> TestBaseUrl = new Lazy<string>(() =>
{
string user = "Azure";
const string branch = "psSdkJson6";

if (HttpMockServer.Mode == HttpRecorderMode.Record)
{
// The test images are checked in to git, so we see if can determine the URL to these.
// To allow for those working in forks to also test, we try and figure out the base URL using git.
// When all else fails, fall back to master.

try
{
var git = new Process();
git.StartInfo.FileName = "git";
git.StartInfo.Arguments = "config --local --list";
git.StartInfo.RedirectStandardOutput = true;
git.StartInfo.CreateNoWindow = true;
git.Start();
var stdout = git.StandardOutput.ReadToEnd();
git.WaitForExit();

var configRegex = new Regex(@"remote\.origin\.url=https://github.com/(\S*)/azure-sdk-for-net.git");
var userMatch = configRegex.Match(stdout);
if (userMatch.Success)
{
user = userMatch.Groups[1].Value;
}
}
catch
{
/* ignore exceptions, fall back to default */
}
}

return $"https://raw.githubusercontent.com/{user}/azure-sdk-for-net/{branch}/src/SDKs/CognitiveServices/dataPlane/Vision/ComputerVision/ComputerVision.Tests/TestImages/";
});

static BaseTests()
{
Expand All @@ -24,5 +66,22 @@ protected IComputerVisionAPI GetComputerVisionClient(DelegatingHandler handler)

return client;
}

/// <summary>
/// Return the relative path to the local test image, for stream-based APIs.
/// </summary>
protected string GetTestImagePath(string name)
{
return Path.Combine("TestImages", name);
}

/// <summary>
/// Return the URL for the test image, for URL-based APIs.
/// The URL is for the project test image served out of github.
/// </summary>
protected string GetTestImageUrl(string name)
{
return TestBaseUrl.Value + name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests Class Library</Description>
<AssemblyName>Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Tests</AssemblyName>
<VersionPrefix>1.0.2-preview</VersionPrefix>
<VersionPrefix>1.0.3</VersionPrefix>
</PropertyGroup>

<PropertyGroup>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Entries": [],
"Names": {},
"Variables": {}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Entries": [
{
"RequestUri": "/vision/v1.0/describe?maxCandidates=1&language=ja",
"EncodedRequestUri": "L3Zpc2lvbi92MS4wL2Rlc2NyaWJlP21heENhbmRpZGF0ZXM9MSZsYW5ndWFnZT1qYQ==",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"url\": \"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/psSdkJson6/src/SDKs/CognitiveServices/dataPlane/Vision/ComputerVision/ComputerVision.Tests/TestImages/dog.jpg\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"184"
],
"Ocp-Apim-Subscription-Key": [
""
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"description\": {\r\n \"tags\": [\r\n \"犬\",\r\n \"屋外\",\r\n \"座る\",\r\n \"動物\",\r\n \"哺乳類\",\r\n \"探す\",\r\n \"茶色\",\r\n \"ベンチ\",\r\n \"イエロー\",\r\n \"フロント\",\r\n \"大きい\",\r\n \"木製\",\r\n \"小さい\",\r\n \"ホワイト\",\r\n \"立つ\",\r\n \"閉じる\",\r\n \"テーブル\",\r\n \"オレンジ\",\r\n \"横たわる\",\r\n \"公園\",\r\n \"頭\"\r\n ],\r\n \"captions\": [\r\n {\r\n \"text\": \"犬の顔\",\r\n \"confidence\": 0.80020958730655689\r\n }\r\n ]\r\n },\r\n \"requestId\": \"f602086d-a901-420e-b90e-86592fc2d5d7\",\r\n \"metadata\": {\r\n \"height\": 599,\r\n \"width\": 455,\r\n \"format\": \"Jpeg\"\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"432"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Connection": [
"close"
],
"Date": [
"Wed, 30 May 2018 20:53:38 GMT"
],
"apim-request-id": [
"f602086d-a901-420e-b90e-86592fc2d5d7"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
],
"x-content-type-options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Entries": [
{
"RequestUri": "/vision/v1.0/describe?maxCandidates=2",
"EncodedRequestUri": "L3Zpc2lvbi92MS4wL2Rlc2NyaWJlP21heENhbmRpZGF0ZXM9Mg==",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"url\": \"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/psSdkJson6/src/SDKs/CognitiveServices/dataPlane/Vision/ComputerVision/ComputerVision.Tests/TestImages/dog.jpg\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"184"
],
"Ocp-Apim-Subscription-Key": [
""
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"description\": {\r\n \"tags\": [\r\n \"dog\",\r\n \"outdoor\",\r\n \"sitting\",\r\n \"animal\",\r\n \"mammal\",\r\n \"looking\",\r\n \"brown\",\r\n \"bench\",\r\n \"yellow\",\r\n \"front\",\r\n \"large\",\r\n \"wooden\",\r\n \"small\",\r\n \"white\",\r\n \"standing\",\r\n \"close\",\r\n \"table\",\r\n \"orange\",\r\n \"laying\",\r\n \"park\",\r\n \"head\"\r\n ],\r\n \"captions\": [\r\n {\r\n \"text\": \"a close up of a dog\",\r\n \"confidence\": 0.96541176672082818\r\n },\r\n {\r\n \"text\": \"close up of a dog\",\r\n \"confidence\": 0.95799109896890555\r\n }\r\n ]\r\n },\r\n \"requestId\": \"b17f1aed-b5bb-4cc3-9ddf-eaedc8f7c9c3\",\r\n \"metadata\": {\r\n \"height\": 599,\r\n \"width\": 455,\r\n \"format\": \"Jpeg\"\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"449"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Connection": [
"close"
],
"Date": [
"Wed, 30 May 2018 20:53:37 GMT"
],
"apim-request-id": [
"b17f1aed-b5bb-4cc3-9ddf-eaedc8f7c9c3"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
],
"x-content-type-options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Entries": [
{
"RequestUri": "/vision/v1.0/models/celebrities/analyze",
"EncodedRequestUri": "L3Zpc2lvbi92MS4wL21vZGVscy9jZWxlYnJpdGllcy9hbmFseXpl",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"url\": \"http://video.ch9.ms/ch9/ac40/1209d088-5752-4413-b003-fdbeb326ac40/IgniteKeynoteSatya_512.jpg\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"107"
],
"Ocp-Apim-Subscription-Key": [
""
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/1.0.2.0"
]
},
"ResponseBody": "{\r\n \"result\": {\r\n \"celebrities\": [\r\n {\r\n \"faceRectangle\": {\r\n \"top\": 50,\r\n \"left\": 212,\r\n \"width\": 54,\r\n \"height\": 54\r\n },\r\n \"name\": \"Satya Nadella\",\r\n \"confidence\": 0.98922520875930786\r\n }\r\n ]\r\n },\r\n \"requestId\": \"21703252-3d98-4561-8c77-da00ba2cd7f2\",\r\n \"metadata\": {\r\n \"height\": 288,\r\n \"width\": 512,\r\n \"format\": \"Jpeg\"\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"252"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Connection": [
"close"
],
"Date": [
"Fri, 25 May 2018 02:54:51 GMT"
],
"apim-request-id": [
"21703252-3d98-4561-8c77-da00ba2cd7f2"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
],
"x-content-type-options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Entries": [
{
"RequestUri": "/vision/v1.0/models/celebrities/analyze",
"EncodedRequestUri": "L3Zpc2lvbi92MS4wL21vZGVscy9jZWxlYnJpdGllcy9hbmFseXpl",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"url\": \"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/psSdkJson6/src/SDKs/CognitiveServices/dataPlane/Vision/ComputerVision/ComputerVision.Tests/TestImages/satya.jpg\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"186"
],
"Ocp-Apim-Subscription-Key": [
""
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"result\": {\r\n \"celebrities\": [\r\n {\r\n \"faceRectangle\": {\r\n \"top\": 50,\r\n \"left\": 212,\r\n \"width\": 54,\r\n \"height\": 54\r\n },\r\n \"name\": \"Satya Nadella\",\r\n \"confidence\": 0.98922520875930786\r\n }\r\n ]\r\n },\r\n \"requestId\": \"f4765af5-fd39-4f20-bf4b-24d1be6b8c31\",\r\n \"metadata\": {\r\n \"height\": 288,\r\n \"width\": 512,\r\n \"format\": \"Jpeg\"\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"252"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Connection": [
"close"
],
"Date": [
"Wed, 30 May 2018 20:53:36 GMT"
],
"apim-request-id": [
"f4765af5-fd39-4f20-bf4b-24d1be6b8c31"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
],
"x-content-type-options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Entries": [
{
"RequestUri": "/vision/v1.0/models/landmarks/analyze?language=pt",
"EncodedRequestUri": "L3Zpc2lvbi92MS4wL21vZGVscy9sYW5kbWFya3MvYW5hbHl6ZT9sYW5ndWFnZT1wdA==",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"url\": \"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/psSdkJson6/src/SDKs/CognitiveServices/dataPlane/Vision/ComputerVision/ComputerVision.Tests/TestImages/spaceneedle.jpg\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"192"
],
"Ocp-Apim-Subscription-Key": [
""
],
"User-Agent": [
"FxVersion/4.6.25211.01",
"Microsoft.Azure.CognitiveServices.Vision.ComputerVision.ComputerVisionAPI/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"result\": {\r\n \"landmarks\": [\r\n {\r\n \"name\": \"Obelisco Espacial\",\r\n \"confidence\": 0.99991440773010254\r\n }\r\n ]\r\n },\r\n \"requestId\": \"a5623e39-1d7b-43ed-b936-23891383179e\",\r\n \"metadata\": {\r\n \"height\": 479,\r\n \"width\": 243,\r\n \"format\": \"Jpeg\"\r\n }\r\n}",
"ResponseHeaders": {
"Content-Length": [
"193"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Connection": [
"close"
],
"Date": [
"Wed, 30 May 2018 20:53:34 GMT"
],
"apim-request-id": [
"a5623e39-1d7b-43ed-b936-23891383179e"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
],
"x-content-type-options": [
"nosniff"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {}
}

Large diffs are not rendered by default.

Loading