# Path: siptools/utils.py
# def fsencode_path(filename):
#     """
#     Encode Unicode filenames using the file system encoding.
# 
#     :filename: File path to encode
#     :returns: Encoded path
#     :raises: TypeError if wrong type given
#     """
#     if isinstance(filename, six.text_type):
#         return filename.encode(encoding=sys.getfilesystemencoding())
#     if isinstance(filename, six.binary_type):
#         return filename
# 
#     raise TypeError("Value is not a (byte) string")
# 
# 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.path
import json
import shutil
import pytest
import lxml.etree as ET
import siptools.scripts.create_videomd as create_videomd
from siptools.utils import fsencode_path, read_md_references

    path = "/vmd:VIDEOMD/vmd:fileData/vmd:duration"
    assert videomd.xpath(path, namespaces=NAMESPACES)[0].text == 'PT50S'


@pytest.mark.parametrize("file_, base_path", [
    ('tests/data/video/valid_1.m1v', ''),
    ('./tests/data/video/valid_1.m1v', ''),
    ('video/valid_1.m1v', 'tests/data'),
    ('./video/valid_1.m1v', './tests/data'),
    ('data/video/valid_1.m1v', '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_videomd.main, [
            '--workspace', testpath, '--base_path', base_path, file_])
    else:
        run_cli(create_videomd.main, [
            '--workspace', testpath, file_])


# Path: siptools/utils.py
# def fsencode_path(filename):
#     """
#     Encode Unicode filenames using the file system encoding.
# 
#     :filename: File path to encode
#     :returns: Encoded path
#     :raises: TypeError if wrong type given
#     """
#     if isinstance(filename, six.text_type):
#         return filename.encode(encoding=sys.getfilesystemencoding())
#     if isinstance(filename, six.binary_type):
#         return filename
# 
#     raise TypeError("Value is not a (byte) string")
# 
# 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_videomd.py
import os.path
import json
import shutil
import pytest
import lxml.etree as ET
import siptools.scripts.create_videomd as create_videomd
from siptools.utils import fsencode_path, read_md_references


    path = "/vmd:VIDEOMD/vmd:fileData/vmd:duration"
    assert videomd.xpath(path, namespaces=NAMESPACES)[0].text == 'PT50S'


@pytest.mark.parametrize("file_, base_path", [
    ('tests/data/video/valid_1.m1v', ''),
    ('./tests/data/video/valid_1.m1v', ''),
    ('video/valid_1.m1v', 'tests/data'),
    ('./video/valid_1.m1v', './tests/data'),
    ('data/video/valid_1.m1v', '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_videomd.main, [
            '--workspace', testpath, '--base_path', base_path, file_])
    else:
        run_cli(create_videomd.main, [
            '--workspace', testpath, file_])


    references = read_md_references(