Esempio n. 1
0
    def test_build_transform_command(self):
        """Tests the function that generates transform executable command"""
        # Should return empty string if config file exists but no transformation
        transform_config = '{}/resources/transform-config-empty.json'.format(
            os.path.dirname(__file__)
        )
        transform_bin = '/bin/transform_field.py'

        transform = commands.TransformParams(
            config=transform_config,
            bin=transform_bin,
            python_bin='/bin/python',
            tap_id='my_tap',
            target_id='my_target',
        )
        # profiling disabled
        command = commands.build_transformation_command(
            transform=transform, profiling_mode=False, profiling_dir=None
        )
        assert command is None

        # profiling enabled
        command = commands.build_transformation_command(
            transform=transform, profiling_mode=True, profiling_dir='./profiling'
        )
        assert command is None

        # Should return a input piped command with an executable transform command
        transform_config = '{}/resources/transform-config.json'.format(
            os.path.dirname(__file__)
        )

        transform = commands.TransformParams(
            config=transform_config,
            bin=transform_bin,
            python_bin='/bin/python',
            tap_id='my_tap',
            target_id='my_target',
        )
        # profiling disabled
        command = commands.build_transformation_command(
            transform=transform, profiling_mode=False, profiling_dir=None
        )

        assert command == f'/bin/transform_field.py --config {transform_config}'

        # profiling enabled
        command = commands.build_transformation_command(
            transform=transform, profiling_mode=True, profiling_dir='./profiling'
        )

        assert (
            command
            == f'/bin/python -m cProfile -o ./profiling/transformation_my_tap_my_target.pstat '
            f'/bin/transform_field.py --config {transform_config}'
        )
Esempio n. 2
0
    def test_build_transform_command(self):
        """Tests the function that generates transform executable command"""
        # Should return empty string if config file exists but no transformation
        transform_config = '{}/resources/transform-config-empty.json'.format(os.path.dirname(__file__))
        command = commands.build_transformation_command(transform_bin='/bin/transform_field.py',
                                                        config=transform_config)
        assert command is None

        # Should return a input piped command with an executable transform command
        transform_config = '{}/resources/transform-config.json'.format(os.path.dirname(__file__))
        command = commands.build_transformation_command(transform_bin='/bin/transform_field.py',
                                                        config=transform_config)
        assert command == f'/bin/transform_field.py --config {transform_config}'