Beispiel #1
0
    def test_parse_args_fails_when_output_file_already_exists(
            self, mock_isfile):
        def side_effect(file_name):
            return True

        mock_isfile.side_effect = side_effect
        with self.assertRaises(SystemExit):
            offence_score.parse_args(input_args)
Beispiel #2
0
    def test_parse_args_fails_when_no_low_risk_exists(self, mock_isfile):
        def side_effect(file_name):
            if file_name != output_file_path and file_name != low_risk_phrases_file_path:
                return True
            return False

        mock_isfile.side_effect = side_effect
        with self.assertRaises(SystemExit):
            offence_score.parse_args(input_args)
Beispiel #3
0
    def test_parse_args_fails_when_a_target_file_does_not_exist(
            self, mock_isfile):
        def side_effect(file_name):
            if file_name != output_file_path and file_name != simple_file_path:
                return True
            return False

        mock_isfile.side_effect = side_effect
        with self.assertRaises(SystemExit):
            offence_score.parse_args(input_args)
Beispiel #4
0
    def test_parse_args_happy_path(self, mock_isfile):
        def side_effect(file_name):
            if file_name != output_file_path:
                return True
            return False

        mock_isfile.side_effect = side_effect

        args = offence_score.parse_args(input_args)
        self.assertEqual(args.high_risk_phrases_file_path,
                         high_risk_phrases_file_path)
        self.assertEqual(args.low_risk_phrases_file_path,
                         low_risk_phrases_file_path)
        self.assertEqual(args.output_file_path, output_file_path)
        self.assertEqual(args.files_to_score, files_to_scan)