Ejemplo n.º 1
0
    def test_super_transform_called(self, mocker):
        """Test that BaseTransformer.transform called."""

        df = d.create_date_test_df()

        x = DateDiffLeapYearTransformer(column_lower="a",
                                        column_upper="b",
                                        new_column_name="c",
                                        drop_cols=True)

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

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

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

        x = DateDiffLeapYearTransformer(column_lower="a",
                                        column_upper="b",
                                        new_column_name="c",
                                        drop_cols=False)

        df_transformed = x.transform(df)

        h.assert_frame_equal_msg(
            actual=df_transformed,
            expected=expected,
            msg_tag=
            "Unexpected values in DateDiffLeapYearTransformer.transform (nulls)",
        )
Ejemplo n.º 3
0
    def test_expected_output_drop_cols_false(self, df, expected):
        """Test that the output is expected from transform, when drop_cols is False.

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

        """

        x = DateDiffLeapYearTransformer(column_lower="a",
                                        column_upper="b",
                                        new_column_name="c",
                                        drop_cols=False)

        df_transformed = x.transform(df)

        h.assert_frame_equal_msg(
            actual=df_transformed,
            expected=expected,
            msg_tag=
            "Unexpected values in DateDiffLeapYearTransformer.transform (without drop_cols)",
        )