Exemplo n.º 1
0
import importlib

import pytest

from helpers import running_on_ci

# Skip all tests if rdkit not installed
pytestmark = pytest.mark.skipif(
    (importlib.util.find_spec("rdkit") is None) & ~running_on_ci(),
    reason="rdkit tests only required for CI",
)


@pytest.mark.parametrize("progressbar", [None, "terminal"])
@pytest.mark.chemistry
def test_smiles2mol(chemdf, progressbar):
    """Test each SMILES properly converted to Mol object."""
    from rdkit import Chem

    chemdf = chemdf.smiles2mol("smiles", "mol", progressbar)
    assert "mol" in chemdf.columns
    for elem in chemdf["mol"]:
        assert isinstance(elem, Chem.rdchem.Mol)
Exemplo n.º 2
0
def test_running_on_ci_local(monkeypatch):
    """Test running_on_ci run on local machine returns False."""
    monkeypatch.delenv("JANITOR_CI_MACHINE", raising=False)
    assert running_on_ci() is False
Exemplo n.º 3
0
import pytest
from pandas.testing import assert_frame_equal

from helpers import running_on_ci

if running_on_ci():
    import pyspark
else:
    pyspark = pytest.importorskip("pyspark")
import janitor.spark  # noqa: F401 isort:skip


@pytest.mark.spark_functions
def test_update_where_string(dataframe, spark_dataframe):
    """Test update_where and update with a string."""
    assert_frame_equal(
        spark_dataframe.update_where(
            conditions="""
            `decorated-elephant` = 1 AND `animals@#$%^` = 'rabbit'
            """,
            target_column_name="cities",
            target_val="Durham",
        ).toPandas(),
        dataframe.update_where(
            (dataframe["decorated-elephant"] == 1)
            & (dataframe["animals@#$%^"] == "rabbit"),
            "cities",
            "Durham",
        ),
    )
Exemplo n.º 4
0
def test_running_on_ci_ci(monkeypatch):
    """Test running_on_ci run on CI machine returns True."""
    monkeypatch.setenv("JANITOR_CI_MACHINE", "1")
    assert running_on_ci() is True