Fixes #4260 - Item with P582 (end time) shown as existing (#4292)

* fix issue with item with endtime shown as existing

* Removed destroyed and endtime, Added comments and also fixed the broken tests

* minor fix

* Added comments

* fix no such column location_exists error

* minor improvement

Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
Pratham Pahariya 2021-03-17 20:35:08 +05:30 committed by GitHub
parent d00127947c
commit 944225c3a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 28 deletions

View file

@ -38,7 +38,7 @@ class BookMarkLocationDaoTest {
COLUMN_LAT,
COLUMN_LONG,
COLUMN_PIC,
COLUMN_DESTROYED)
COLUMN_EXISTS)
private val client: ContentProviderClient = mock()
private val database: SQLiteDatabase = mock()
private val captor = argumentCaptor<ContentValues>()
@ -63,7 +63,7 @@ class BookMarkLocationDaoTest {
examplePlaceBookmark = Place("en", "placeName", exampleLabel, "placeDescription"
, exampleLocation, "placeCategory", builder.build(),"picName","placeDestroyed")
, exampleLocation, "placeCategory", builder.build(),"picName",false)
testObject = BookmarkLocationsDao { client }
}
@ -98,7 +98,7 @@ class BookMarkLocationDaoTest {
assertEquals(builder.build().wikidataLink, it.siteLinks.wikidataLink)
assertEquals(builder.build().commonsLink, it.siteLinks.commonsLink)
assertEquals("picName",it.pic)
assertEquals("placeDestroyed", it.destroyed)
assertEquals(false, it.exists)
}
}
}
@ -163,7 +163,7 @@ class BookMarkLocationDaoTest {
assertEquals(examplePlaceBookmark.siteLinks.wikidataLink.toString(), cv.getAsString(COLUMN_WIKIDATA_LINK))
assertEquals(examplePlaceBookmark.siteLinks.commonsLink.toString(), cv.getAsString(COLUMN_COMMONS_LINK))
assertEquals(examplePlaceBookmark.pic.toString(), cv.getAsString(COLUMN_PIC))
assertEquals(examplePlaceBookmark.destroyed.toString(), cv.getAsString(COLUMN_DESTROYED))
assertEquals(examplePlaceBookmark.exists.toString(), cv.getAsString(COLUMN_EXISTS))
}
}
@ -271,13 +271,19 @@ class BookMarkLocationDaoTest {
verify(database).execSQL("ALTER TABLE bookmarksLocations ADD COLUMN location_language STRING;")
}
@Test
fun migrateTableVersionFrom_v14_to_v15() {
onUpdate(database, 14, 15)
verify(database).execSQL("ALTER TABLE bookmarksLocations ADD COLUMN location_exists STRING;")
}
private fun createCursor(rowCount: Int) = MatrixCursor(columns, rowCount).apply {
for (i in 0 until rowCount) {
addRow(listOf("placeName", "en", "placeDescription", "placeCategory", exampleLabel.text, exampleLabel.icon,
exampleUri, builder.build().wikipediaLink, builder.build().wikidataLink, builder.build().commonsLink,
exampleLocation.latitude, exampleLocation.longitude, "picName", "placeDestroyed"))
exampleLocation.latitude, exampleLocation.longitude, "picName", "placeExists"))
}
}
}

View file

@ -33,8 +33,8 @@ class BookmarkLocationControllerTest {
private val mockBookmarkList: List<Place>
private get() {
val list = ArrayList<Place>()
list.add(Place("en","a place",null,"a description",null,"a cat",null,null,null))
list.add(Place("en","another place",null,"another description",null,"another cat",null,null,null))
list.add(Place("en","a place",null,"a description",null,"a cat",null,null,true))
list.add(Place("en","another place",null,"another description",null,"another cat",null,null,true))
return list
}