def test_empty_list_selection():
    """
    Test selection operation when using a list that is empty.
    """
    try:
        selection(EMPTY_LIST, filter_students)
    except AttributeError:
        assert True
def test_empty_list_selection():
    """
    Test selection operation when using a list that is empty.
    """
    try:
        selection(EMPTY_LIST, filter_students)
    except AttributeError:
        assert True
def test_selection():
    """
    Test select operation.
    """

    result = [["Surname", "FirstName", "Age", "Salary"], ["Verdi", "Nico", 36, 4500], ["Smith", "Mark", 40, 3900]]
    assert is_equal(result, selection(EMPLOYEES, filter_employees))
    assert selection(GRADUATES, filter_employees) is None
    assert selection(R3, filter_employees) is None
示例#4
0
def test_selection():
    """
    Test select operation.
    """

    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500], ["Smith", "Mark", 40, 3900]]
    assert is_equal(result, selection(EMPLOYEES, filter_employees))
    assert selection(GRADUATES, filter_employees) is None
    assert selection(R3, filter_employees) is None
def test_selection_result_empty():
    """
    Test select operation result with empty table
    """
    def returnNone(row):
        return row[-1] < -1
    assert selection(EMPLOYEES, returnNone) == None
def test_selection_empty_input_table():
    """
    Test select operation where input table is an empty table.
    """
    empty_table = [["Surname", "FirstName", "Age", "Salary"]]

    assert selection(empty_table, filter_employees) is None
def test_selection_none():
    """
    Tests selection function to see if None is returned when
    it results in an empty table
    return: None (empty table)
    """
    assert (selection(EMPLOYEES, filter_employees_none)) is None
def test_selection_empty_input_table():
    """
    Test select operation where input table is an empty table.
    """
    empty_table = [["Surname", "FirstName", "Age", "Salary"]]

    assert selection(empty_table, filter_employees) is None
def test_selection_some_results():
    """
    Test select operation such that some rows get selected, some don't get selected
    """
    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500], ["Smith", "Mark", 40, 3900]]

    assert is_equal(result, selection(EMPLOYEES, filter_employees))
def test_selection_all_results():
    """
    Test select operation with selection that returns everything
    """
    table = [["Surname", "FirstName", "Age", "Salary"],
             ["Verdi", "Nico", 36, 4500], ["Smith", "Mark", 40, 3900]]

    assert is_equal(table, selection(table, filter_employees))
def test_selection_no_results():
    """
    Test select operation where nothing gets selected.
    """
    table = [["Surname", "FirstName", "Age", "Salary"],
             ["Smith", "Mary", 25, 2000], ["Black", "Lucy", 40, 3000]]

    assert selection(table, filter_employees) is None
def test_selection():
    """
    Test the selection operation.
    """

    result = [["FirstName", "Surname", "IQ", "GPA"], ["Zoe", "Washburne", 110, 3.5], ["Inara", "Serra", 158, 4.0]]

    assert is_equal(result, selection(STUDENTS, filter_students))
def test_selection():
    """
    Test the selection operation.
    """

    result = [["FirstName", "Surname", "IQ", "GPA"],
              ["Zoe", "Washburne", 110, 3.5], ["Inara", "Serra", 158, 4.0]]

    assert is_equal(result, selection(STUDENTS, filter_students))
def test_selection_no_results():
    """
    Test select operation where nothing gets selected.
    """
    table = [["Surname", "FirstName", "Age", "Salary"],
             ["Smith", "Mary", 25, 2000],
             ["Black", "Lucy", 40, 3000]]

    assert selection(table, filter_employees) is None
def test_selection_all_results():
    """
    Test select operation with selection that returns everything
    """
    table = [["Surname", "FirstName", "Age", "Salary"],
             ["Verdi", "Nico", 36, 4500],
             ["Smith", "Mark", 40, 3900]]

    assert is_equal(table, selection(table, filter_employees))
def test_selection_some_results():
    """
    Test select operation such that some rows get selected, some don't get selected
    """
    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500],
              ["Smith", "Mark", 40, 3900]]

    assert is_equal(result, selection(EMPLOYEES, filter_employees))
def test_selection_student():
    # Test selection
    result = [["FirstName", "Surname", "Age"],
              ["Yueyue", "Yang", 25],
              ["Yuchen", "Jia", 23],
              ["Xike", "Wang", 25],
              ["Ming", "Fu", 31]]

    assert is_equal(result, selection(STUDENTS, filter_students))
示例#18
0
def test_selection_team_test():
    # Tests select operation
    result = [["Surname", "FirstName", "Age"],
          ["Vasquez", "Maria", 23],
          ["Allen", "Grant", 18],
          ["Xun", "Lu", 47],
          ["Qian", "Sima", 117]]

    assert is_equal(result, selection(VOTERS, filter_eligible_voters))
def test_selection():
    """
    Test selection operation.
    """

    result = [["Surname", "FirstName", "Age", "Tuition"],
              ["Black", "Lucy", 28, 35000], ["Sara", "Maria", 36, 45000],
              ["Smith", "Mark", 29, 39000]]
    assert is_equal(result, selection(STUDENTS, filter_students))
def test_selection_one_row():
    """
    Tests selection function to see if selection table
    of just one row is properly generated.
    return: a new table the result of applying function to original table)
    """
    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500]]
    assert is_equal(result, selection(EMPLOYEES, filter_employees_names))
def test_selection_returns_none():
    # Checks if selection() function returns "None" if the result is an empty table.
    t = [["Age", "Name"],
         ["Dan", 50],
         ["Mary", 44],
         ["Jose", 54]]

    def f(r):
        return r[-1] < 35

    assert selection(t, f) == None
def test_selection1():
    """
    Test select operation (student version)
    """
    result1 = [["Make", "Color", "Year", "Works(y/n)"],
                ["Honda", "Orange", 2011, "n"],
                ["Dodge", "Purple", 2000, "y"],
                ["Fiat", "Polka dot", 1999, "y"]]

    result2 = [["Make", "Color", "Year", "Works(y/n)"],
                ["Dodge", "Purple", 2000, "y"]]

    # Test with CARS table and filter_vehicles
    assert is_equal(result1, selection(CARS, filter_vehicles))

    # Test with TRUCKS table and filter_vehicles
    assert is_equal(result2, selection(TRUCKS, filter_vehicles))

    # Test with BIKES table and filter_vehicles (should filter out all entries and return None)
    assert selection(BIKES, filter_vehicles) == None
def test_selection_our_test():
    """
    Another test select operation.
    return: a new table the result of applying function to original table
    """
    result = [["Surname", "Title", "Age"],
              ["Mustard", "Colonel", 63],
              ["White", "Mrs.", 56],
              ["Plum", "Professor", 48]]

    assert is_equal(result, selection(SUSPECTS, filter_suspects))
def test_selection():
    """
    Test select operation.
    return: a new table the result of applying function to original table
    """

    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500],
              ["Smith", "Mark", 40, 3900]]

    assert is_equal(result, selection(EMPLOYEES, filter_employees))
def test_selection_returns_nothing():
    # Test if selection is none
    t = [["Name", "Age"],
         ["Bob", 47],
         ["Mary", 65],
         ["Carla", 54]]

    def f(r):
        return r[-1] < 35

    assert selection(t, f) is None
示例#26
0
def test_selection_returns_nothing():
    #Tests whether selection() function returns None if result is empty table
    t = [["Name", "Age"],
         ["Bob", 47],
         ["Mary", 65],
         ["Carla", 54]]

    def f(r):
        return r[-1] < 35

    assert selection(t,f) == None
def test_selection():
    """
    Test select operation.
    """
    # Test last_element_gt_three method selection
    result = [["A", "B", "C"], [4, 5, 6]]
    assert is_equal(result, selection(R, last_elem_gt_three))

    # Test empty table returned when no rows in result
    input_table = [[1, 1, 1], [2, 2, 2]]
    assert is_equal([], selection(input_table, last_elem_gt_three))

    # Test empty table returned when input table is null
    assert is_equal([], selection([], last_elem_gt_three))

    # Test filter employee method selection
    result = [["Surname", "FirstName", "Age", "Salary"],
              ["Verdi", "Nico", 36, 4500],
              ["Smith", "Mark", 40, 3900]]
    assert is_equal(result, selection(EMPLOYEES, filter_employees))

    # If selection function is not passed, should raise exception
    with pytest.raises(UnknownFunctionException):
        not_a_fn = []
        selection(R, not_a_fn)
def test_selection_empty_list():
    """
    Return None for an empty table
    """
    assert selection(EMPLOYEES_EMPTY, filter_employees) is None
def test_selection_empty_list():
    """
    Return None for an empty table
    """
    assert selection(EMPLOYEES_EMPTY, filter_employees) is None
def test_selection2():
    result = [["A", "B", "C"], [4, 5, 6]]

    assert is_equal (result, selection(R, filter_r))
def test_selection_empty_table():
    """
    Test select operation with empty table
    """
    assert selection([], filter_employees) == None