# Path: siptools/utils.py
# def read_md_references(workspace, ref_file):
#     """Read all the MD IDs as a dictionary.
# 
#     :workspace: path to workspace directory
#     :ref_file: Metadata reference file
#     :returns: A dict of references or None if reference file doesn't
#               exist
#     """
#     reference_file = os.path.join(workspace, ref_file)
# 
#     if os.path.isfile(reference_file):
#         references = {}
#         with open(reference_file) as in_file:
#             for line in in_file:
#                 references.update(json.loads(line))
#         return references
#     return None


import os
import json
import shutil
import sys
import pytest
import siptools.scripts.create_mix as create_mix
from siptools.utils import read_md_references
    images present.
    """
    with pytest.raises(ValueError):
        create_mix.create_mix_metadata("tests/data/images/multiple_images.tif")


@pytest.mark.parametrize("file_, base_path", [
    ('tests/data/images/tiff1.tif', ''),
    ('./tests/data/images/tiff1.tif', ''),
    ('images/tiff1.tif', 'tests/data'),
    ('./images/tiff1.tif', './tests/data'),
    ('data/images/tiff1.tif', 'absolute')
])
def test_paths(testpath, file_, base_path, run_cli):
    """ Test the following path arguments:
    (1) Path without base_path
    (2) Path without base bath, but with './'
    (3) Path with base path
    (4) Path with base path and with './'
    (5) Absolute base path
    """
    if 'absolute' in base_path:
        base_path = os.path.join(os.getcwd(), 'tests')

    if base_path != '':
        run_cli(create_mix.main, [
            '--workspace', testpath, '--base_path', base_path, file_])
    else:
        run_cli(create_mix.main, ['--workspace', testpath, file_])


# Path: siptools/utils.py
# def read_md_references(workspace, ref_file):
#     """Read all the MD IDs as a dictionary.
# 
#     :workspace: path to workspace directory
#     :ref_file: Metadata reference file
#     :returns: A dict of references or None if reference file doesn't
#               exist
#     """
#     reference_file = os.path.join(workspace, ref_file)
# 
#     if os.path.isfile(reference_file):
#         references = {}
#         with open(reference_file) as in_file:
#             for line in in_file:
#                 references.update(json.loads(line))
#         return references
#     return None


# Path: tests/scripts/test_create_mix.py
import os
import json
import shutil
import sys
import pytest
import siptools.scripts.create_mix as create_mix
from siptools.utils import read_md_references

    images present.
    """
    with pytest.raises(ValueError):
        create_mix.create_mix_metadata("tests/data/images/multiple_images.tif")


@pytest.mark.parametrize("file_, base_path", [
    ('tests/data/images/tiff1.tif', ''),
    ('./tests/data/images/tiff1.tif', ''),
    ('images/tiff1.tif', 'tests/data'),
    ('./images/tiff1.tif', './tests/data'),
    ('data/images/tiff1.tif', 'absolute')
])
def test_paths(testpath, file_, base_path, run_cli):
    """ Test the following path arguments:
    (1) Path without base_path
    (2) Path without base bath, but with './'
    (3) Path with base path
    (4) Path with base path and with './'
    (5) Absolute base path
    """
    if 'absolute' in base_path:
        base_path = os.path.join(os.getcwd(), 'tests')

    if base_path != '':
        run_cli(create_mix.main, [
            '--workspace', testpath, '--base_path', base_path, file_])
    else:
        run_cli(create_mix.main, ['--workspace', testpath, file_])


    refs = read_md_references(testpath, 'create-mix-md-references.jsonl')