コード例 #1
0
 def test_process_args_should_reject_missing_units(self, arg_dict):
     """
     The argument processor should not create a ``ChangeResolution`` action
     if the input resolution desired has no units.
     """
     with pytest.raises(KeyError):
         change_resolution.process_args(arg_dict)
コード例 #2
0
 def test_process_args_should_reject_missing_units(self, arg_dict):
     """
     The argument processor should not create a ``ChangeResolution`` action
     if the input resolution desired has no units.
     """
     with pytest.raises(KeyError):
         change_resolution.process_args(arg_dict)
コード例 #3
0
 def test_process_args_should_reject_noninteger_values(self, arg_dict):
     """
     The argument processor should not accept a nonpositive, noninteger
     input value for the image resolution.
     """
     self.use_resolution_val(arg_dict, "Potato")
     with pytest.raises(TypeError):
         change_resolution.process_args(arg_dict)
コード例 #4
0
 def test_process_args_should_reject_resolution_value_of_zero(self, arg_dict):
     """
     The argument processor should not accept zero as an input value for
     the image resolution.
     """
     self.use_resolution_val(arg_dict, 0)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #5
0
 def test_process_args_should_reject_noninteger_values(self, arg_dict):
     """
     The argument processor should not accept a nonpositive, noninteger
     input value for the image resolution.
     """
     self.use_resolution_val(arg_dict, "Potato")
     with pytest.raises(TypeError):
         change_resolution.process_args(arg_dict)
コード例 #6
0
 def test_process_args_should_reject_fractional_resolution_values(self, arg_dict):
     """
     The ``ChangeResolution`` action's argument processor should not accept
     fractional resolution values.
     """
     self.use_resolution_val(arg_dict, 600.1)
     with pytest.raises(TypeError):
         change_resolution.process_args(arg_dict)
コード例 #7
0
 def test_process_args_should_reject_nonpositive_resolution_values(self, arg_dict):
     """
     The argument processor should not accept a negative input value for
     the image resolution.
     """
     self.use_resolution_val(arg_dict, -600)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #8
0
 def test_process_args_should_reject_nonpositive_resolution_values(
         self, arg_dict):
     """
     The argument processor should not accept a negative input value for
     the image resolution.
     """
     self.use_resolution_val(arg_dict, -600)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #9
0
 def test_process_args_should_reject_resolution_value_of_zero(
         self, arg_dict):
     """
     The argument processor should not accept zero as an input value for
     the image resolution.
     """
     self.use_resolution_val(arg_dict, 0)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #10
0
 def test_process_args_should_reject_fractional_resolution_values(
         self, arg_dict):
     """
     The ``ChangeResolution`` action's argument processor should not accept
     fractional resolution values.
     """
     self.use_resolution_val(arg_dict, 600.1)
     with pytest.raises(TypeError):
         change_resolution.process_args(arg_dict)
コード例 #11
0
 def test_process_args_should_reject_nonpositive_integer_resolutions(self, arg_dict):
     """
     The argument processor should reject negative and zero values for
     the new resolution for the image. It does not make sense to have 
     negative pixels per inch.
     """
     self.use_resolution_val(arg_dict, -600)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #12
0
 def test_process_args_should_reject_nonpositive_integer_resolutions(
         self, arg_dict):
     """
     The argument processor should reject negative and zero values for
     the new resolution for the image. It does not make sense to have 
     negative pixels per inch.
     """
     self.use_resolution_val(arg_dict, -600)
     with pytest.raises(ValueError):
         change_resolution.process_args(arg_dict)
コード例 #13
0
    def test_process_args_should_reject_non_existent_input_directory(self, arg_dict):
        """
        The arument processor should not accept an input directory that does
        not exist. Surely it is impossible to read a nonexistent input.
        """
        self.use_source_path(arg_dict, 'sample/directory_does_not_exist/')
        self.use_resolution_val(arg_dict, 600)

        with pytest.raises(FileNotFoundError):
            change_resolution.process_args(arg_dict)
コード例 #14
0
    def test_process_args_should_reject_non_existent_input_directory(
            self, arg_dict):
        """
        The arument processor should not accept an input directory that does
        not exist. Surely it is impossible to read a nonexistent input.
        """
        self.use_source_path(arg_dict, 'sample/directory_does_not_exist/')
        self.use_resolution_val(arg_dict, 600)

        with pytest.raises(FileNotFoundError):
            change_resolution.process_args(arg_dict)
コード例 #15
0
    def test_change_resolution_runner(self, arg_dict):
        action = change_resolution.process_args(arg_dict)
        target_file = arg_dict['output']

        change_resolution.Runner.setup(action)
        change_resolution.Runner.execute(action)

        assert os.path.exists(target_file)
コード例 #16
0
    def test_change_resolution_runner(self, arg_dict):
        action = change_resolution.process_args(arg_dict)
        target_file = arg_dict['output']

        change_resolution.Runner.setup(action)
        change_resolution.Runner.execute(action)

        assert os.path.exists(target_file)
コード例 #17
0
 def test_process_args(self, arg_dict):
     """
     The argument processor should correctly create a ``ChangeResolution``
     action under conditions where there is a positive resolution value when
     units are given.
     """
     self.use_resolution_val(arg_dict, 600)
     action = change_resolution.process_args(arg_dict)
     
     assert isinstance(action, change_resolution.ChangeResolution)
     assert action.source_file != action.target_file
コード例 #18
0
    def test_change_resolution_runner_process(self, arg_dict):
        self.use_source_file(arg_dict, 'sample/sample.tiff')
        action = change_resolution.process_args(arg_dict)

        try:
            change_resolution.Runner.setup(action)
            change_resolution.Runner.execute(action)
        except FileNotFoundError as e:
            pytest.fail(e)
        finally:
            change_resolution.Runner.cleanup(action)
コード例 #19
0
    def test_change_resolution_runner_process(self, arg_dict):
        self.use_source_file(arg_dict, 'sample/sample.tiff')
        action = change_resolution.process_args(arg_dict)

        try:
            change_resolution.Runner.setup(action)
            change_resolution.Runner.execute(action)
        except FileNotFoundError as e:
            pytest.fail(e)
        finally:
            change_resolution.Runner.cleanup(action)
コード例 #20
0
    def test_process_args(self, arg_dict):
        """
        The argument processor should correctly create a ``ChangeResolution``
        action under conditions where there is a positive resolution value when
        units are given.
        """
        self.use_resolution_val(arg_dict, 600)
        action = change_resolution.process_args(arg_dict)

        assert isinstance(action, change_resolution.ChangeResolution)
        assert action.source_file != action.target_file
コード例 #21
0
    def test_multi_page_change_resolution_should_generate_multiple_actions_from_input_directory(
            self, arg_dict):
        """
        Given a valid input directory with zero or more files in it, the multiple
        page change resolution action argument processor should find every valid 
        input image and group them together into one action.
        """
        resolution = Resolution.make(arg_dict['resolution'], arg_dict['units'])
        multi_actions = change_resolution.process_args(arg_dict)

        for action in multi_actions.values():
            assert isinstance(action, change_resolution.ChangeResolution)
コード例 #22
0
 def test_multi_page_change_resolution_should_generate_multiple_actions_from_input_directory(self, arg_dict):
     """
     Given a valid input directory with zero or more files in it, the multiple
     page change resolution action argument processor should find every valid 
     input image and group them together into one action.
     """
     resolution = Resolution.make(
         arg_dict['resolution'], arg_dict['units']
     )
     multi_actions = change_resolution.process_args(arg_dict)
     
     for action in multi_actions.values():
         assert isinstance(action, change_resolution.ChangeResolution)
コード例 #23
0
 def test_runner_should_fail_if_source_does_not_exist(self, arg_dict):
     self.use_source_file(arg_dict, 'sample/does_not_exist.tiff')
     with pytest.raises(FileNotFoundError):
         action = change_resolution.process_args(arg_dict)
         change_resolution.Runner.setup(action)
コード例 #24
0
 def test_runner_should_fail_if_source_does_not_exist(self, arg_dict):
     self.use_source_file(arg_dict, 'sample/does_not_exist.tiff')
     with pytest.raises(FileNotFoundError):
         action = change_resolution.process_args(arg_dict)
         change_resolution.Runner.setup(action)