diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/attachments-test/attachments-test-handler.py b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/attachments-test/attachments-test-handler.py index 7c082a5777302102bfeeeaf130e71a1fe0b99a2d..2355e6bb0ee92855ba5ce0c1aefdc9ccf1e4a8f9 100644 --- a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/attachments-test/attachments-test-handler.py +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/attachments-test/attachments-test-handler.py @@ -1,30 +1,6 @@ from java.lang import String from org.apache.commons.io import IOUtils -def listProjectAttachments(transaction, projectIdentifier): - project = transaction.getProject(projectIdentifier) - return transaction.listProjectAttachments(project); - -def listExperimentAttachments(transaction, experimentIdentifier): - experiment = transaction.getExperiment(experimentIdentifier) - return transaction.listExperimentAttachments(experiment); - -def listSampleAttachments(transaction, sampleIdentifier): - sample = transaction.getSample(sampleIdentifier) - return transaction.listSampleAttachments(sample); - -def getProjectAttachmentContent(transaction, projectIdentifier, name, version): - project = transaction.getProject(projectIdentifier) - return transaction.getProjectAttachmentContent(project, name, version) - -def getExperimentAttachmentContent(transaction, experimentIdentifier, name, version): - experiment = transaction.getExperiment(experimentIdentifier) - return transaction.getExperimentAttachmentContent(experiment, name, version) - -def getSampleAttachmentContent(transaction, sampleIdentifier, name, version): - sample = transaction.getSample(sampleIdentifier) - return transaction.getSampleAttachmentContent(sample, name, version) - def assertAttachmentContentContains(actualContentStream, expectedContentString): if(expectedContentString == None and actualContentStream <> None): actualContentString = String(IOUtils.toByteArray(actualContentStream)); @@ -55,72 +31,72 @@ def assertAttachment(attachment, fileName, title, description, version): raise Exception('Attachment version should be: "' + str(version) + '" but was: "' + str(attachment.getVersion()) + '"') def testProjectWithoutAttachments(transaction): - PROJECT_IDENTIFIER = "/CISD/DEFAULT"; + project = transaction.getProject("/CISD/DEFAULT"); - attachments = listProjectAttachments(transaction, PROJECT_IDENTIFIER) + attachments = transaction.listProjectAttachments(project) assertAttachmentCount(attachments, 0) - content = getProjectAttachmentContent(transaction, PROJECT_IDENTIFIER, "not-existing-attachment", None); + content = transaction.getProjectAttachmentContent(project, "not-existing-attachment", None); assertAttachmentContentContains(content, None); def testProjectWithAttachments(transaction): - PROJECT_IDENTIFIER = "/CISD/NEMO"; + project = transaction.getProject("/CISD/NEMO"); - attachments = listProjectAttachments(transaction, PROJECT_IDENTIFIER) + attachments = transaction.listProjectAttachments(project) assertAttachmentCount(attachments, 1) assertAttachment(attachments[0], "projectDescription.txt", "The Project", "All about it.", 1); - content = getProjectAttachmentContent(transaction, PROJECT_IDENTIFIER, "projectDescription.txt", None); + content = transaction.getProjectAttachmentContent(project, "projectDescription.txt", None); assertAttachmentContentContains(content, "3VCP1"); - content2 = getProjectAttachmentContent(transaction, PROJECT_IDENTIFIER, "not-existing-attachment", None); + content2 = transaction.getProjectAttachmentContent(project, "not-existing-attachment", None); assertAttachmentContentContains(content2, None); def testExperimentWithoutAttachments(transaction): - EXPERIMENT_IDENTIFIER = "/CISD/NEMO/EXP10"; + experiment = transaction.getExperiment("/CISD/NEMO/EXP10"); - attachments = listExperimentAttachments(transaction, EXPERIMENT_IDENTIFIER) + attachments = transaction.listExperimentAttachments(experiment) assertAttachmentCount(attachments, 0) - content = getExperimentAttachmentContent(transaction, EXPERIMENT_IDENTIFIER, "not-existing-attachment", 2); + content = transaction.getExperimentAttachmentContent(experiment, "not-existing-attachment", 2); assertAttachmentContentContains(content, None); def testExperimentWithAttachments(transaction): - EXPERIMENT_IDENTIFIER = "/CISD/NEMO/EXP1"; + experiment = transaction.getExperiment("/CISD/NEMO/EXP1"); - attachments = listExperimentAttachments(transaction, EXPERIMENT_IDENTIFIER) + attachments = transaction.listExperimentAttachments(experiment) assertAttachmentCount(attachments, 4) assertAttachment(attachments[0], "exampleExperiments.txt", None, None, 1) assertAttachment(attachments[1], "exampleExperiments.txt", None, None, 2) assertAttachment(attachments[2], "exampleExperiments.txt", None, None, 3) assertAttachment(attachments[3], "exampleExperiments.txt", None, None, 4) - content = getExperimentAttachmentContent(transaction, EXPERIMENT_IDENTIFIER, "exampleExperiments.txt", 2); + content = transaction.getExperimentAttachmentContent(experiment, "exampleExperiments.txt", 2); assertAttachmentContentContains(content, "koko"); - content2 = getExperimentAttachmentContent(transaction, EXPERIMENT_IDENTIFIER, "not-existing-attachment", 2); + content2 = transaction.getExperimentAttachmentContent(experiment, "not-existing-attachment", 2); assertAttachmentContentContains(content2, None); def testSampleWithoutAttachments(transaction): - SAMPLE_IDENTIFIER = "/CISD/3VCP5"; + sample = transaction.getSample("/CISD/3VCP5"); - attachments = listSampleAttachments(transaction, SAMPLE_IDENTIFIER) + attachments = transaction.listSampleAttachments(sample) assertAttachmentCount(attachments, 0) - content = getSampleAttachmentContent(transaction, SAMPLE_IDENTIFIER, "not-existing-attachment", None); + content = transaction.getSampleAttachmentContent(sample, "not-existing-attachment", None); assertAttachmentContentContains(content, None); def testSampleWithAttachments(transaction): - SAMPLE_IDENTIFIER = "/CISD/3VCP6"; + sample = transaction.getSample("/CISD/3VCP6"); - attachments = listSampleAttachments(transaction, SAMPLE_IDENTIFIER) + attachments = transaction.listSampleAttachments(sample) assertAttachmentCount(attachments, 1) assertAttachment(attachments[0], "sampleHistory.txt", None, None, 1) - content = getSampleAttachmentContent(transaction, SAMPLE_IDENTIFIER, "sampleHistory.txt", None); + content = transaction.getSampleAttachmentContent(sample, "sampleHistory.txt", None); assertAttachmentContentContains(content, "kot") - content2 = getSampleAttachmentContent(transaction, SAMPLE_IDENTIFIER, "not-existing-attachment", None); + content2 = transaction.getSampleAttachmentContent(sample, "not-existing-attachment", None); assertAttachmentContentContains(content2, None); def process(transaction): diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/AttachmentsDropboxTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/AttachmentsDropboxTest.java index 6ae429d37c8526342c3f3cb84f7122e0fb885d13..f746108c1e9993e54cf46f2b9dcf517c5313130f 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/AttachmentsDropboxTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/AttachmentsDropboxTest.java @@ -109,4 +109,10 @@ public class AttachmentsDropboxTest extends SystemTestCase return new File(rootDir, "incoming-attachments-test"); } + @Override + protected int dataSetImportWaitDurationInSeconds() + { + return 120; + } + }