Example #1
0
 def test_other_row_cells_modified(self, mock_first, mock_pyxl):
     """Other rows cell's value attributes changed to None."""
     fake_two_one = FakeCell(2, 1)
     ligrarian.openpyxl.copy_worksheet.return_value.cell.side_effect = [
             fake_two_one,
             FakeCell(2, 2),
             FakeCell(2, 3),
             FakeCell(2, 4),
             FakeCell(2, 5),
             FakeCell(2, 6),
             FakeCell(5, 8),
     ]
     ligrarian.create_sheet(ligrarian.openpyxl, 'copy', 'new')
     assert fake_two_one.value is None
Example #2
0
    def test_first_row_cells_not_modified(self, mock_first, mock_pyxl):
        """First row not accessed by cell call for .value modification.

        Cells are blanked by setting their .value attributes to None. This
        requires the cell to be accessed via a call with row and column args;
        so no call to row 1 column 2 indicates that the first row hasn't been
        set to None.

        """
        mock_sheet = ligrarian.openpyxl.copy_worksheet
        ligrarian.create_sheet(ligrarian.openpyxl, 'copy', 'new')
        cell_calls = mock_sheet.return_value.cell.call_args_list

        assert mock.call(row=1, column=2) not in cell_calls
Example #3
0
 def test_date_formula_written_to_last_cell(self, mock_first, mock_pyxl):
     """Cell 5, 8 equal to date formula."""
     fake_last_call = FakeCell(5, 8)
     ligrarian.openpyxl.copy_worksheet.return_value.cell.side_effect = [
             FakeCell(2, 1),
             FakeCell(2, 2),
             FakeCell(2, 3),
             FakeCell(2, 4),
             FakeCell(2, 5),
             FakeCell(2, 6),
             fake_last_call,
     ]
     ligrarian.create_sheet(ligrarian.openpyxl, 'copy', 'new')
     assert fake_last_call.value == "=(TODAY()-DATE(new,1,1))/7"
Example #4
0
    def test_names_sheet(self, mock_first, mock_pyxl):
        """Should name sheet to new_sheet_name argument."""
        ligrarian.create_sheet(ligrarian.openpyxl, 'copy', 'new')

        assert ligrarian.openpyxl.copy_worksheet.return_value.title == 'new'
Example #5
0
    def test_copies_sheet(self, mock_first, mock_pyxl):
        """Should call copy_worksheet on workbook object."""
        ligrarian.create_sheet(ligrarian.openpyxl, 'copy', 'new')

        ligrarian.openpyxl.copy_worksheet.assert_called_once()