Ejemplo n.º 1
0
 def test_request_list_of_int_list_of_int_above_max(self, mocked_print,
                                                    mocked_input):
     with self.assertRaises(Exception):
         ui.request_list_of_int('', max_value=2)
     mocked_print.assert_called_with(
         f"!WARNING! The following entries are above the allowed maximum of 2 :\n3"
     )
Ejemplo n.º 2
0
 def test_request_list_of_int_list_of_int_below_min(self, mocked_print,
                                                    mocked_input):
     with self.assertRaises(Exception):
         ui.request_list_of_int('', min_value=2)
     mocked_print.assert_called_with(
         f"!WARNING! The following entries are below the allowed minimum of 2:\n1"
     )
Ejemplo n.º 3
0
 def test_request_list_of_int_list_of_float(self, mocked_print,
                                            mocked_input):
     with self.assertRaises(Exception):
         ui.request_list_of_int('')
     mocked_print.assert_called_with(
         f"!WARNING! The following entries are not integers :\n1.3  2.4  12.5"
     )
Ejemplo n.º 4
0
def request_missing_args(partial_args):
    """Sees which arguments are logically missing based on the already provided arguments and actively requests them
    from the user. """
    # Request -re Regex
    if partial_args.regular_expression is None:
        partial_args.regular_expression = ui.request_regex_pattern(
            "Enter a regular expression matching "
            "SFDB lines (optional):\n")

    # Request -c Filepath
    if partial_args.comparison_sfdb is None:
        partial_args.comparison_sfdb = ui.request_sfdb(
            'Path to old SFDB file for comparison tests (optional):\n')
    else:
        logging.info('Path to comparison-SFDB File has already been provided.')

    # Request -x1 exclusion row indices
    if partial_args.excluded_lines1 == [] and partial_args.comparison_sfdb:
        input_message = (
            "\tEnter a space-separated list of the indices of all lines in the old SFDB (starting from 1) "
            "that were removed (optional):\n"
            "\t")
        partial_args.excluded_lines1 = ui.request_list_of_int(input_message,
                                                              min_value=6)

    # Request -x2 eclusion row indices
    if partial_args.excluded_lines2 == [] and partial_args.comparison_sfdb:
        input_message = (
            "\tEnter a space-separated list of the indices of all lines in the new SFDB (starting from 1) "
            "that were added, separated by spaces (optional):\n"
            "\t")
        partial_args.excluded_lines2 = ui.request_list_of_int(input_message,
                                                              min_value=6)

    # Request -xc eclusion column names
    if partial_args.excluded_columns == [] and partial_args.comparison_sfdb:
        input_message = (
            '\tEnter a space-separated list of the name of the columns you wish to ignore for the '
            'comparison (optional):\n'
            '\t')
        partial_args.excluded_columns = input(input_message).split()

    return partial_args
Ejemplo n.º 5
0
 def test_request_list_of_int_list_of_int_between_min_max(
         self, mocked_input):
     int_list = ui.request_list_of_int('', min_value=0, max_value=4)
     expected_output = [1, 2, 3]
     self.assertEqual(expected_output, int_list)
Ejemplo n.º 6
0
 def test_request_list_of_int_empty_string(self, mocked_print,
                                           mocked_input):
     ui.request_list_of_int('')
     mocked_print.assert_called_with(f"No list of numbers provided.")
Ejemplo n.º 7
0
 def test_request_list_of_int_list_of_int(self, mocked_input):
     int_list = ui.request_list_of_int('')
     expected_output = [1, 2, 12]
     self.assertEqual(expected_output, int_list)