コード例 #1
0
def test_is_spring_decompression_possible_no_fastq(
        crunchy_config_dict: dict, compression_object: CompressionData,
        caplog):
    """Test if decompression is possible when there are no FASTQ files

    The function should return true since there are no FASTQ files
    """
    caplog.set_level(logging.DEBUG)
    # GIVEN a crunchy-api
    crunchy_api = CrunchyAPI(crunchy_config_dict)
    # GIVEN a existing SPRING file
    compression_object.spring_path.touch()
    assert compression_object.spring_path.exists()
    # GIVEN that there are no fastq files
    compression_object.fastq_first.unlink()
    compression_object.fastq_second.unlink()
    assert not compression_object.fastq_first.exists()
    assert not compression_object.fastq_second.exists()

    # WHEN checking if SPRING compression is done
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be True since there are no fastq files
    assert result is True
    # THEN assert the correct information is communicated
    assert "Decompression is possible" in caplog.text
コード例 #2
0
def test_is_spring_decompression_possible(crunchy_config_dict,
                                          compression_object,
                                          spring_metadata_file, caplog):
    """Test if SPRING decompression is possible

    The function should return True since there is a SPRING file and no FASTQ files
    """
    caplog.set_level(logging.DEBUG)
    # GIVEN a crunchy-api
    crunchy_api = CrunchyAPI(crunchy_config_dict)
    # GIVEN a existing SPRING file
    compression_object.spring_path.touch()
    # GIVEN that the FASTQ files does not exist
    compression_object.fastq_first.unlink()
    compression_object.fastq_second.unlink()
    assert not compression_object.fastq_first.exists()
    assert not compression_object.fastq_second.exists()

    # WHEN checking if SPRING decompression is done
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be True since decompression is possible
    assert result is True
    # THEN assert that it was communicated that compression is pending
    assert "Decompression is possible" in caplog.text
コード例 #3
0
def test_is_spring_decompression_possible(crunchy_config_dict,
                                          compression_object,
                                          spring_metadata_file):
    """Test if SPRING decompression is possible when decompression is already done

    The function should return False since decompression is already done
    """
    # GIVEN a crunchy-api
    crunchy_api = CrunchyAPI(crunchy_config_dict)
    # GIVEN that the FASTQ paths exists
    compression_object.fastq_first.touch()
    compression_object.fastq_second.touch()
    # GIVEN a existing SPRING file
    compression_object.spring_path.touch()

    # GIVEN a existing flag file
    # GIVEN that the files have an updated tag
    old_date = "2019-01-01"
    with open(spring_metadata_file, "r") as infile:
        content = json.load(infile)
    # GIVEN that the files where updated more than three weeks ago
    for file_info in content:
        file_info["updated"] = old_date
    with open(spring_metadata_file, "w") as outfile:
        outfile.write(json.dumps(content))

    # WHEN checking if SPRING decompression is done
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be False since decompression is already done
    assert result is False
コード例 #4
0
def test_is_spring_decompression_possible_no_spring(
        crunchy_config_dict: dict, compression_object: CompressionData,
        caplog):
    """Test if decompression is possible when there are no SPRING archive

    The function should return False since there is no SPRING archive
    """
    caplog.set_level(logging.DEBUG)
    # GIVEN a crunchy-api, and FASTQ paths
    crunchy_api = CrunchyAPI(crunchy_config_dict)

    # WHEN checking if SPRING compression is done
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be False since there is no SPRING archive
    assert result is False
    # THEN assert the correct information is communicated
    assert "No SPRING file found" in caplog.text
コード例 #5
0
def test_is_spring_decompression_possible_decompression_pending(
        crunchy_config_dict, compression_object, spring_metadata_file, caplog):
    """Test if SPRING decompression is possible when decompression is pending

    The function should return False since decompression is pending
    """
    caplog.set_level(logging.DEBUG)
    # GIVEN a crunchy-api
    crunchy_api = CrunchyAPI(crunchy_config_dict)
    # GIVEN a existing pending file
    compression_object.pending_path.touch()

    # WHEN checking if SPRING decompression is done
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be False since decompression is pending
    assert result is False
    # THEN assert that it was communicated that compression is pending
    assert "decompression is pending" in caplog.text
コード例 #6
0
def test_is_spring_decompression_possible_fastq(
        crunchy_config_dict: dict, compression_object: CompressionData,
        caplog):
    """Test if decompression is possible when there are existing FASTQ files

    The function should return False since there are decompressed FASTQ files
    """
    caplog.set_level(logging.DEBUG)
    # GIVEN a crunchy-api, and FASTQ paths
    crunchy_api = CrunchyAPI(crunchy_config_dict)
    # GIVEN a existing SPRING file
    compression_object.spring_path.touch()
    # GIVEN that the FASTQ files exists
    compression_object.fastq_first.touch()
    compression_object.fastq_second.touch()

    # WHEN checking if SPRING decompression is possible
    result = crunchy_api.is_spring_decompression_possible(compression_object)

    # THEN result should be False since the FASTQ files already exists
    assert result is False
    # THEN assert the correct information is communicated
    assert "FASTQ files already exists" in caplog.text