-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automl: break tests into individual test files and remove bom from po…
…m for v1 library support (#1928) * automl: break tests into individual files * remove bom from automl until bom is released with v1 of client library * Update DeleteModelTest.java * run code formatter * Remove file that has been replaced by VisionClassificationDeployModelNodeCountTest * Update tests to use centralized automl testing project
- Loading branch information
Showing
8 changed files
with
455 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 0 additions & 134 deletions
134
automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.automl; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static junit.framework.TestCase.assertNotNull; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.PrintStream; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class GetModelEvaluationTest { | ||
private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); | ||
private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); | ||
private String modelEvaluationId; | ||
private ByteArrayOutputStream bout; | ||
private PrintStream out; | ||
|
||
private static void requireEnvVar(String varName) { | ||
assertNotNull( | ||
System.getenv(varName), | ||
"Environment variable '%s' is required to perform these tests.".format(varName)); | ||
} | ||
|
||
@BeforeClass | ||
public static void checkRequirements() { | ||
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); | ||
requireEnvVar("AUTOML_PROJECT_ID"); | ||
requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); | ||
} | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
bout = new ByteArrayOutputStream(); | ||
out = new PrintStream(bout); | ||
System.setOut(out); | ||
|
||
// Get a model evaluation ID from the List request first to be used in the Get call | ||
ListModelEvaluations.listModelEvaluations(PROJECT_ID, MODEL_ID); | ||
String got = bout.toString(); | ||
modelEvaluationId = got.split(MODEL_ID + "/modelEvaluations/")[1].split("\n")[0]; | ||
assertThat(got).contains("Model Evaluation Name:"); | ||
|
||
bout = new ByteArrayOutputStream(); | ||
out = new PrintStream(bout); | ||
System.setOut(out); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
System.setOut(null); | ||
} | ||
|
||
@Test | ||
public void testGetModelEvaluation() throws IOException { | ||
GetModelEvaluation.getModelEvaluation(PROJECT_ID, MODEL_ID, modelEvaluationId); | ||
String got = bout.toString(); | ||
assertThat(got).contains("Model Evaluation Name:"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.automl; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static junit.framework.TestCase.assertNotNull; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.PrintStream; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class GetModelTest { | ||
private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); | ||
private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); | ||
private ByteArrayOutputStream bout; | ||
private PrintStream out; | ||
|
||
private static void requireEnvVar(String varName) { | ||
assertNotNull( | ||
System.getenv(varName), | ||
"Environment variable '%s' is required to perform these tests.".format(varName)); | ||
} | ||
|
||
@BeforeClass | ||
public static void checkRequirements() { | ||
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); | ||
requireEnvVar("AUTOML_PROJECT_ID"); | ||
requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
bout = new ByteArrayOutputStream(); | ||
out = new PrintStream(bout); | ||
System.setOut(out); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
System.setOut(null); | ||
} | ||
|
||
@Test | ||
public void testGetModel() throws IOException { | ||
GetModel.getModel(PROJECT_ID, MODEL_ID); | ||
String got = bout.toString(); | ||
assertThat(got).contains("Model id: " + MODEL_ID); | ||
} | ||
} |
Oops, something went wrong.