File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1313 sys .path .insert (0 , _path )
1414
1515import apstools
16+ from apstools .filewriters import SpecWriterCallback
1617from databroker import Broker
1718import json
1819import shutil
@@ -73,9 +74,22 @@ def tearDown(self):
7374 if os .path .exists (self .tempdir ):
7475 shutil .rmtree (self .tempdir , ignore_errors = True )
7576
76- def test_test (self ):
77+ def test_writer (self ):
7778 self .assertTrue (len (self .db ) > 0 , "test data ready" )
78- # TODO: newfile() tests
79+ testfile = os .path .join (self .tempdir , "tune_mr.dat" )
80+ specwriter = SpecWriterCallback (filename = testfile )
81+ self .assertIsInstance (specwriter , SpecWriterCallback , "specwriter object" )
82+ self .assertEqual (specwriter .spec_filename , testfile , "output data file" )
83+ self .assertFalse (os .path .exists (testfile ), "data file not created yet" )
84+
85+ # write the doc stream to the file
86+ for document in self .db ["tune_mr" ]:
87+ tag , doc = document
88+ specwriter .receiver (tag , doc )
89+
90+ self .assertTrue (os .path .exists (testfile ), "data file created" )
91+
92+ # TODO: test newfile() with existing file
7993
8094
8195def suite (* args , ** kw ):
You can’t perform that action at this time.
0 commit comments