diff options
author | Mariusz Wagner <mariusz.wagner@nokia.com> | 2018-07-30 14:19:50 +0200 |
---|---|---|
committer | Mariusz Wagner <mariusz.wagner@nokia.com> | 2018-07-30 14:36:10 +0200 |
commit | 3cbe54761c77812594cf6c497482373e814792c1 (patch) | |
tree | 8ffedf6bd1efba888c628eef3bc263f2312275c3 /test/csit/tests/dcaegen2/prh-testcases/resources/simulator | |
parent | 0b8db8f3fb19c3e41a901e76c930e7f2008239f4 (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')
4 files changed, 17 insertions, 34 deletions
diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py index d5deacaa9..ca8bdd1f6 100644 --- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py +++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py @@ -11,9 +11,7 @@ class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler): global pnfs content_length = int(self.headers['Content-Length']) pnfs = 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 @@ -28,14 +26,11 @@ class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler): return - def do_GET(self): - self.send_response(200) - self.send_header('Content-Type', 'application/json') - self.end_headers() - self.wfile.write('GET') - 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=AAIHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"): diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator index d647207fc..9566c47a9 100644 --- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator +++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator @@ -1,7 +1,5 @@ FROM python:2 -ENV https_proxy "$https_proxy" - ADD AAI.py / RUN pip install robotframework 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:]: diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator index 37da1c7c1..20761e7e8 100644 --- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator +++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator @@ -1,7 +1,5 @@ FROM python:2 -ENV https_proxy "$https_proxy" - ADD DMaaP.py / RUN pip install robotframework |