summaryrefslogtreecommitdiffstats
path: root/tests/units
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/server.py4
-rw-r--r--tests/units/test_0001_probe.py14
-rw-r--r--tests/units/test_0003_shellrun.py30
-rw-r--r--tests/units/test_0004_hardware.py4
-rw-r--r--tests/units/test_0005_other_requests.py4
-rw-r--r--tests/units/test_0006_run_schedule.py4
-rw-r--r--tests/units/test_0007_software.py4
-rw-r--r--tests/units/test_0008_refresh.py4
8 files changed, 34 insertions, 34 deletions
diff --git a/tests/units/server.py b/tests/units/server.py
index 864b75c..d50c646 100644
--- a/tests/units/server.py
+++ b/tests/units/server.py
@@ -12,9 +12,9 @@ import sys
class Server():
_probe_json = '{"id": 0, "name": "test_local", "center": 0, "room": 0}'
- _probe_msg = 'POST /probe HTTP/1.0\r\nContent-Length:'+ \
+ _probe_msg = 'POST /probe HTTP/1.0\r\nContent-Length: '+ \
str(len(_probe_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + _probe_json
+ '\r\nContent-Type: application/json\r\n\r\n' + _probe_json
_recv_buffer_size = 16384
def __init__(self, host='127.0.0.1', port=1234):
diff --git a/tests/units/test_0001_probe.py b/tests/units/test_0001_probe.py
index 0f08296..a39ff7d 100644
--- a/tests/units/test_0001_probe.py
+++ b/tests/units/test_0001_probe.py
@@ -13,8 +13,8 @@ import unittest
class TestProbeMethods(unittest.TestCase):
def setUp(self):
- self.ok_response = 'HTTP/1.0 200 OK\r\nContent-Length:17\r\n' \
- 'Content-Type:application/json\r\n\r\n' + \
+ self.ok_response = 'HTTP/1.0 200 OK\r\nContent-Length: 17\r\n' \
+ 'Content-Type: application/json\r\n\r\n' + \
'{"status": "OPG"}'
def test_post(self):
@@ -29,7 +29,7 @@ class TestProbeMethods(unittest.TestCase):
c = Client()
s = Server()
s.connect(probe=False)
- s.send('POST /probe HTTP/1.0\r\nContent-Length:0\r\n\r\n')
+ s.send('POST /probe HTTP/1.0\r\nContent-Length: 0\r\n\r\n')
response = s.recv()
s.stop()
c.stop()
@@ -38,8 +38,8 @@ class TestProbeMethods(unittest.TestCase):
def test_malformed_json(self):
json = '{"id": 0, "name": "test_local", "center": 0}'
len_json = str(len(json))
- msg = 'POST /probe HTTP/1.0\r\nContent-Length:' + len_json + \
- '\r\nContent-Type:application/json\r\n\r\n' + json
+ msg = 'POST /probe HTTP/1.0\r\nContent-Length: ' + len_json + \
+ '\r\nContent-Type: application/json\r\n\r\n' + json
c = Client()
s = Server()
s.connect(probe=False)
@@ -64,8 +64,8 @@ class TestProbeMethods(unittest.TestCase):
json = '{"id": 0, "name": "test_local", "center": 0, "room": 0, ' + \
'"extra_param": true}'
len_json = str(len(json))
- msg = 'POST /probe HTTP/1.0\r\nContent-Length:' + len_json + \
- '\r\nContent-Type:application/json\r\n\r\n' + json
+ msg = 'POST /probe HTTP/1.0\r\nContent-Length: ' + len_json + \
+ '\r\nContent-Type: application/json\r\n\r\n' + json
c = Client()
s = Server()
s.connect(probe=False)
diff --git a/tests/units/test_0003_shellrun.py b/tests/units/test_0003_shellrun.py
index 79b7305..a6609ad 100644
--- a/tests/units/test_0003_shellrun.py
+++ b/tests/units/test_0003_shellrun.py
@@ -15,12 +15,12 @@ class TestShellRunMethods(unittest.TestCase):
def test_post_with_echo(self):
req_json = '{"run":"echo \\"croqueta\\"", "echo":true}'
response_json = '{"out": \"croqueta\\n\"}'
- req = 'POST /shell/run HTTP/1.0\r\nContent-Length:'+ \
+ req = 'POST /shell/run HTTP/1.0\r\nContent-Length: '+ \
str(len(req_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + req_json
- resp = 'HTTP/1.0 200 OK\r\nContent-Length:' + \
+ '\r\nContent-Type: application/json\r\n\r\n' + req_json
+ resp = 'HTTP/1.0 200 OK\r\nContent-Length: ' + \
str(len(response_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + response_json
+ '\r\nContent-Type: application/json\r\n\r\n' + response_json
c = Client()
s = Server()
s.connect()
@@ -32,9 +32,9 @@ class TestShellRunMethods(unittest.TestCase):
def test_post_without_echo(self):
req_json = '{"run":"echo 1", "echo":false}'
- req = 'POST /shell/run HTTP/1.0\r\nContent-Length:'+ \
+ req = 'POST /shell/run HTTP/1.0\r\nContent-Length: '+ \
str(len(req_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + req_json
+ '\r\nContent-Type: application/json\r\n\r\n' + req_json
resp = 'HTTP/1.0 200 OK\r\n\r\n'
c = Client()
s = Server()
@@ -49,7 +49,7 @@ class TestShellRunMethods(unittest.TestCase):
c = Client()
s = Server()
s.connect()
- s.send('POST /shell/run HTTP/1.0\r\nContent-Length:0\r\n\r\n')
+ s.send('POST /shell/run HTTP/1.0\r\nContent-Length: 0\r\n\r\n')
response = s.recv()
s.stop()
c.stop()
@@ -58,8 +58,8 @@ class TestShellRunMethods(unittest.TestCase):
def test_malformed_json(self):
json = '{"wrong_param": 0}'
len_json = str(len(json))
- msg = 'POST /shell/run HTTP/1.0\r\nContent-Length:' + len_json + \
- '\r\nContent-Type:application/json\r\n\r\n' + json
+ msg = 'POST /shell/run HTTP/1.0\r\nContent-Length: ' + len_json + \
+ '\r\nContent-Type: application/json\r\n\r\n' + json
c = Client()
s = Server()
s.connect()
@@ -71,17 +71,17 @@ class TestShellRunMethods(unittest.TestCase):
def test_serial_requests(self):
req1_json = '{"run":"echo 1", "echo":true}'
- req1 = 'POST /shell/run HTTP/1.0\r\nContent-Length:'+ \
+ req1 = 'POST /shell/run HTTP/1.0\r\nContent-Length: '+ \
str(len(req1_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + req1_json
+ '\r\nContent-Type: application/json\r\n\r\n' + req1_json
req2_json = '{"run":"echo 2", "echo":true}'
- req2 = 'POST /shell/run HTTP/1.0\r\nContent-Length:'+ \
+ req2 = 'POST /shell/run HTTP/1.0\r\nContent-Length: '+ \
str(len(req2_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + req2_json
+ '\r\nContent-Type: application/json\r\n\r\n' + req2_json
response_json = '{"out": "2\n"}'
- resp = 'HTTP/1.0 200 OK\r\nContent-Length:' + \
+ resp = 'HTTP/1.0 200 OK\r\nContent-Length: ' + \
str(len(response_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + response_json
+ '\r\nContent-Type: application/json\r\n\r\n' + response_json
c = Client()
s = Server()
s.connect()
diff --git a/tests/units/test_0004_hardware.py b/tests/units/test_0004_hardware.py
index 6cfaf77..f2210be 100644
--- a/tests/units/test_0004_hardware.py
+++ b/tests/units/test_0004_hardware.py
@@ -14,8 +14,8 @@ import json
class TestHardwareMethods(unittest.TestCase):
def test_get(self):
- req = 'GET /hardware HTTP/1.0\r\nContent-Length:0\r\n' + \
- 'Content-Type:application/json\r\n\r\n '
+ req = 'GET /hardware HTTP/1.0\r\nContent-Length: 0\r\n' + \
+ 'Content-Type: application/json\r\n\r\n '
c = Client()
s = Server()
s.connect()
diff --git a/tests/units/test_0005_other_requests.py b/tests/units/test_0005_other_requests.py
index 0a4d222..d7f204e 100644
--- a/tests/units/test_0005_other_requests.py
+++ b/tests/units/test_0005_other_requests.py
@@ -14,9 +14,9 @@ class TestOtherRequests(unittest.TestCase):
def test_non_existent_function(self):
post_req = 'POST /this_function_does_not_exist HTTP/1.0\r\n' + \
- 'Content-Length:0\r\nContent-Type:application/json\r\n\r\n'
+ 'Content-Length: 0\r\nContent-Type: application/json\r\n\r\n'
get_req = 'GET /this_function_does_not_exist HTTP/1.0\r\n' + \
- 'Content-Length:0\r\nContent-Type:application/json\r\n\r\n'
+ 'Content-Length: 0\r\nContent-Type: application/json\r\n\r\n'
c = Client()
s = Server()
s.connect()
diff --git a/tests/units/test_0006_run_schedule.py b/tests/units/test_0006_run_schedule.py
index 2b8700d..542c36d 100644
--- a/tests/units/test_0006_run_schedule.py
+++ b/tests/units/test_0006_run_schedule.py
@@ -13,8 +13,8 @@ import unittest
class TestRunScheduleMethods(unittest.TestCase):
def test_get(self):
- req = 'GET /run/schedule HTTP/1.0\r\nContent-Length:0'+ \
- '\r\nContent-Type:application/json\r\n\r\n'
+ req = 'GET /run/schedule HTTP/1.0\r\nContent-Length: 0'+ \
+ '\r\nContent-Type: application/json\r\n\r\n'
c = Client()
s = Server()
s.connect()
diff --git a/tests/units/test_0007_software.py b/tests/units/test_0007_software.py
index 0984c56..4734384 100644
--- a/tests/units/test_0007_software.py
+++ b/tests/units/test_0007_software.py
@@ -15,9 +15,9 @@ class TestSoftwareMethods(unittest.TestCase):
def test_correct_post(self):
req_json = '{"disk": 1, "partition": 1}'
- req = 'POST /software HTTP/1.0\r\nContent-Length:' + \
+ req = 'POST /software HTTP/1.0\r\nContent-Length: ' + \
str(len(req_json)) + \
- '\r\nContent-Type:application/json\r\n\r\n' + req_json
+ '\r\nContent-Type: application/json\r\n\r\n' + req_json
c = Client()
s = Server()
s.connect()
diff --git a/tests/units/test_0008_refresh.py b/tests/units/test_0008_refresh.py
index b8f32d5..4d71a2b 100644
--- a/tests/units/test_0008_refresh.py
+++ b/tests/units/test_0008_refresh.py
@@ -14,8 +14,8 @@ import json
class TestRefreshMethods(unittest.TestCase):
def test_correct_get(self):
- req = 'GET /refresh HTTP/1.0\r\nContent-Length:0\r\n' + \
- 'Content-Type:application/json\r\n\r\n'
+ req = 'GET /refresh HTTP/1.0\r\nContent-Length: 0\r\n' + \
+ 'Content-Type: application/json\r\n\r\n'
c = Client()
s = Server()
s.connect()