Skip to content

Commit

Permalink
Delete-processed-tests (#3258)
Browse files Browse the repository at this point in the history
* Add tests

* format
  • Loading branch information
anna-parker authored Nov 20, 2024
1 parent c5dab17 commit a0a145e
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.hamcrest.Matchers.not
import org.junit.jupiter.api.Test
import org.loculus.backend.api.DataUseTerms
import org.loculus.backend.api.DataUseTermsChangeRequest
import org.loculus.backend.api.DeleteSequenceScope
import org.loculus.backend.api.Status
import org.loculus.backend.config.BackendSpringProperty
import org.loculus.backend.controller.DEFAULT_USER_NAME
Expand All @@ -26,6 +27,7 @@ import org.loculus.backend.controller.submission.SubmissionControllerClient
import org.loculus.backend.controller.submission.SubmissionConvenienceClient
import org.loculus.backend.controller.submission.SubmitFiles.DefaultFiles.NUMBER_OF_SEQUENCES
import org.loculus.backend.controller.withAuth
import org.loculus.backend.service.submission.SubmissionDatabaseService
import org.loculus.backend.service.submission.UseNewerProcessingPipelineVersionTask
import org.loculus.backend.utils.DateProvider
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -40,6 +42,7 @@ class DeleteAllSequenceDataEndpointTest(
@Autowired private val submissionControllerClient: SubmissionControllerClient,
@Autowired private val dataUseTermsClient: DataUseTermsControllerClient,
@Autowired private val useNewerProcessingPipelineVersionTask: UseNewerProcessingPipelineVersionTask,
@Autowired val submissionDatabaseService: SubmissionDatabaseService,
@Autowired private val mockMvc: MockMvc,
) {
@Test
Expand Down Expand Up @@ -142,6 +145,27 @@ class DeleteAllSequenceDataEndpointTest(
assertThat(extractedDataAfterDeletion, hasSize(NUMBER_OF_SEQUENCES))
}

@Test
fun `GIVEN preprocessing pipeline version 1 WHEN some sequences deleted THEN can update pipeline to version 2`() {
val accessionVersions = submissionConvenienceClient.prepareDataTo(Status.PROCESSED)

val accessionFirst = accessionVersions.first()

submissionControllerClient.deleteSequenceEntries(
scope = DeleteSequenceScope.ALL,
accessionVersionsFilter = listOf(accessionFirst),
jwt = jwtForSuperUser,
)

val extractedDataVersion2 = submissionConvenienceClient.extractUnprocessedData(pipelineVersion = 2)
val processedDataVersion2 = extractedDataVersion2
.map { PreparedProcessedData.successfullyProcessed(accession = it.accession, version = it.version) }
submissionConvenienceClient.submitProcessedData(processedDataVersion2, pipelineVersion = 2)

val canUpdate = submissionDatabaseService.useNewerProcessingPipelineIfPossible()
assertThat("An update to v2 should be possible", canUpdate, `is`(2L))
}

@Test
fun `GIVEN I deleted all sequences WHEN submitting again THEN new sequences are present`() {
submissionConvenienceClient.prepareDataTo(Status.APPROVED_FOR_RELEASE)
Expand Down

0 comments on commit a0a145e

Please sign in to comment.