mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Fixed unit tests
This commit is contained in:
		
							parent
							
								
									04539e0afe
								
							
						
					
					
						commit
						810d86cdd3
					
				
					 7 changed files with 0 additions and 82 deletions
				
			
		|  | @ -96,7 +96,6 @@ class UploadClientTest { | |||
|         assertSame(uploadResult, result.values()[0]) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testUploadFileFromStash_WithError() { | ||||
|         val error = mock<MwServiceError>() | ||||
|  | @ -121,7 +120,6 @@ class UploadClientTest { | |||
|         assertEquals(errorCode, result.errors()[0].message) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testUploadFileFromStash_Failure() { | ||||
|         val exception = Exception("test") | ||||
|  | @ -177,7 +175,6 @@ class UploadClientTest { | |||
|         assertEquals(fileContent, fileCaptor.firstValue.body.asString()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testUploadChunkToStash_Failure() { | ||||
|         val exception = Exception("expected") | ||||
|  | @ -190,7 +187,6 @@ class UploadClientTest { | |||
|         assertSame(exception, result.errors()[0]) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun uploadFileToStash_completedContribution() { | ||||
|         whenever(contribution.isCompleted()).thenReturn(true) | ||||
|  | @ -204,23 +200,6 @@ class UploadClientTest { | |||
|         assertEquals(StashUploadState.SUCCESS, stashResult.state) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun uploadFileToStash_contributionIsUnpaused() { | ||||
|         whenever(contribution.isCompleted()).thenReturn(false) | ||||
|         whenever(contribution.fileKey).thenReturn(filekey) | ||||
|         whenever(fileUtilsWrapper.getMimeType(anyOrNull<File>())).thenReturn("image/png") | ||||
|         whenever( | ||||
|             fileUtilsWrapper.getFileChunks( | ||||
|                 anyOrNull<File>(), | ||||
|                 eq(expectedChunkSize) | ||||
|             ) | ||||
|         ).thenReturn(emptyList()) | ||||
|         val result = uploadClient.uploadFileToStash(filename, contribution, mock()).test() | ||||
|         result.assertNoErrors() | ||||
|         verify(contribution, times(1)) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun uploadFileToStash_returnsFailureIfNothingToUpload() { | ||||
|         val tempFile = File.createTempFile("tempFile", ".tmp") | ||||
|  | @ -237,7 +216,6 @@ class UploadClientTest { | |||
|         assertEquals(StashUploadState.FAILED, result.values()[0].state) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun uploadFileToStash_returnsFailureIfAnyChunkFails() { | ||||
|         val mockFile = mock<File>() | ||||
|  | @ -271,7 +249,6 @@ class UploadClientTest { | |||
|         assertEquals(StashUploadState.FAILED, result.values()[0].state) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun uploadFileToStash_successWithOneChunk() { | ||||
|         val mockFile = mock<File>() | ||||
|  |  | |||
|  | @ -95,13 +95,11 @@ class UploadRepositoryUnitTest { | |||
|         `when`(contributionDao.save(contribution)).thenReturn(completable) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testBuildContributions() { | ||||
|         assertEquals(repository.buildContributions(), uploadModel.buildContributions()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testPrepareMedia() { | ||||
|         assertEquals( | ||||
|  | @ -110,7 +108,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSaveContribution() { | ||||
|         assertEquals( | ||||
|  | @ -119,13 +116,11 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetUploads() { | ||||
|         assertEquals(repository.uploads, uploadModel.uploads) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testCleanup() { | ||||
|         repository.cleanup() | ||||
|  | @ -134,13 +129,11 @@ class UploadRepositoryUnitTest { | |||
|         verify(depictModel).cleanUp() | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetSelectedCategories() { | ||||
|         assertEquals(repository.selectedCategories, categoriesModel.getSelectedCategories()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSearchAll() { | ||||
|         assertEquals( | ||||
|  | @ -149,21 +142,18 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSetSelectedCategories() { | ||||
|         repository.setSelectedCategories(listOf()) | ||||
|         verify(uploadModel).setSelectedCategories(listOf()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testOnCategoryClicked() { | ||||
|         repository.onCategoryClicked(categoryItem, media) | ||||
|         verify(categoriesModel).onCategoryItemClicked(categoryItem, media) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testContainsYear() { | ||||
|         assertEquals( | ||||
|  | @ -171,25 +161,21 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetLicenses() { | ||||
|         assertEquals(repository.licenses, uploadModel.licenses) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetSelectedLicense() { | ||||
|         assertEquals(repository.selectedLicense, uploadModel.selectedLicense) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetCount() { | ||||
|         assertEquals(repository.count, uploadModel.count) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testPreProcessImage() { | ||||
|         assertEquals( | ||||
|  | @ -198,7 +184,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetImageQuality() { | ||||
|         assertEquals( | ||||
|  | @ -207,7 +192,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetCaptionQuality() { | ||||
|         assertEquals( | ||||
|  | @ -216,13 +200,11 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testDeletePicture() { | ||||
|         assertEquals(repository.deletePicture(""), uploadModel.deletePicture("")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetUploadItemCaseNonNull() { | ||||
|         `when`(uploadModel.items).thenReturn(listOf(uploadItem)) | ||||
|  | @ -232,19 +214,16 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetUploadItemCaseNull() { | ||||
|         assertEquals(repository.getUploadItem(-1), null) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSetSelectedLicense() { | ||||
|         assertEquals(repository.setSelectedLicense(""), uploadModel.setSelectedLicense("")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSetSelectedExistingDepictions() { | ||||
|         assertEquals( | ||||
|  | @ -253,7 +232,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testOnDepictItemClicked() { | ||||
|         assertEquals( | ||||
|  | @ -262,19 +240,16 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetSelectedDepictions() { | ||||
|         assertEquals(repository.selectedDepictions, uploadModel.selectedDepictions) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetSelectedExistingDepictions() { | ||||
|         assertEquals(repository.selectedExistingDepictions, uploadModel.selectedExistingDepictions) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSearchAllEntities() { | ||||
|         assertEquals( | ||||
|  | @ -283,7 +258,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetPlaceDepictions() { | ||||
|         `when`(uploadModel.uploads).thenReturn(listOf(uploadItem)) | ||||
|  | @ -295,7 +269,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testCheckNearbyPlacesWithoutExceptionCaseNonNull() { | ||||
|         `when`( | ||||
|  | @ -311,7 +284,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testCheckNearbyPlacesWithoutExceptionCaseNull() { | ||||
|         assertEquals( | ||||
|  | @ -320,7 +292,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testCheckNearbyPlacesWithException() { | ||||
|         `when`( | ||||
|  | @ -336,7 +307,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testUseSimilarPictureCoordinates() { | ||||
|         assertEquals( | ||||
|  | @ -345,7 +315,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testIsWMLSupportedForThisPlace() { | ||||
|         `when`(uploadModel.items).thenReturn(listOf(uploadItem)) | ||||
|  | @ -356,7 +325,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetDepictions() { | ||||
|         `when`(depictModel.getDepictions("Q12")) | ||||
|  | @ -369,7 +337,6 @@ class UploadRepositoryUnitTest { | |||
|         method.invoke(repository, listOf("Q12")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testJoinIDs() { | ||||
|         val method: Method = UploadRepository::class.java.getDeclaredMethod( | ||||
|  | @ -380,7 +347,6 @@ class UploadRepositoryUnitTest { | |||
|         method.invoke(repository, listOf("Q12", "Q23")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `test joinIDs when depictIDs is null`() { | ||||
|         val method: Method = UploadRepository::class.java.getDeclaredMethod( | ||||
|  | @ -391,7 +357,6 @@ class UploadRepositoryUnitTest { | |||
|         method.invoke(repository, null) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetSelectedExistingCategories() { | ||||
|         assertEquals( | ||||
|  | @ -400,7 +365,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSetSelectedExistingCategories() { | ||||
|         assertEquals( | ||||
|  | @ -409,7 +373,6 @@ class UploadRepositoryUnitTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testGetCategories() { | ||||
|         assertEquals( | ||||
|  |  | |||
|  | @ -16,7 +16,6 @@ import wikiBaseEntityValue | |||
| 
 | ||||
| class DepictedItemTest { | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `name and description get user language label`() { | ||||
|         val depictedItem = | ||||
|  | @ -25,7 +24,6 @@ class DepictedItemTest { | |||
|         Assert.assertEquals(depictedItem.description, "description") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `name and descriptions get first language label if user language not present`() { | ||||
|         val depictedItem = DepictedItem(entity(mapOf("" to "label"), mapOf("" to "description"))) | ||||
|  | @ -33,7 +31,6 @@ class DepictedItemTest { | |||
|         Assert.assertEquals(depictedItem.description, "description") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `name and descriptions get empty if nothing present`() { | ||||
|         val depictedItem = DepictedItem(entity()) | ||||
|  | @ -41,19 +38,16 @@ class DepictedItemTest { | |||
|         Assert.assertEquals(depictedItem.description, "") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `image is empty with null statements`() { | ||||
|         Assert.assertEquals(DepictedItem(entity(statements = null)).imageUrl, null) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `image is empty with no image statement`() { | ||||
|         Assert.assertEquals(DepictedItem(entity()).imageUrl, null) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `image is empty with dataValue not of ValueString type`() { | ||||
|         Assert.assertEquals( | ||||
|  | @ -68,7 +62,6 @@ class DepictedItemTest { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `image is not empty with dataValue of ValueString type`() { | ||||
|         Assert.assertEquals( | ||||
|  | @ -84,7 +77,6 @@ class DepictedItemTest { | |||
|             "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/_example_/70px-_example_") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `instancesOf maps EntityIds to ids`() { | ||||
|         Assert.assertEquals( | ||||
|  | @ -102,13 +94,11 @@ class DepictedItemTest { | |||
|             listOf("1", "2")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `instancesOf is empty with no values`() { | ||||
|         Assert.assertEquals(DepictedItem(entity()).instanceOfs, emptyList<String>()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `commonsCategory maps ValueString to strings`() { | ||||
|         Assert.assertEquals( | ||||
|  | @ -125,25 +115,21 @@ class DepictedItemTest { | |||
|             listOf("1", "2")) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `commonsCategory is empty with no values`() { | ||||
|         Assert.assertEquals(DepictedItem(entity()).commonsCategories, emptyList<String>()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `isSelected is false at creation`() { | ||||
|         Assert.assertEquals(DepictedItem(entity()).isSelected, false) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `id is entityId`() { | ||||
|         Assert.assertEquals(DepictedItem(entity(id = "1")).id, "1") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun `place constructor uses place name and longDescription`() { | ||||
|         val depictedItem = DepictedItem(entity(), place(name = "1", longDescription = "2")) | ||||
|  |  | |||
|  | @ -19,7 +19,6 @@ class FileUtilsTest { | |||
|         assertEquals(false, file.exists()) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testSHA1() { | ||||
|         val fileUtilsWrapper = FileUtilsWrapper(mock()) | ||||
|  |  | |||
|  | @ -29,7 +29,6 @@ class WikiBaseClientUnitTest { | |||
|         whenever(csrfTokenClient.getTokenBlocking()).thenReturn("test") | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testPostEditEntity() { | ||||
|         val response = mock<MwPostResponse>() | ||||
|  | @ -42,7 +41,6 @@ class WikiBaseClientUnitTest { | |||
|         assertTrue(result) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testPostEditEntityByFilename() { | ||||
|         val response = mock<MwPostResponse>() | ||||
|  | @ -55,7 +53,6 @@ class WikiBaseClientUnitTest { | |||
|         assertTrue(result) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun getFileEntityId() { | ||||
|         val upload = UploadResult("result", "key", 0, "Example.jpg") | ||||
|  | @ -74,7 +71,6 @@ class WikiBaseClientUnitTest { | |||
|         assertEquals(123L, result) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun addLabelstoWikidata() { | ||||
|         val mwPostResponse = mock<MwPostResponse>() | ||||
|  |  | |||
|  | @ -42,7 +42,6 @@ class WikidataClientTest { | |||
|             .thenReturn(Observable.just(mwQueryResponse)) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun addEditTag() { | ||||
|         val response = mock(WbCreateClaimResponse::class.java) | ||||
|  |  | |||
|  | @ -46,14 +46,12 @@ class WikidataEditServiceTest { | |||
|         MockitoAnnotations.openMocks(this) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun noClaimsWhenEntityIdIsNull() { | ||||
|         wikidataEditService.createClaim(mock(), "Test.jpg", hashMapOf()) | ||||
|         verifyNoInteractions(wikidataClient) | ||||
|     } | ||||
| 
 | ||||
|     @Ignore | ||||
|     @Test | ||||
|     fun testUpdateDepictsProperty() { | ||||
|         whenever(wikibaseClient.postEditEntityByFilename("Test.jpg", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kanahia
						Kanahia