def test_run_action_with_error(): """test with an error at unoconv time""" temp_path = os.path.join(tmpdir, "this-file-does-not-exists.odt") worker = UnoConvWorker(tmpdir, tmpdir) with pytest.raises(Exception): worker.run_action(src=temp_path) temp_path = os.path.join(tmpdir, "sample-text.odt") worker = UnoConvWorker(tmpdir, tmpdir) with pytest.raises(Exception): worker.run_action(src=temp_path, dest_fmt="not-existing")
def test_run_action(): """just test the action is working""" temp_path = os.path.join(tmpdir, "sample-text.odt") shutil.copyfile(sample_path, temp_path) group_permissions(temp_path) worker = UnoConvWorker(tmpdir, tmpdir) worker.run_action(src=temp_path, remove_src=True) pdf_path = os.path.join(tmpdir, "sample-text.pdf") assert os.path.exists(pdf_path) with open(pdf_path) as f: assert f.read(5) == "%PDF-" assert not os.path.exists(temp_path) shutil.copyfile(sample_path, temp_path) group_permissions(temp_path) worker.run_action(src=temp_path, dest_fmt="doc") odt_path = os.path.join(tmpdir, "sample-text.doc") assert os.path.exists(odt_path) assert os.path.exists(temp_path)