Made vigil into a package with a setup.py file.
This commit is contained in:
parent
49f8d87659
commit
5728e5cff3
135 changed files with 76 additions and 50 deletions
42
tests/worker_test.py
Executable file
42
tests/worker_test.py
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2017 Andrew Hamilton. All rights reserved.
|
||||
# Licensed under the Artistic License 2.0.
|
||||
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import vigil.tools as tools
|
||||
import vigil.worker as worker
|
||||
|
||||
|
||||
class WorkerTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.original_working_dir = os.getcwd()
|
||||
os.chdir(self.temp_dir)
|
||||
os.mkdir(tools.CACHE_PATH)
|
||||
open("foo", "w").close()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
os.chdir(self.original_working_dir)
|
||||
|
||||
def test_run_job(self):
|
||||
loop = asyncio.get_event_loop()
|
||||
worker_ = worker.Worker(False, False)
|
||||
loop.run_until_complete(worker_.create_process())
|
||||
future = worker_.run_tool("foo", tools.metadata)
|
||||
status = loop.run_until_complete(future)
|
||||
self.assertEqual(status, tools.Status.normal)
|
||||
result_path = os.path.join(tools.CACHE_PATH, "foo-metadata")
|
||||
self.assertTrue(os.path.exists(result_path))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue