Example #1
0
def test_number_columns_kwarg_with_setting(entries_27,
                                           settings_NUMBER_OF_COLUMNS_4):
    # the number of columns corresponds to num_columns kwarg passed
    instance = EvenVMCView(num_columns=5)
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 5
Example #2
0
def test_number_columns_kwarg_with_setting(entries_27,
                                           settings_number_of_columns_4):
    """The number of columns corresponds to num_columns kwarg passed"""
    instance = EvenVMCView(num_columns=5)
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 5
Example #3
0
def test_number_columns_defaults_to_3(entries_27,
                                      settings_NUMBER_OF_COLUMNS_Null):
    # the number of columns defaults to 3 if not provided
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 3
Example #4
0
def test_number_columns_defaults_to_3(entries_27,
                                      settings_number_of_columns_null):
    """The number of columns defaults to 3 if not provided"""
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 3
Example #5
0
def test_susan(alternate_data_structure_data, settings_NUMBER_OF_COLUMNS_5):
    instance = EvenVMCView()
    rows = instance.process_entries(alternate_data_structure_data)
    for r in range(len(rows) - 1):
        row = rows[r]
        for c in row:
            for i in range(5):
                assert type(row[i]) is dict
    row = rows[len(rows) - 1]
    for i in range(2):
        assert type(row[i]) is dict
    for i in range(2, 5):
        assert row[i] == ""
Example #6
0
def test_heirarchical_data(heirarchical_data_structure,
                           settings_number_of_columns_5):
    """Testing that heirarchical data can be handled by VMC (even though this is NOT recommended"""
    instance = EvenVMCView()
    rows = instance.process_entries(heirarchical_data_structure)
    for row in range(len(rows) - 1):
        row_content = rows[row]
        for i in row_content:
            for j in range(5):
                assert isinstance(row[j], dict)
    row = rows[len(rows) - 1]
    for i in range(2):
        assert isinstance(row[i], dict)
    for i in range(2, 5):
        assert row[i] == ""
Example #7
0
def test_same_entries_in_same_vertical_order(entries_27,
                                             settings_NUMBER_OF_COLUMNS_4):
    # All the entries received are still there and are vertically sorted in the same order as received
    # Note entries_27 spread over 4 rows means 7 rows with the last row having 1 null entry in the last position
    # Null entries must be removed. They were just filler to complete the row and keep the template happy.
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    temp_list = []
    for c in range(4):
        temp_list.append([
            rows[r][c]["name"] if rows[r][c] != "" else "to-be-removed"
            for r in range(7)
        ])
    temp_list = flatten(temp_list)
    generated_entries = [e for e in temp_list if e != "to-be-removed"]
    original_entries = [e["name"] for e in entries_27]

    assert original_entries == generated_entries
Example #8
0
def test_partial_rows_display_data_in_left_most_columns(
        entries_27, settings_NUMBER_OF_COLUMNS_5):
    # As above, when the number of entries to be displayed does not divide evenly by the number of columns,
    # the extra cells are displayed in the left most columns of the last row
    # The 27 entries spread over 5 columns means 6 rows. The first 5 rows should have dictionaries in all positions.
    # The last row should have only 2 dictionaries in the first 2 positions. The remaining 3 should be empty strings.
    # This test checks for this.
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    for r in range(len(rows) - 1):
        row = rows[r]
        for c in row:
            for i in range(5):
                assert type(row[i]) is dict
    row = rows[len(rows) - 1]
    for i in range(2):
        assert type(row[i]) is dict
    for i in range(2, 5):
        assert row[i] == ""
Example #9
0
def test_partial_rows_display_data_in_left_most_columns(
        entries_27, settings_number_of_columns_5):
    """As above, when the number of entries to be displayed does not divide evenly by the number of columns,
    the extra cells are displayed in the left most columns of the last row
    The 27 entries spread over 5 columns means 6 rows. The first 5 rows should have dictionaries in all positions.
    The last row should have only 2 dictionaries in the first 2 positions. The remaining 3 should be empty strings.
    This test checks for this.
    """
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    for row in range(len(rows) - 1):
        row_content = rows[row]
        for i in row_content:
            for j in range(5):
                assert isinstance(row_content[j], dict)
    row = rows[len(rows) - 1]
    for i in range(1):
        assert isinstance(row[i], dict)
    for i in range(1, 5):
        assert row[i] == ""
Example #10
0
def test_number_columns_correct(entries_27, settings_NUMBER_OF_COLUMNS_3):
    # the number of columns generated corresponds to the column number setting
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 3
Example #11
0
def test_can_handle_no_data_passed(settings_number_of_columns_null, entries_0):
    """If no data is passed, process_entries can handle it"""
    instance = EvenVMCView()
    rows = instance.process_entries(entries_0)
    assert rows == []
Example #12
0
def test_number_columns_correct(entries_27, settings_number_of_columns_3):
    """The number of columns generated corresponds to the column number setting"""
    instance = EvenVMCView()
    rows = instance.process_entries(entries_27)
    num_cols = len(rows[0])
    assert num_cols == 3