Add another read OPML test

This commit is contained in:
Shinokuni 2020-08-10 23:31:10 +02:00
parent 74447b1671
commit 3657f740df
2 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,9 @@
<opml version="2.0">
<body>
<outline>
<outline title="The Verge" xmlUrl='http://www.theverge.com/rss/index.xml' htmlUrl="http://www.theverge.com" />
</outline>
<outline title="TechCrunch" xmlUrl='https://techcrunch.com/feed/' htmlUrl="https://techcrunch.com/" />
</body>
</opml>

View File

@ -3,7 +3,6 @@ package com.readrops.api
import android.Manifest import android.Manifest
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
@ -11,11 +10,8 @@ import com.readrops.api.opml.OPMLParser
import com.readrops.api.utils.ParseException import com.readrops.api.utils.ParseException
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder import com.readrops.db.entities.Folder
import io.reactivex.CompletableObserver
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertTrue
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -54,6 +50,22 @@ class OPMLParserTest {
stream.close() stream.close()
} }
@Test
fun readLiteSubscriptionsTest() {
val stream = context.resources.assets.open("lite_subscriptions.opml")
var foldersAndFeeds: Map<Folder?, List<Feed>>? = null
OPMLParser.read(stream)
.subscribe { result -> foldersAndFeeds = result }
assertEquals(foldersAndFeeds?.values?.first()?.size, 2)
assertEquals(foldersAndFeeds?.values?.first()?.first()?.url, "http://www.theverge.com/rss/index.xml")
assertEquals(foldersAndFeeds?.values?.first()?.get(1)?.url, "https://techcrunch.com/feed/")
stream.close()
}
@Test @Test
fun opmlVersionTest() { fun opmlVersionTest() {
val stream = context.resources.assets.open("wrong_version.opml") val stream = context.resources.assets.open("wrong_version.opml")