def validate(self): """Validate command input. Raises: ValidationError - if something is wrong with command parameters. """ if is_valid_uuid(self.project_id) is False: raise ValidationError("Project ID is not valid. Exiting.") if self.sample_ids: if not all(is_valid_uuid(s_id) for s_id in self.sample_ids): raise ValidationError("Not all sample IDs are valid. Exiting.")
def validate(self): """Validate command input. Raises: ValidationError - if something is wrong with command parameters. """ if is_valid_uuid(self.project_id) is False: raise ValidationError("Project ID is not valid. Exiting.")
def validate(self): """Validate command setup before execution. Raises: ValidationError - if something is wrong with command parameters. """ # fmt: off if self.destination and not self.destination.startswith(UPLOAD_PREFIX): self.echo_error( "Invalid destination path. Must start with '{}'".format( UPLOAD_PREFIX)) raise ValidationError("Bad configuration. Exiting.") # fmt: on if os.path.isfile( self.source) and not self.source.endswith(FASTQ_MAP_EXTENSION): raise ValidationError(f"Source input ('{self.source}') is a file, " f"but must be a directory or a map file " f"('*{FASTQ_MAP_EXTENSION}'). Exiting.") if not self.fastqs and not self.fastqs_map: self.echo_error("No FASTQ files found in the path. " "Only following files are accepted: {}".format( FASTQ_EXTENSIONS)) raise ValidationError("Bad configuration. Exiting.") if self.output and not self.project_id: raise ValidationError( "--output cannot be used without --run-project-id") if self.metadata and not self.project_id: raise ValidationError( "--metadata cannot be used without --run-project-id") if self.project_id and is_valid_uuid(self.project_id) is False: raise ValidationError("--run-project-id is not valid. Exiting.") # validate metadata json if self.metadata and is_valid_json(self.metadata) is False: raise ValidationError("--metadata is not valid JSON. Exiting.")
def test_is_valid_uuid__is_not_valid__text(): """Test that random word is not a valid UUID""" assert is_valid_uuid("foo") is False
def test_is_valid_uuid__is_not_valid__too_short(): """Test that UUID with missing chars is not a valid UUID""" assert is_valid_uuid("11111111-1111-1111-1111-1") is False
def test_is_valid_uuid__is_not_valid__too_long(): """Test that UUID with extra chars is not a valid UUID""" assert is_valid_uuid("11111111-1111-1111-1111-11111111111122") is False
def test_is_valid_uuid__is_valid(): """Test that a UUID is a valid UUID""" assert is_valid_uuid("11111111-1111-1111-1111-111111111111")