def test_doesnt_write_images_if_make_index_is_false( self, mock_open, mock_add_header, mock_add_img_subj, mock_index): mock_file = MagicMock(spec=io.IOBase) mock_open.return_value.__enter__.return_value = mock_file qc_config = self.get_config_stub(make_all=False) html.write_index_pages(self.qc_dir, qc_config, self.subject) # One image in the list should have 'make_index' = False expected_writes = len(qc_config.images) - 1 assert mock_index.call_count == expected_writes
def test_writes_images_to_index(self, mock_open, mock_add_header, mock_add_img_subj, mock_index): mock_file = MagicMock(spec=io.IOBase) mock_open.return_value.__enter__.return_value = mock_file qc_config = self.get_config_stub() html.write_index_pages(self.qc_dir, qc_config, self.subject) expected_writes = len(qc_config.images) assert mock_index.call_count == expected_writes
def test_title_changed_to_include_image_name_when_title_given( self, mock_open, mock_add_header, mock_add_img_subj, mock_index): mock_file = MagicMock(spec=io.IOBase) mock_open.return_value.__enter__.return_value = mock_file qc_config = self.get_config_stub() html.write_index_pages(self.qc_dir, qc_config, self.subject, title='QC mode for image {}') for image in qc_config.images: name = image.name found = False for call in mock_index.call_args_list: if name in call[1]['title']: found = True assert found