mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	tests: fix failing testUpdateDepictsProperty
This commit is contained in:
		
							parent
							
								
									ec4a6bc0c4
								
							
						
					
					
						commit
						51aa0bdff9
					
				
					 2 changed files with 12 additions and 5 deletions
				
			
		|  | @ -47,9 +47,9 @@ class WikiBaseClient @Inject constructor( | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun postDeleteClaims(entityId: String, data: String): Observable<Boolean> { |     fun postDeleteClaims(entityId: String, data: String?): Observable<Boolean> { | ||||||
|         return csrfToken().switchMap { editToken -> |         return csrfToken().switchMap { editToken -> | ||||||
|             wikiBaseInterface.postDeleteClaims(editToken, entityId, data) |             wikiBaseInterface.postDeleteClaims(editToken, entityId, data!!) | ||||||
|                 .map { response: MwPostResponse -> response.successVal == 1 } |                 .map { response: MwPostResponse -> response.successVal == 1 } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -19,6 +19,7 @@ import org.mockito.Mockito | ||||||
| import org.mockito.Mockito.verifyNoInteractions | import org.mockito.Mockito.verifyNoInteractions | ||||||
| import org.mockito.MockitoAnnotations | import org.mockito.MockitoAnnotations | ||||||
| import fr.free.nrw.commons.wikidata.model.EditClaim | import fr.free.nrw.commons.wikidata.model.EditClaim | ||||||
|  | import fr.free.nrw.commons.wikidata.model.RemoveClaim | ||||||
| 
 | 
 | ||||||
| class WikidataEditServiceTest { | class WikidataEditServiceTest { | ||||||
|     @Mock |     @Mock | ||||||
|  | @ -53,9 +54,15 @@ class WikidataEditServiceTest { | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     fun testUpdateDepictsProperty() { |     fun testUpdateDepictsProperty() { | ||||||
|         whenever(wikibaseClient.postEditEntityByFilename("Test.jpg", |         val fileEntityId = "12345" | ||||||
|             gson.toJson(Mockito.mock(EditClaim::class.java)))).thenReturn(Observable.just(true)) | 
 | ||||||
|         wikidataEditService.updateDepictsProperty("Test.jpg", listOf()) |         whenever(wikibaseClient.getClaimIdsByProperty("M" + fileEntityId, "P180")) | ||||||
|  |             .thenReturn(Observable.just(emptyList())) | ||||||
|  |         whenever(wikibaseClient.postDeleteClaims("M" + fileEntityId, | ||||||
|  |             gson.toJson(Mockito.mock(RemoveClaim::class.java))) | ||||||
|  |         ).thenReturn(Observable.just(true)) | ||||||
|  | 
 | ||||||
|  |         wikidataEditService.updateDepictsProperty(fileEntityId, listOf()) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rohit Verma
						Rohit Verma