# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass


from hashlib import sha256
from onecodex.exceptions import OneCodexException
import pytest
import warnings
    assert df["totalige"].tolist() == [62.9, 91.5, 112.0]

    # tax_id coerced to string from integer
    df, fields = samples._metadata_fetch([1279])
    assert fields[1279] == "Staphylococcus (1279)"
    assert df["Staphylococcus (1279)"].round(10).tolist() == [4.0172e-06, 4.89491e-05, 2.0881e-06]

    # tax_name, should take lowest matching tax_id, be case-insensitive, and report within-rank abundance
    df, fields = samples._metadata_fetch(["bacteroid"])
    assert fields["bacteroid"] == "Bacteroidaceae (815)"
    assert df["Bacteroidaceae (815)"].round(10).tolist() == [
        0.344903898,
        0.1656058794,
        0.7776093433,
    ]

    # label is a metadata field or callable
    df, fields = samples._metadata_fetch(["Label"], label="eggs")
    assert df["Label"].tolist() == ["True (1)", "True (2)", "True (3)"]

    df, fields = samples._metadata_fetch(["Label"], label=lambda x: str(x["eggs"]) + "_foo")
    assert df["Label"].tolist() == ["True_foo (1)", "True_foo (2)", "True_foo (3)"]

    # label must be a string or callable
    with pytest.raises(OneCodexException) as e:
        df, fields = samples._metadata_fetch(["Label"], label=False)
    assert "string or callable" in str(e.value)

    # label is a field not in the table
    with pytest.raises(OneCodexException) as e:

# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass


# Path: tests/test_analyses.py
from hashlib import sha256
from onecodex.exceptions import OneCodexException
import pytest
import warnings

    assert df["totalige"].tolist() == [62.9, 91.5, 112.0]

    # tax_id coerced to string from integer
    df, fields = samples._metadata_fetch([1279])
    assert fields[1279] == "Staphylococcus (1279)"
    assert df["Staphylococcus (1279)"].round(10).tolist() == [4.0172e-06, 4.89491e-05, 2.0881e-06]

    # tax_name, should take lowest matching tax_id, be case-insensitive, and report within-rank abundance
    df, fields = samples._metadata_fetch(["bacteroid"])
    assert fields["bacteroid"] == "Bacteroidaceae (815)"
    assert df["Bacteroidaceae (815)"].round(10).tolist() == [
        0.344903898,
        0.1656058794,
        0.7776093433,
    ]

    # label is a metadata field or callable
    df, fields = samples._metadata_fetch(["Label"], label="eggs")
    assert df["Label"].tolist() == ["True (1)", "True (2)", "True (3)"]

    df, fields = samples._metadata_fetch(["Label"], label=lambda x: str(x["eggs"]) + "_foo")
    assert df["Label"].tolist() == ["True_foo (1)", "True_foo (2)", "True_foo (3)"]

    # label must be a string or callable
    with pytest.raises(OneCodexException) as e:
        df, fields = samples._metadata_fetch(["Label"], label=False)
    assert "string or callable" in str(e.value)

    # label is a field not in the table
    with pytest.raises(OneCodexException) as e:

        df, fields = samples._metadata_fetch(["Label"], label="does_not_exist")