forked from rc/aircox
- Writes tests for aircox streamer application; - Add test utilities in aircox Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#110
This commit is contained in:
39
aircox_streamer/tests/fake_modules/subprocess.py
Normal file
39
aircox_streamer/tests/fake_modules/subprocess.py
Normal file
@ -0,0 +1,39 @@
|
||||
"""Spoof psutil module in order to run and check tests Resulting values of
|
||||
method calls are set inside `fixtures` module."""
|
||||
|
||||
STDOUT = 1
|
||||
STDERR = 2
|
||||
STDIN = 3
|
||||
|
||||
|
||||
class FakeProcess:
|
||||
args = None
|
||||
kwargs = None
|
||||
"""Kwargs passed to Popen."""
|
||||
killed = False
|
||||
"""kill() have been called."""
|
||||
waited = False
|
||||
"""wait() have been called."""
|
||||
polled = False
|
||||
"""poll() have been called."""
|
||||
poll_result = None
|
||||
"""Result of poll() method."""
|
||||
|
||||
def __init__(self, args=[], kwargs={}):
|
||||
self.pid = -13
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
def kill(self):
|
||||
self.killed = True
|
||||
|
||||
def wait(self):
|
||||
self.waited = True
|
||||
|
||||
def poll(self):
|
||||
self.polled = True
|
||||
return self.poll_result
|
||||
|
||||
|
||||
def Popen(args, **kwargs):
|
||||
return FakeProcess(args, kwargs)
|
Reference in New Issue
Block a user