def launch(self, **kwargs): result = Datatype2() if 'param_5' in kwargs: result.row1 = str(kwargs['param_5']) if 'param_6' in kwargs: result.row2 = str(kwargs['param_6']) result.storage_path = self.storage_path result.string_data = ["data"] return result
def launch(self, test): result = Datatype2() result.row1 = 'param_5' result.row2 = 'param_6' result.storage_path = self.storage_path res_array = [] for _ in range(int(test)): res_array.append("data") result.string_data = res_array return result
def test_get_filtered_datatypes(self): """ Test the filter function when retrieving dataTypes. """ #Create some test operations start_dates = [datetime.now(), datetime.strptime("08-06-2010", "%m-%d-%Y"), datetime.strptime("07-21-2010", "%m-%d-%Y"), datetime.strptime("05-06-2010", "%m-%d-%Y"), datetime.strptime("07-21-2011", "%m-%d-%Y")] end_dates = [datetime.now(), datetime.strptime("08-12-2010", "%m-%d-%Y"), datetime.strptime("08-12-2010", "%m-%d-%Y"), datetime.strptime("08-12-2011", "%m-%d-%Y"), datetime.strptime("08-12-2011", "%m-%d-%Y")] for i in range(5): operation = model.Operation(self.test_user.id, self.test_project.id, self.algo_inst.id, 'test params', status="FINISHED", start_date=start_dates[i], completion_date=end_dates[i]) operation = dao.store_entity(operation) storage_path = FilesHelper().get_project_folder(self.test_project, str(operation.id)) if i < 4: datatype_inst = Datatype1() datatype_inst.type = "Datatype1" datatype_inst.subject = "John Doe" + str(i) datatype_inst.state = "RAW" datatype_inst.set_operation_id(operation.id) dao.store_entity(datatype_inst) else: for _ in range(2): datatype_inst = Datatype2() datatype_inst.storage_path = storage_path datatype_inst.type = "Datatype2" datatype_inst.subject = "John Doe" + str(i) datatype_inst.state = "RAW" datatype_inst.string_data = ["data"] datatype_inst.set_operation_id(operation.id) dao.store_entity(datatype_inst) returned_data = self.flow_service.get_available_datatypes(self.test_project.id, "tvb_test.datatypes.datatype1.Datatype1") for row in returned_data: if row[1] != 'Datatype1': self.fail("Some invalid data was returned!") self.assertEqual(4, len(returned_data), "Invalid length of result") filter_op = FilterChain(fields=[FilterChain.datatype + ".state", FilterChain.operation + ".start_date"], values=["RAW", datetime.strptime("08-01-2010", "%m-%d-%Y")], operations=["==", ">"]) returned_data = self.flow_service.get_available_datatypes(self.test_project.id, "tvb_test.datatypes.datatype1.Datatype1", filter_op) returned_subjects = [one_data[3] for one_data in returned_data] if "John Doe0" not in returned_subjects or "John Doe1" not in returned_subjects or len(returned_subjects) != 2: self.fail("DataTypes were not filtered properly!")
def create_datatype_with_storage(self, subject=USER_FULL_NAME, state=DATATYPE_STATE, data=DATATYPE_DATA, operation_id=None): """ This method creates and stores a data type which imply storage on the file system. """ datatype_inst = Datatype2() self._fill_datatype(datatype_inst, subject, state, operation_id) datatype_inst.string_data = data return self._store_datatype(datatype_inst, operation_id)
def launch(self, test): """ Mimics launching with a lot of memory usage :param test: should be a very large integer; the larger, the more memory is used :returns: a `Datatype2` object, with big string_data """ result = Datatype2() result.row1 = 'param_5' result.row2 = 'param_6' result.storage_path = self.storage_path res_array = [] for _ in range(int(test)): res_array.append("data") result.string_data = res_array return result