* Better documentation for the local backend
* Remove the fifos at the beginning of the test
This commit is contained in:
parent
bdf964531f
commit
97adb1a191
2 changed files with 23 additions and 2 deletions
|
@ -12,8 +12,22 @@ from platypush.message.request import Request
|
||||||
from platypush.message.response import Response
|
from platypush.message.response import Response
|
||||||
|
|
||||||
class LocalBackend(Backend):
|
class LocalBackend(Backend):
|
||||||
""" Sends and receive messages on two distinct local FIFOs, one for
|
"""
|
||||||
the requests and one for the responses """
|
Sends and receive messages on two distinct local FIFOs, one for
|
||||||
|
the requests and one for the responses.
|
||||||
|
|
||||||
|
You can use this backend either to send local commands to push through
|
||||||
|
Pusher (or any other script), or debug. You can even send command on the
|
||||||
|
command line and read the responses in this way:
|
||||||
|
|
||||||
|
# Send the request. Remember: the JSON must be all on one line.
|
||||||
|
$ cat <<EOF > /tmp/platypush-requests.fifo
|
||||||
|
{"type": "request", "target": "node_name", "action": "shell.exec", "args": {"cmd":"echo ping"}, "origin": "node_name", "id": "put_an_id_here"}
|
||||||
|
EOF
|
||||||
|
$ cat /tmp/platypush-responses.fifo
|
||||||
|
ping
|
||||||
|
$
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, request_fifo, response_fifo, **kwargs):
|
def __init__(self, request_fifo, response_fifo, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from .context import platypush, config_file, TestTimeoutException
|
from .context import platypush, config_file, TestTimeoutException
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -22,6 +23,12 @@ class TestLocal(unittest.TestCase):
|
||||||
backends = Config.get_backends()
|
backends = Config.get_backends()
|
||||||
self.assertTrue('local' in backends)
|
self.assertTrue('local' in backends)
|
||||||
|
|
||||||
|
try: os.remove(Config.get_backends()['local']['request_fifo'])
|
||||||
|
except FileNotFoundError as e: pass
|
||||||
|
|
||||||
|
try: os.remove(Config.get_backends()['local']['response_fifo'])
|
||||||
|
except FileNotFoundError as e: pass
|
||||||
|
|
||||||
|
|
||||||
def test_local_shell_exec_flow(self):
|
def test_local_shell_exec_flow(self):
|
||||||
self.start_sender()
|
self.start_sender()
|
||||||
|
|
Loading…
Reference in a new issue