def test_standard_submit(self): """This tests the submit function of the spooler. The test make a file and then submits it to a spooler. The spooler processes the file with the default (no-op) processing. """ # Make a file to submit (fd, submit_filename) = tempfile.mkstemp(suffix="_spooler_test_file", dir="/tmp") try: with os.fdopen(fd, "w+") as fh: fh.write("hello!") # Make a spool s = Spool("test", directory=self._spool_dir) # Submit the pre-existing file to it s._submit_file(submit_filename) dc = [os.path.join(s._in, d) for d in os.listdir(s._in)] assert dc, "the incoming file didn't arrive" filename = dc[0] with open(filename) as fd: content = fd.read() assert content == "hello!" # Process with the defaults s.process() # Now assert it's gone to the output filename = filename.replace('/in/', '/out/') # read the last file. try: with open(filename) as fd: content = fd.read() except IOError: assert False, "test1: the processed file didn't arrive" assert content == "hello!" finally: os.unlink(submit_filename) try: fd.close() except Exception: pass