From 8f4e176f5354ea7569abf60ec255ab5079246df0 Mon Sep 17 00:00:00 2001 From: Peter surface book 2 Date: Sat, 12 Dec 2020 15:55:46 -0800 Subject: [PATCH 1/2] update MRC test to use writer and temp_file remove TODO in DM and SER which cant be accomplished. --- tests/test_DM.py | 9 ++++++--- tests/test_MRC.py | 46 +++++++++++++--------------------------------- tests/test_SER.py | 10 +++++----- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/tests/test_DM.py b/tests/test_DM.py index 2c0bd8f..255b49b 100644 --- a/tests/test_DM.py +++ b/tests/test_DM.py @@ -1,12 +1,15 @@ +from pathlib import Path import pytest -from xicam.NCEM.ingestors.DMPlugin import ingest_NCEM_DM -# TODO: add fixture that writes temp data file with ncempy for tests +from xicam.NCEM.ingestors.DMPlugin import ingest_NCEM_DM + @pytest.fixture def DM_path(): - return "/home/rp/data/NCEM/01_TimeSeriesImages_20images(1).dm3" + """DM files must be written from DM.""" + dPath = Path.home() + return str(dPath / Path('data') / Path('01_TimeSeriesImages_20images.dm3')) def test_slicing(DM_path): diff --git a/tests/test_MRC.py b/tests/test_MRC.py index aaa9a19..a37c7af 100644 --- a/tests/test_MRC.py +++ b/tests/test_MRC.py @@ -8,44 +8,24 @@ from xicam.NCEM.ingestors.MRCPlugin import ingest_NCEM_MRC -# TODO: move file creation to fixture - @pytest.fixture -def mrc_path(): - """Write a small MRC file to a temporary directory and file location. - - THIS DOES NOT WORK. NOT SURE WHY. -PAE - - Returns - ------- - : string - The path to the temporary file. - """ - dd, _, _ = np.mgrid[0:30, 0:40, 0:50] - dd = dd.astype(' Date: Sat, 12 Dec 2020 16:12:32 -0800 Subject: [PATCH 2/2] Use pytest fixture for temp_file and write EMD files for tests. --- tests/test_EMD.py | 87 ++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/tests/test_EMD.py b/tests/test_EMD.py index 099f873..eb2f60b 100644 --- a/tests/test_EMD.py +++ b/tests/test_EMD.py @@ -9,26 +9,12 @@ from xicam.NCEM.ingestors.EMDPlugin import ingest_NCEM_EMD, _get_slice from databroker.in_memory import BlueskyInMemoryCatalog -# TODO: move file creation to fixture - @pytest.fixture -def EMD_path(): - """ - Write a small Berkeley EMD file to a tempfile - - """ - #return "/home/rp/data/NCEM/Acquisition_18.emd" - dd, _, _ = np.mgrid[0:30, 0:40, 0:50] - dd = dd.astype('