# Path: vcfpy/reader.py
# class Reader:
#     def from_stream(
#         klass, stream, path=None, tabix_path=None, record_checks=None, parsed_samples=None
#     ):
#     def from_path(klass, path, tabix_path=None, record_checks=None, parsed_samples=None):
#     def __init__(self, stream, path=None, tabix_path=None, record_checks=None, parsed_samples=None):
#     def fetch(self, chrom_or_region, begin=None, end=None):
#     def close(self):
#     def __enter__(self):
#     def __exit__(self, type_, value, traceback):
#     def __iter__(self):
#     def __next__(self):


import os
from vcfpy import reader

def test_fetch_two_records_values():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")
    r = reader.Reader.from_path(path)

    records = [vcf_rec for vcf_rec in r.fetch("20", 1110697, 1234568)]

    assert len(records) == 2

    assert records[0].CHROM == "20"
    assert records[0].POS == 1230237

    assert records[1].CHROM == "20"
    assert records[1].POS == 1234567


# Test fetch with samtools region ---------------------------------------------


def test_fetch_no_records_region():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")
    r = reader.Reader.from_path(path)

    records = [vcf_rec for vcf_rec in r.fetch("20:1,110,699-1,230,236")]

    assert len(records) == 0


def test_fetch_one_record_region():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")

# Path: vcfpy/reader.py
# class Reader:
#     def from_stream(
#         klass, stream, path=None, tabix_path=None, record_checks=None, parsed_samples=None
#     ):
#     def from_path(klass, path, tabix_path=None, record_checks=None, parsed_samples=None):
#     def __init__(self, stream, path=None, tabix_path=None, record_checks=None, parsed_samples=None):
#     def fetch(self, chrom_or_region, begin=None, end=None):
#     def close(self):
#     def __enter__(self):
#     def __exit__(self, type_, value, traceback):
#     def __iter__(self):
#     def __next__(self):


# Path: tests/test_fetch.py
import os
from vcfpy import reader


def test_fetch_two_records_values():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")
    r = reader.Reader.from_path(path)

    records = [vcf_rec for vcf_rec in r.fetch("20", 1110697, 1234568)]

    assert len(records) == 2

    assert records[0].CHROM == "20"
    assert records[0].POS == 1230237

    assert records[1].CHROM == "20"
    assert records[1].POS == 1234567


# Test fetch with samtools region ---------------------------------------------


def test_fetch_no_records_region():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")
    r = reader.Reader.from_path(path)

    records = [vcf_rec for vcf_rec in r.fetch("20:1,110,699-1,230,236")]

    assert len(records) == 0


def test_fetch_one_record_region():
    path = os.path.join(os.path.dirname(__file__), "vcfs", "multi_contig.vcf.gz")

    r = reader.Reader.from_path(path)