def test_refresh(self): plot = os.path.join(self.tempdir, 'plot.svg') plot2 = os.path.join(self.tempdir, 'plot2.svg') sdf = specplot.openSpecFile(self.data_file.name) scan = sdf.getScan(3) plotter = specplot.LinePlotter() # plot the first data plotter.plot_scan(scan, plot) self.assertTrue(os.path.exists(plot)) plotsize = os.path.getsize(plot) mtime = os.path.getmtime(plot) self.assertGreater(plotsize, 0) self.assertGreater(mtime, 0) for iter in range(2): scan_number = sdf.refresh() if scan_number is None: scan = sdf.getScan(3) self.assertTrue(scan.__interpreted__) # update the file with more data self.addMoreScans() time.sleep(0.1) else: scan = sdf.getScan(3) self.assertFalse(scan.__interpreted__) plotter.plot_scan(scan, plot2) self.assertTrue(os.path.exists(plot2)) self.assertGreater(os.path.getmtime(plot2), mtime) self.assertNotEqual(os.path.getsize(plot2), plotsize)
def test_y_values_all_zero_lin_lin(self): specFile = os.path.join(os.path.dirname(__file__), 'data', 'issue64_data.txt') scan_number = 50 sfile = specplot.openSpecFile(specFile) scan = sfile.getScan(scan_number) self.assertTrue(scan is not None) plotter = specplot.LinePlotter() if os.path.exists( self.plotFile): # always re-create this plot for testing os.remove(self.plotFile) plotter.plot_scan(scan, self.plotFile) self.assertTrue(os.path.exists(self.plotFile))
def test_scan_aborted_after_0_points(self): specFile = self.abs_data_fname('33bm_spec.dat') scan_number = 15 sfile = specplot.openSpecFile(specFile) scan = sfile.getScan(scan_number) self.assertTrue(scan is not None) plotter = specplot.LinePlotter() if os.path.exists( self.plotFile): # always re-create this plot for testing os.remove(self.plotFile) self.assertRaises(specplot.NoDataToPlot, plotter.plot_scan, scan, self.plotFile) self.assertFalse(os.path.exists(self.plotFile))