@Test
@ExtendWith({ RepositoryManagementTestExecutionListener.class,

              ArtifactManagementTestExecutionListener.class })
public void testUploadPackage(@PypiTestRepository(repositoryId = REPOSITORY_RELEASES, storageId = REPOSITORY_STORAGE) Repository repository,
                              @PypiTestArtifact(id = "hello_world_pypi", versions = "1.3") Path packagePath)
{
    final String storageId = repository.getStorage().getId();
    final String repositoryId = repository.getId();
    String url = getContextBaseUrl() + "/storages/{storageId}/{repositoryId}";
    PypiArtifactCoordinates coordinates = new PypiArtifactCoordinates("hello_world_pypi",
                                                                      "1.3",
                                                                      null,
                                                                      "py3",
                                                                      "none",
                                                                      "any",
                                                                      "whl");
    RepositoryPath repositoryPath = repositoryPathResolver.resolve(repository, coordinates);
    assertThat(Files.exists(repositoryPath)).isFalse();
    
    // Upload with Invalid action
    mockMvc.contentType(MediaType.MULTIPART_FORM_DATA_VALUE)
           .multiPart("filetype", "sdist")
           .multiPart(":action", "File_Upload")
           .multiPart("name", "hello-world-pipy")
           .multiPart("metadata_version", "1.0")
           .multiPart("content", packagePath.toFile())
           .when()
           .post(url, storageId, repositoryId)
           .then()
           .log()
           .all()
           .statusCode(HttpStatus.BAD_REQUEST.value())
           .contentType(ContentType.TEXT);
    // Upload with Invalid filetype
    mockMvc.contentType(MediaType.MULTIPART_FORM_DATA_VALUE)
           .multiPart("filetype", "wheel")
           .multiPart(":action", "file_upload")
           .multiPart("name", "hello-world-pipy")
           .multiPart("metadata_version", "1.0")
           .multiPart("content", packagePath.toFile())
           .when()
           .post(url, storageId, repositoryId)
           .then()
           .log()
           .all()
           .statusCode(HttpStatus.BAD_REQUEST.value())
           .contentType(ContentType.TEXT);
    // Valid pypi package upload
    mockMvc.contentType(MediaType.MULTIPART_FORM_DATA_VALUE)
           .multiPart("filetype", "sdist")
           .multiPart(":action", "file_upload")
           .multiPart("name", "hello-world-pipy")
           .multiPart("metadata_version", "1.0")
           .multiPart("content", packagePath.toFile())
           .when()
           .post(url, storageId, repositoryId)
           .then()
           .log()
           .all()
           .statusCode(HttpStatus.OK.value())
           .contentType(ContentType.TEXT)
           .body(Matchers.containsString("The artifact was deployed successfully."));
    
    repositoryPath = repositoryPathResolver.resolve(repository, coordinates);
    assertThat(Files.exists(repositoryPath)).isTrue();
}