Fix image not loading issue in peer review (#2902)

* Fix image loading issue in peer review

* With more test cases
This commit is contained in:
Vivek Maskara 2019-04-20 13:12:09 +05:30 committed by neslihanturan
parent 482cad6663
commit accb880256
2 changed files with 20 additions and 4 deletions

View file

@ -50,12 +50,28 @@ class ReviewHelperTest {
.thenReturn(Single.just(listOf(recentChange, recentChange1, recentChange2)))
`when`(mediaWikiApi?.pageExists(ArgumentMatchers.anyString()))
.thenReturn(Single.just(true))
.thenReturn(Single.just(false))
val randomMedia = reviewHelper?.randomMedia?.blockingGet()
assertTrue(randomMedia is Media)
}
/**
* Test scenario when all media is already nominated for deletion
*/
@Test(expected = Exception::class)
fun getRandomMediaWithWithAllMediaNominatedForDeletion() {
val recentChange = getMockRecentChange("test", "File:Test1.jpeg", 0)
val recentChange1 = getMockRecentChange("test", "File:Test2.png", 0)
val recentChange2 = getMockRecentChange("test", "File:Test3.jpg", 0)
`when`(okHttpJsonApiClient?.recentFileChanges)
.thenReturn(Single.just(listOf(recentChange, recentChange1, recentChange2)))
`when`(mediaWikiApi?.pageExists(ArgumentMatchers.anyString()))
.thenReturn(Single.just(true))
reviewHelper?.randomMedia?.blockingGet()
}
fun getMockRecentChange(type: String, title: String, oldRevisionId: Long): RecentChange {
val recentChange = mock(RecentChange::class.java)
`when`(recentChange!!.type).thenReturn(type)