Reader
This commit is contained in:
@@ -3,4 +3,8 @@ package org.koitharu.kotatsu.parsers
|
||||
interface MangaParserTest {
|
||||
|
||||
fun testMangaList()
|
||||
|
||||
fun testMangaDetails()
|
||||
|
||||
fun testMangaPages()
|
||||
}
|
||||
@@ -8,27 +8,46 @@ import org.junit.runner.RunWith
|
||||
import org.koitharu.kotatsu.domain.repository.ReadmangaRepository
|
||||
import org.koitharu.kotatsu.parsers.MangaParserTest
|
||||
import org.koitharu.kotatsu.parsers.RepositoryTestEnvironment
|
||||
import org.koitharu.kotatsu.utils.MyAsserts
|
||||
import org.koitharu.kotatsu.utils.TestUtil
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ReadmangaRuTest : MangaParserTest {
|
||||
|
||||
@Test
|
||||
override fun testMangaList() {
|
||||
val list = runBlocking { repository.getList(1) }
|
||||
Assert.assertTrue(list.size == 70)
|
||||
val item = list[40]
|
||||
Assert.assertTrue(item.title.isNotEmpty())
|
||||
Assert.assertTrue(item.rating in 0f..1f)
|
||||
MyAsserts.assertValidUrl(item.url)
|
||||
MyAsserts.assertValidUrl(item.coverUrl)
|
||||
}
|
||||
@Test
|
||||
override fun testMangaList() {
|
||||
val list = runBlocking { repository.getList(1) }
|
||||
Assert.assertTrue(list.size == 70)
|
||||
val item = list[40]
|
||||
Assert.assertTrue(item.title.isNotEmpty())
|
||||
Assert.assertTrue(item.rating in 0f..1f)
|
||||
TestUtil.assertValidUrl(item.url)
|
||||
TestUtil.assertValidUrl(item.coverUrl)
|
||||
}
|
||||
|
||||
companion object : RepositoryTestEnvironment() {
|
||||
@Test
|
||||
override fun testMangaDetails() {
|
||||
val manga = runBlocking { repository.getDetails(repository.getList(1).last()) }
|
||||
Assert.assertNotNull(manga.largeCoverUrl)
|
||||
TestUtil.assertValidUrl(manga.largeCoverUrl!!)
|
||||
Assert.assertNotNull(manga.chapters)
|
||||
val chapter = manga.chapters!!.last()
|
||||
TestUtil.assertValidUrl(chapter.url)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun setUp() = initialize(ReadmangaRepository::class.java)
|
||||
}
|
||||
@Test
|
||||
override fun testMangaPages() {
|
||||
val chapter = runBlocking { repository.getDetails(repository.getList(1).last()).chapters!!.first() }
|
||||
val pages = runBlocking { repository.getPages(chapter) }
|
||||
Assert.assertFalse(pages.isEmpty())
|
||||
TestUtil.assertValidUrl(runBlocking { repository.getPageFullUrl(pages.first()) })
|
||||
TestUtil.assertValidUrl(runBlocking { repository.getPageFullUrl(pages.last()) })
|
||||
}
|
||||
|
||||
companion object : RepositoryTestEnvironment() {
|
||||
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun setUp() = initialize(ReadmangaRepository::class.java)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.junit.Assert
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
object MyAsserts {
|
||||
object TestUtil {
|
||||
|
||||
private val VALID_RESPONSE_CODES = arrayOf(
|
||||
HttpURLConnection.HTTP_OK,
|
||||
Reference in New Issue
Block a user