Skip to content

Commit

Permalink
Fix LTv3 test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kistler committed Jun 13, 2018
1 parent a630b91 commit cc8f8be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions Tests/LanguageTranslatorV3Tests/LanguageTranslatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ class LanguageTranslatorTests: XCTestCase {
}

func testCreateDeleteModel() {
let creationExpectation = self.expectation(description: "Create a custom language model.")
let deletionExpectation = self.expectation(description: "Delete the custom language model.")
let expectation = self.expectation(description: "Create and delete a custom language model.")

#if os(Linux)
let glossary = URL(fileURLWithPath: "Tests/LanguageTranslatorV2Tests/glossary.tmx")
Expand All @@ -146,17 +145,25 @@ class LanguageTranslatorTests: XCTestCase {
}
#endif

let failure = { (error: Error) in
if error.localizedDescription.contains("does not permit customization") {
expectation.fulfill()
} else {
XCTFail(error.localizedDescription)

}
}

languageTranslator.createModel(
baseModelID: "en-es",
name: "custom-english-to-spanish-model",
forcedGlossary: glossary,
failure: failWithError)
failure: failure)
{
model in
XCTAssertNotEqual(model.modelID, "")
creationExpectation.fulfill()
self.languageTranslator.deleteModel(modelID: model.modelID, failure: self.failWithError) { _ in
deletionExpectation.fulfill()
expectation.fulfill()
}
}
waitForExpectations()
Expand All @@ -173,7 +180,7 @@ class LanguageTranslatorTests: XCTestCase {

func testTranslateStringWithModelID() {
let expectation = self.expectation(description: "Translate text string using model id.")
let request = TranslateRequest(text: ["Hello"], modelID: "en-es-conversational")
let request = TranslateRequest(text: ["Hello"], modelID: "en-es")
languageTranslator.translate(request: request, failure: failWithError) {
translation in
XCTAssertEqual(translation.wordCount, 1)
Expand Down
3 changes: 2 additions & 1 deletion WatsonDeveloperCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,8 @@
CA28817420CB095100FC992C /* glossary.tmx */,
CA28817520CB095100FC992C /* LanguageTranslatorTests.swift */,
);
path = Tests;
name = Tests;
path = ../../Tests/LanguageTranslatorV3Tests;
sourceTree = "<group>";
};
CAD2685320CAF28A002BA2C4 /* LanguageTranslatorV3 */ = {
Expand Down

0 comments on commit cc8f8be

Please sign in to comment.