Ejemplo n.º 1
0
def test_export_continues_with_missing_sheet_in_datamap(
        mock_config, master, datamap_missing_fields, blank_template):
    """When an export takes place using a datamap with missing sheet names"""
    mock_config.initialise()
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(output_repo, datamap_missing_fields, master,
                                blank_template)
    with pytest.raises(MissingSheetFieldError):
        uc.execute()
Ejemplo n.º 2
0
def test_exception_when_given_master_with_empty_col_a(mock_config, datamap,
                                                      master_no_col_a,
                                                      blank_template):
    """Test for handling cells in Col A which are empty - and return None."""
    mock_config.initialise()
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(output_repo, datamap, master_no_col_a,
                                blank_template)
    with pytest.raises(RuntimeError):
        uc.execute()
Ejemplo n.º 3
0
def test_output_gateway(mock_config, datamap, master, blank_template):
    mock_config.initialise()
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(output_repo, datamap, master, blank_template)
    uc.execute()
    result_file = mock_config.PLATFORM_DOCS_DIR / "output" / "Chutney Bridge.xlsm"
    wb = load_workbook(result_file)
    intro_sheet = wb["Introduction"]
    summ_sheet = wb["Summary"]
    an_sheet = wb["Another Sheet"]
    assert intro_sheet["C9"].value == "Accounting Department"
    assert intro_sheet["C10"].value == "Satellite Corp"
    assert intro_sheet["C13"].value == 1334
    # note that dates come out of spreadsheets as datetime objects
    assert intro_sheet["C17"].value == datetime.datetime(2012, 1, 1, 0, 0)
    assert summ_sheet["B3"].value == "Bobbins"
    assert an_sheet["F17"].value == 20.303
    # note that dates come out of spreadsheets as datetime objects
    assert an_sheet["H39"].value == datetime.datetime(2024, 2, 1, 0, 0)
Ejemplo n.º 4
0
def test_output_gateway_reduced_datamap(mock_config, datamap_reduced, master,
                                        blank_template):
    """
    The idea here is that the resulting master should work even if some lines
    in the  datamap are removed or hidden. In other words, the export does not
    depend on the datamap and the master's column A matching.
    """
    mock_config.initialise()
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(output_repo, datamap_reduced, master,
                                blank_template)
    uc.execute()
    result_file = mock_config.PLATFORM_DOCS_DIR / "output" / "Chutney Bridge.xlsm"
    wb = load_workbook(result_file)
    intro_sheet = wb["Introduction"]
    assert intro_sheet["C10"].value == "Satellite Corp"
    assert intro_sheet["C11"].value == "Chutney Bridge Ltd"
    assert intro_sheet["C13"].value == 1334
    # note that dates come out of spreadsheets as datetime objects
    assert intro_sheet["C17"].value == datetime.datetime(2012, 1, 1, 0, 0)
Ejemplo n.º 5
0
def test_can_export_more_than_twenty_six_columns(
    mock_config,
    datamap,
    master_with_rogue_cell_vals_beyond_col_and_row_range,
    blank_template,
):
    # master_plus_twenty_six must contain at least 26 projects
    mock_config.initialise()
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(
        output_repo,
        datamap,
        master_with_rogue_cell_vals_beyond_col_and_row_range,
        blank_template,
    )
    uc.execute()
    # Test a project much later - i.e. beyond the 25th project
    result_file = (mock_config.PLATFORM_DOCS_DIR / "output" /
                   "Ramsbottom Knot Gorge Cleanout 26.xlsm")
    wb = load_workbook(result_file)
    intro_sheet = wb["Introduction"]
    assert intro_sheet["C9"].value == "VA Department"
Ejemplo n.º 6
0
def write_master_to_templates(blank_template: Path, datamap: Path,
                              master: Path) -> None:
    output_repo = MultipleTemplatesWriteRepo(blank_template)
    uc = WriteMasterToTemplates(output_repo, datamap, master, blank_template)
    uc.execute()