aboutsummaryrefslogtreecommitdiffstats
path: root/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
diff options
context:
space:
mode:
authorMariusz Wagner <mariusz.wagner@nokia.com>2018-07-30 14:19:50 +0200
committerMariusz Wagner <mariusz.wagner@nokia.com>2018-07-30 14:36:10 +0200
commit3cbe54761c77812594cf6c497482373e814792c1 (patch)
tree8ffedf6bd1efba888c628eef3bc263f2312275c3 /test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
parent0b8db8f3fb19c3e41a901e76c930e7f2008239f4 (diff)
Cleaning tests
Code refactor and clean TC code Issue-ID: INT-604 Change-Id: I6b47dae37eb3b3897698bab738abcc8aac97d90d Signed-off-by: Mariusz Wagner <mariusz.wagner@nokia.com>
Diffstat (limited to 'test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py')
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
index b5382826b..dd2d19451 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
+++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
@@ -12,9 +12,7 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
global received_event_to_get_method
content_length = int(self.headers['Content-Length'])
received_event_to_get_method = self.rfile.read(content_length)
- self.send_response(200)
- self.send_header('Content-Type', 'application/json')
- self.end_headers()
+ _header_200_and_json(self)
return
@@ -23,35 +21,29 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
global posted_event_from_prh
content_length = int(self.headers['Content-Length'])
posted_event_from_prh = self.rfile.read(content_length)
- self.send_response(200)
- self.send_header('Content-Type', 'application/json')
- self.end_headers()
+ _header_200_and_json(self)
return
def do_GET(self):
if re.search('/events/unauthenticated.SEC_OTHER_OUTPUT/OpenDcae-c12/c12', self.path):
- self.send_response(200)
- self.send_header('Content-Type', 'application/json')
- self.end_headers()
+ _header_200_and_json(self)
self.wfile.write(received_event_to_get_method)
self.wfile.close()
elif re.search('/events/pnfReady', self.path):
- self.send_response(200)
- self.send_header('Content-Type', 'application/json')
- self.end_headers()
+ _header_200_and_json(self)
self.wfile.write(posted_event_from_prh)
self.wfile.close()
- else:
- self.send_response(200)
- self.send_header('Content-Type', 'application/json')
- self.end_headers()
- self.wfile.write('GET else')
- self.wfile.close()
-
+
return
+def _header_200_and_json(self):
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+
+
def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
if sys.argv[1:]: