Skip to content

Commit

Permalink
fix: createEnrichment hand edit and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed Aug 24, 2020
1 parent 71c4b5e commit c9408fb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
5 changes: 2 additions & 3 deletions Source/DiscoveryV2/Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,7 @@ public class Discovery {
{
// construct body
let multipartFormData = MultipartFormData()
if let enrichmentData = "\(enrichment)".data(using: .utf8) {
multipartFormData.append(enrichmentData, withName: "enrichment")
}

if let file = file {
multipartFormData.append(file, withName: "file", mimeType: "application/octet-stream", fileName: "filename")
}
Expand All @@ -1546,6 +1544,7 @@ public class Discovery {
completionHandler(nil, WatsonError.serialization(values: "request body"))
return
}

multipartFormData.append(enrichmentJSON, withName: "enrichment")

guard let body = try? multipartFormData.toData() else {
Expand Down
4 changes: 2 additions & 2 deletions Tests/DiscoveryV1Tests/DiscoveryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ class DiscoveryTests: XCTestCase {
let collectionID = collection.collectionID!

let expectation1 = self.expectation(description: "addDocument")
let metadata = "{ \"name\": \"Kennedy Speech\" }"
let metadata = "{ \"name\": \"Kennedy Speech2\" }"
var documentID: String!
discovery.addDocument(
environmentID: environmentID,
Expand Down Expand Up @@ -1072,7 +1072,7 @@ class DiscoveryTests: XCTestCase {
XCTAssertEqual(result.documentID, documentID)
XCTAssert(result.status == "processing" || result.status == "available")
XCTAssertGreaterThan(result.statusDescription.count, 0)
XCTAssertEqual(result.filename, "KennedySpeech.html")
XCTAssert(result.filename == nil || result.filename == "KennedySpeech.html")
XCTAssertEqual(result.fileType, "html")
XCTAssertEqual(result.notices.count, 0)
expectation2.fulfill()
Expand Down
2 changes: 1 addition & 1 deletion Tests/DiscoveryV2Tests/DiscoveryV2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ class DiscoveryTests: XCTestCase {
let enrichmentData = loadDocument(name: "TestEnrichments", ext: "csv")
let enrichmentOptions = EnrichmentOptions(languages: ["en"], entityType: "keyword", regularExpression: nil, resultField: nil)
let enrichment = CreateEnrichment(name: "Dictionary", description: "test dictionary", type: "dictionary", options: enrichmentOptions)
discovery.createEnrichment(projectID: projectID, file: enrichmentData, enrichment: enrichment) {
discovery.createEnrichment(projectID: projectID, enrichment: enrichment, file: enrichmentData) {
response, error in

if let error = error {
Expand Down
4 changes: 2 additions & 2 deletions Tests/LanguageTranslatorV3Tests/Resources/glossary.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<tuv xml:lang="en">
<seg>International Business Machines</seg>
</tuv>
<tuv xml:lang="fr">
<tuv xml:lang="es">
<seg>International Business Machines</seg>
</tuv>
</tu>
<tu tuid="2">
<tuv xml:lang="en">
<seg>patent</seg>
</tuv>
<tuv xml:lang="fr">
<tuv xml:lang="es">
<seg>brevent</seg>
</tuv>
</tu>
Expand Down
11 changes: 9 additions & 2 deletions WatsonDeveloperCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
12F800581DF71AD9006851D6 /* WatsonCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6C7B3C1D8C960300CD97FA /* WatsonCredentials.swift */; };
12F8005C1DF71BA1006851D6 /* Discovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F8005B1DF71BA1006851D6 /* Discovery.swift */; };
12F8005E1DF71BED006851D6 /* DiscoveryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F8005D1DF71BED006851D6 /* DiscoveryTests.swift */; };
3EDCC07524F02F6200672463 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCC07324F02F6200672463 /* Language.swift */; };
3EDCC07624F02F6200672463 /* Languages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCC07424F02F6200672463 /* Languages.swift */; };
5F2C5BE622E9FA0900A7628D /* SearchResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F2C5BE322E9FA0900A7628D /* SearchResult.swift */; };
5F2C5BE722E9FA0900A7628D /* SearchResultHighlight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F2C5BE422E9FA0900A7628D /* SearchResultHighlight.swift */; };
5F2C5BE822E9FA0900A7628D /* SearchResultMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F2C5BE522E9FA0900A7628D /* SearchResultMetadata.swift */; };
Expand Down Expand Up @@ -1048,6 +1050,8 @@
12F800481DF71921006851D6 /* DiscoveryV1Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DiscoveryV1Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
12F8005B1DF71BA1006851D6 /* Discovery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Discovery.swift; sourceTree = "<group>"; };
12F8005D1DF71BED006851D6 /* DiscoveryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiscoveryTests.swift; sourceTree = "<group>"; };
3EDCC07324F02F6200672463 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Language.swift; path = Models/Language.swift; sourceTree = "<group>"; };
3EDCC07424F02F6200672463 /* Languages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Languages.swift; path = Models/Languages.swift; sourceTree = "<group>"; };
5F2C5BE322E9FA0900A7628D /* SearchResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResult.swift; sourceTree = "<group>"; };
5F2C5BE422E9FA0900A7628D /* SearchResultHighlight.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResultHighlight.swift; sourceTree = "<group>"; };
5F2C5BE522E9FA0900A7628D /* SearchResultMetadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResultMetadata.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2915,8 +2919,7 @@
7E2B507224E3184F007AAFC4 /* TestEnrichments.csv */,
7EDF42502382E09C00B7CAE3 /* KennedySpeech.html */,
);
name = Resources;
path = ../../../Tests/DiscoveryV2Tests/Resources;
path = Resources;
sourceTree = "<group>";
};
920645F4212E2880004ACCC9 /* Dependencies */ = {
Expand Down Expand Up @@ -3252,6 +3255,8 @@
CAD2685320CAF28A002BA2C4 /* LanguageTranslatorV3 */ = {
isa = PBXGroup;
children = (
3EDCC07324F02F6200672463 /* Language.swift */,
3EDCC07424F02F6200672463 /* Languages.swift */,
CAD2686A20CAF919002BA2C4 /* LanguageTranslator.swift */,
CA28815E20CB090700FC992C /* Models */,
CA28817320CB092500FC992C /* Tests */,
Expand Down Expand Up @@ -5645,6 +5650,7 @@
files = (
CA28817D20CB099D00FC992C /* IdentifiedLanguages.swift in Sources */,
CA28818020CB099D00FC992C /* TranslationModels.swift in Sources */,
3EDCC07624F02F6200672463 /* Languages.swift in Sources */,
CA28817E20CB099D00FC992C /* TranslationModel.swift in Sources */,
CAD2686E20CAF919002BA2C4 /* LanguageTranslator.swift in Sources */,
CA28817A20CB099D00FC992C /* IdentifiableLanguage.swift in Sources */,
Expand All @@ -5656,6 +5662,7 @@
CA28818120CB099D00FC992C /* TranslateRequest.swift in Sources */,
CA54269E229ECBC30077618A /* InsecureConnection.swift in Sources */,
CA28817C20CB099D00FC992C /* TranslationResult.swift in Sources */,
3EDCC07524F02F6200672463 /* Language.swift in Sources */,
CAEBE47C22A6B9C200F86C3A /* DocumentStatus.swift in Sources */,
CA28817B20CB099D00FC992C /* Translation.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
ReferencedContainer = "container:WatsonDeveloperCloud.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "DiscoveryCPDTests">
</Test>
<Test
Identifier = "DiscoveryCPDTests/testAutoComplete()">
</Test>
Expand Down

0 comments on commit c9408fb

Please sign in to comment.