コード例 #1
0
    def test_transform_data_default_transformers(self):
        """transform_data with default transformers."""

        # Setup
        default_transformers = [
            'NumberTransformer', 'DTTransformer', 'CatTransformer'
        ]

        ht_mock = Mock()
        ht_mock.fit_transform.return_value = {'some': 'data'}

        # Run
        data_navigator_mock = Mock()
        data_navigator_mock.DEFAULT_TRANSFORMERS = default_transformers
        data_navigator_mock.ht = ht_mock

        result = DataNavigator.transform_data(data_navigator_mock, None)

        # Asserts
        expect = {'some': 'data'}
        expect_transformers = [
            'NumberTransformer', 'DTTransformer', 'CatTransformer'
        ]

        assert result == expect

        ht_mock.fit_transform.assert_called_once_with(
            transformer_list=expect_transformers)
コード例 #2
0
    def test_transform_data_with_transformers(self):
        """transform_data with transformers from parameters"""

        # Setup
        transformers = ['NumberTransformer', 'DTTransformer']

        ht_mock = Mock()
        ht_mock.fit_transform.return_value = {'some': 'data'}

        # Run
        data_navigator_mock = Mock()
        data_navigator_mock.ht = ht_mock

        result = DataNavigator.transform_data(data_navigator_mock,
                                              transformers=transformers)

        # Asserts
        expect = {'some': 'data'}
        expect_transformers = ['NumberTransformer', 'DTTransformer']

        assert result == expect

        ht_mock.fit_transform.assert_called_once_with(
            transformer_list=expect_transformers)