Skip to content

Commit efe45fd

Browse files
committed
chore: Updates for filename
1 parent ae99688 commit efe45fd

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public bool CreateClassifier(Callback<Classifier> callback, string name, Diction
420420
foreach (KeyValuePair<string, System.IO.MemoryStream> entry in positiveExamples)
421421
{
422422
var partName = string.Format("{0}_positive_examples", entry.Key);
423-
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file", "application/octet-stream");
423+
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file.zip", "application/octet-stream");
424424
}
425425
}
426426
if (negativeExamples != null)
@@ -742,7 +742,7 @@ public bool UpdateClassifier(Callback<Classifier> callback, string classifierId,
742742
foreach (KeyValuePair<string, System.IO.MemoryStream> entry in positiveExamples)
743743
{
744744
var partName = string.Format("{0}_positive_examples", entry.Key);
745-
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file", "application/octet-stream");
745+
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file.zip", "application/octet-stream");
746746
}
747747
}
748748
if (negativeExamples != null)

Tests/DiscoveryV1IntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ public IEnumerator TestTestConfigurationInEnvironment()
330330
environmentId: environmentId,
331331
configurationId: createdConfigurationId,
332332
file: ms,
333-
fileContentType: Utility.GetMimeType(Path.GetExtension(watsonBeatsJeopardyHtmlFilePath))
333+
fileContentType: Utility.GetMimeType(Path.GetExtension(watsonBeatsJeopardyHtmlFilePath)),
334+
filename: Path.GetFileName(watsonBeatsJeopardyHtmlFilePath)
334335
);
335336

336337
while (testConfigurationInEnvironmentResponse == null)

Tests/VisualRecognitionV3IntegrationTests.cs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,54 @@ public void TestSetup()
7878
service.WithHeader("X-Watson-Test", "1");
7979
}
8080

81-
#region Classify
81+
#region CreateClassifier
8282
[UnityTest, Order(0)]
83+
public IEnumerator TestCreateClassifier()
84+
{
85+
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "Attempting to CreateClassifier...");
86+
Classifier createClassifierResponse = null;
87+
using (FileStream fs0 = File.OpenRead(giraffePositiveExamplesFilepath))
88+
{
89+
using (FileStream fs1 = File.OpenRead(negativeExamplesFilepath))
90+
{
91+
using (MemoryStream ms0 = new MemoryStream())
92+
{
93+
using (MemoryStream ms1 = new MemoryStream())
94+
{
95+
fs0.CopyTo(ms0);
96+
fs1.CopyTo(ms1);
97+
Dictionary<string, MemoryStream> positiveExamples = new Dictionary<string, MemoryStream>();
98+
positiveExamples.Add("giraffe_positive_examples", ms0);
99+
service.CreateClassifier(
100+
callback: (DetailedResponse<Classifier> response, IBMError error) =>
101+
{
102+
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "CreateClassifier result: {0}", response.Response);
103+
createClassifierResponse = response.Result;
104+
classifierId = createClassifierResponse.ClassifierId;
105+
Assert.IsNotNull(createClassifierResponse);
106+
Assert.IsNotNull(classifierId);
107+
Assert.IsTrue(createClassifierResponse.Name == classifierName);
108+
Assert.IsNotNull(createClassifierResponse.Classes);
109+
Assert.IsTrue(createClassifierResponse.Classes.Count > 0);
110+
Assert.IsTrue(createClassifierResponse.Classes[0].ClassName == "giraffe");
111+
Assert.IsNull(error);
112+
},
113+
name: classifierName,
114+
positiveExamples: positiveExamples,
115+
negativeExamples: ms1
116+
);
117+
118+
while (createClassifierResponse == null)
119+
yield return null;
120+
}
121+
}
122+
}
123+
}
124+
}
125+
#endregion
126+
127+
#region Classify
128+
[UnityTest, Order(1)]
83129
public IEnumerator TestClassify()
84130
{
85131
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "Attempting to Classify...");
@@ -114,7 +160,7 @@ public IEnumerator TestClassify()
114160
#endregion
115161

116162
#region DetectFaces
117-
[UnityTest, Order(1)]
163+
[UnityTest, Order(2)]
118164
public IEnumerator TestDetectFaces()
119165
{
120166
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "Attempting to DetectFaces...");
@@ -148,52 +194,6 @@ public IEnumerator TestDetectFaces()
148194
}
149195
#endregion
150196

151-
#region CreateClassifier
152-
[UnityTest, Order(2)]
153-
public IEnumerator TestCreateClassifier()
154-
{
155-
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "Attempting to CreateClassifier...");
156-
Classifier createClassifierResponse = null;
157-
using (FileStream fs0 = File.OpenRead(giraffePositiveExamplesFilepath))
158-
{
159-
using (FileStream fs1 = File.OpenRead(negativeExamplesFilepath))
160-
{
161-
using (MemoryStream ms0 = new MemoryStream())
162-
{
163-
using (MemoryStream ms1 = new MemoryStream())
164-
{
165-
fs0.CopyTo(ms0);
166-
fs1.CopyTo(ms1);
167-
Dictionary<string, MemoryStream> positiveExamples = new Dictionary<string, MemoryStream>();
168-
positiveExamples.Add("giraffe_positive_examples", ms0);
169-
service.CreateClassifier(
170-
callback: (DetailedResponse<Classifier> response, IBMError error) =>
171-
{
172-
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "CreateClassifier result: {0}", response.Response);
173-
createClassifierResponse = response.Result;
174-
classifierId = createClassifierResponse.ClassifierId;
175-
Assert.IsNotNull(createClassifierResponse);
176-
Assert.IsNotNull(classifierId);
177-
Assert.IsTrue(createClassifierResponse.Name == classifierName);
178-
Assert.IsNotNull(createClassifierResponse.Classes);
179-
Assert.IsTrue(createClassifierResponse.Classes.Count > 0);
180-
Assert.IsTrue(createClassifierResponse.Classes[0].ClassName == "giraffe");
181-
Assert.IsNull(error);
182-
},
183-
name: classifierName,
184-
positiveExamples: positiveExamples,
185-
negativeExamples: ms1
186-
);
187-
188-
while (createClassifierResponse == null)
189-
yield return null;
190-
}
191-
}
192-
}
193-
}
194-
}
195-
#endregion
196-
197197
#region GetClassifier
198198
[UnityTest, Order(3)]
199199
public IEnumerator TestGetClassifier()

0 commit comments

Comments
 (0)