-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: OONIAPIClientTest using failing API endpoint and incorrect testi…
…ng logic (#784) Fixes ooni/probe#2778 ## Proposed Changes - Switch testing endpoint from `ams-pg.ooni.org` to `https://backend-hel.ooni.org` - Refactor `OONIAPIClientTest` to Kotlin - Execute API calls synchronously to fix incorrect async logic - Remove database operations that were irrelevant to the `testSelectMeasurementsWithJson` test - Remove the test `getMeasurementJsonError` because it was only testing external libraries logic (retrofit and gson) and not the `OONIAPIClient`
- Loading branch information
Showing
4 changed files
with
48 additions
and
161 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
156 changes: 0 additions & 156 deletions
156
app/src/test/java/org/openobservatory/ooniprobe/client/OONIAPIClientTest.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
app/src/test/java/org/openobservatory/ooniprobe/client/OONIAPIClientTest.kt
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,47 @@ | ||
package org.openobservatory.ooniprobe.client | ||
|
||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import org.openobservatory.ooniprobe.RobolectricAbstractTest | ||
|
||
class OONIAPIClientTest : RobolectricAbstractTest() { | ||
|
||
@Test | ||
fun measurementSuccess() { | ||
val response = apiClient.getMeasurement(EXISTING_REPORT_ID, null).execute() | ||
|
||
assertTrue(response.isSuccessful) | ||
response.body().use { body -> | ||
assertNotNull(body) | ||
assertNotNull(body!!.string()) | ||
} | ||
} | ||
|
||
@Test | ||
fun measurementError() { | ||
val response = apiClient.getMeasurement(NON_EXISTING_REPORT_ID, null).execute() | ||
|
||
assertFalse(response.isSuccessful) | ||
} | ||
|
||
@Test | ||
fun testSelectMeasurementsWithJson() { | ||
val response = apiClient.checkReportId(EXISTING_REPORT_ID).execute() | ||
|
||
assertTrue(response.isSuccessful) | ||
with(response.body()) { | ||
assertNotNull(this) | ||
assertTrue(this!!.found) | ||
} | ||
} | ||
|
||
private val apiClient get() = a.apiClient | ||
|
||
companion object { | ||
private const val EXISTING_REPORT_ID = | ||
"20190113T202156Z_AS327931_CgoC3KbgM6zKajvIIt1AxxybJ1HbjwwWJjsJnlxy9rpcGY54VH" | ||
private const val NON_EXISTING_REPORT_ID = "EMPTY" | ||
} | ||
} |
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