def test_super_transform_called(self, mocker):
        """Test that BaseTransformer.transform called."""

        df = d.create_datediff_test_df()

        x = DateDifferenceTransformer(
            column_lower="a",
            column_upper="b",
            new_column_name="Y",
            units="Y",
            copy=True,
            verbose=False,
        )

        expected_call_args = {
            0: {
                "args": (d.create_datediff_test_df(), ),
                "kwargs": {}
            }
        }

        with h.assert_function_call(
                mocker,
                tubular.base.BaseTransformer,
                "transform",
                expected_call_args,
                return_value=d.create_datediff_test_df(),
        ):

            x.transform(df)
    def test_expected_output_nulls(self, df, expected):
        """Test that the output is expected from transform, when columns are nulls."""

        x = DateDifferenceTransformer(
            column_lower="a",
            column_upper="b",
            new_column_name="Y",
            units="Y",
            copy=True,
            verbose=False,
        )

        df_transformed = x.transform(df)

        h.assert_frame_equal_msg(
            actual=df_transformed,
            expected=expected,
            msg_tag=
            "Unexpected values in DateDifferenceTransformer.transform (nulls)",
        )
    def test_class_methods(self):
        """Test that DateDifferenceTransformer has fit and transform methods."""

        x = DateDifferenceTransformer(
            "column_lower",
            "column_upper",
        )

        h.test_object_method(obj=x,
                             expected_method="transform",
                             msg="transform")
    def test_column_2_type_error(self):
        """Test that an exception is raised if column_upper is not a str."""

        with pytest.raises(TypeError, match="column_upper must be a str"):

            DateDifferenceTransformer(
                column_lower="dummy_1",
                column_upper=123,
                new_column_name="dummy_3",
                units="Y",
                copy=True,
                verbose=False,
            )
    def test_expected_output_units_s(self, df, expected):
        """Test that the output is expected from transform, when units is s.

        This tests positive month gaps, negative month gaps, and missing values.

        """

        x = DateDifferenceTransformer(
            column_lower="a",
            column_upper="b",
            new_column_name="s",
            units="s",
            copy=True,
            verbose=False,
        )

        df_transformed = x.transform(df)

        h.assert_equal_dispatch(
            expected=expected,
            actual=df_transformed,
            msg="Unexpected values in DateDifferenceYearTransformer.transform",
        )
    def test_units_values_error(self):
        """Test that an exception is raised if the value of inits is not one of accepted_values_units."""

        with pytest.raises(
                ValueError,
                match=
                r"units must be one of \['Y', 'M', 'D', 'h', 'm', 's'\], got y",
        ):

            DateDifferenceTransformer(
                column_lower="dummy_1",
                column_upper="dummy_2",
                new_column_name="dummy_3",
                units="y",
                copy=True,
                verbose=False,
            )
    def test_inputs_set_to_attribute_name_not_set(self):
        """Test that the value passed for new_column_new_column_name and units are saved in attributes of the same new_column_name."""

        x = DateDifferenceTransformer(
            column_lower="dummy_1",
            column_upper="dummy_2",
            units="Y",
            copy=True,
            verbose=False,
        )

        h.test_object_attributes(
            obj=x,
            expected_attributes={
                "columns": ["dummy_1", "dummy_2"],
                "new_column_name": "dummy_2_dummy_1_datediff_Y",
                "units": "Y",
                "copy": True,
                "verbose": False,
            },
            msg="Attributes for DateDifferenceTransformer set in init",
        )
    def test_super_init_called(self, mocker):
        """Test that init calls BaseTransformer.init."""

        expected_call_args = {
            0: {
                "args": (),
                "kwargs": {
                    "columns": ["dummy_1", "dummy_2"],
                    "copy": True,
                    "verbose": False,
                },
            }
        }

        with h.assert_function_call(mocker, tubular.base.BaseTransformer,
                                    "__init__", expected_call_args):

            DateDifferenceTransformer(
                column_lower="dummy_1",
                column_upper="dummy_2",
                new_column_name="dummy_3",
                units="Y",
            )
    def test_inheritance(self):
        """Test that DateDifferenceTransformer inherits from BaseTransformer."""

        x = DateDifferenceTransformer("column_lower", "column_upper")

        h.assert_inheritance(x, tubular.base.BaseTransformer)