From d5bcc3517593dcd6ed889b7127fa80c6febc686b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 20 Jun 2020 10:27:43 +0000 Subject: [PATCH 1/2] Fixes 01 --- .gitignore | 51 ++++++++++++++ .idea/.gitignore | 3 - .idea/inspectionProfiles/Project_Default.xml | 47 ------------- .../inspectionProfiles/profiles_settings.xml | 6 -- .idea/misc.xml | 4 -- .idea/modules.xml | 8 --- .idea/openlp-api-tester.iml | 11 ---- test_api/apitest/runner.py | 66 +++++++++++++++---- test_api/runner.py | 3 +- x1.py | 56 ---------------- 10 files changed, 105 insertions(+), 150 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/openlp-api-tester.iml delete mode 100644 x1.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ed3205 --- /dev/null +++ b/.gitignore @@ -0,0 +1,51 @@ +*.*~ +*.dll +*.e4* +*.kate-swp +*.kdev4 +*.komodoproject +*.log* +*.nja +*.orig +*.pyc +*.qm +*.rej +*.ropeproject +*.~\?~ +*eric[1-9]project +.cache +.coverage +.directory +.eggs +.idea +.kdev4 +.komodotools +.pytest_cache +.venv +.vscode +.eggs +.venv +.mypy_cache +OpenLP.egg-info +\#*\# +__pycache__ +build +cover +coverage +dist +env +htmlcov +list +node_modules +openlp.cfg +openlp.pro +openlp/core/resources.py +openlp/core/resources.py.old +openlp/plugins/presentations/lib/vendor/Pyro4 +openlp/plugins/presentations/lib/vendor/serpent.py +output +package-lock.json +tags +test +openlp-test-projectordb.sqlite +*/test-results.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 8f2739c..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index d4fc832..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0a7a2bf..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/openlp-api-tester.iml b/.idea/openlp-api-tester.iml deleted file mode 100644 index 8dc09e5..0000000 --- a/.idea/openlp-api-tester.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/test_api/apitest/runner.py b/test_api/apitest/runner.py index 26ced4a..dc8011d 100644 --- a/test_api/apitest/runner.py +++ b/test_api/apitest/runner.py @@ -23,11 +23,13 @@ import requests import string import time import random +import threading +import websocket from websocket import create_connection from test_api.apitest.constants import BookNames -from test_api.apitest.logger import print_text, print_error, print_ok +from test_api.apitest.logger import print_text, print_error, print_ok, print_info class RunTestsController(object): @@ -37,7 +39,41 @@ class RunTestsController(object): self.http_port = http_port self.ws_port = ws_port self.reserved_result_stage = None - self.reserved_result_live = None + self.received = False + + def connect(self) -> None: + print_info("Starting thread") + self.ws = websocket.WebSocketApp(f'ws://{self.address}:{self.ws_port}', + on_message=self.on_message, + on_close=self.on_close, + on_open=self.on_open, + on_error=self.on_error, + ) + self.wst = threading.Thread(target=lambda: self.ws.run_forever()) + self.wst.daemon = True + self.wst.start() + + conn_timeout = 5 + while (not self.ws.sock or not self.ws.sock.connected) and conn_timeout: + human_delay(1) + conn_timeout -= 1 + if not conn_timeout: + print_error("Could not connect to WS! Exiting.") + + def on_message(self, message: str) -> None: + print_info("Message returned") + self.result_stage = message + self.compare_stage() + self.received = True + + def on_open(self) -> None: + print_info("opened") + + def on_close(self) -> None: + print_info("closed") + + def on_error(self, error: str) -> None: + print_error(f'WebSocket Error: {error}') def load_and_check_sockets(self, first_run: bool = False) -> bool: ws = create_connection(f'ws://{self.address}:{self.ws_port}') @@ -61,16 +97,18 @@ class RunTestsController(object): """ :return: """ - self.stage_diff = {} - reserved = json.loads(self.reserved_result_stage.decode('utf-8'))['results'] - current = json.loads(self.result_stage.decode('utf-8'))['results'] - # compare_strings(reserved, current) - assert len(reserved) == len(current) - for a, _ in current.items(): - # compare_strings(reserved[a], current[a]) - if reserved[a] != current[a]: - self.stage_diff[a] = {'before': reserved[a], 'after': current[a]} - self.reserved_result_stage = self.result_stage + if self.received: + self.stage_diff = {} + reserved = json.loads(self.reserved_result_stage.decode('utf-8'))['results'] + current = json.loads(self.result_stage.decode('utf-8'))['results'] + self.received = False + # compare_strings(reserved, current) + assert len(reserved) == len(current) + for a, _ in current.items(): + # compare_strings(reserved[a], current[a]) + if reserved[a] != current[a]: + self.stage_diff[a] = {'before': reserved[a], 'after': current[a]} + self.reserved_result_stage = self.result_stage def marshal_full(self): print_ok('Running full test script') @@ -295,8 +333,8 @@ def live_item(rtc: RunTestsController, plugin: str) -> None: def check_websocket_changes(rtc: RunTestsController, manditary: int, optional: int) -> None: - rtc.load_and_check_sockets() - rtc.compare_stage() + while not rtc.received: + time.sleep(0.1) if manditary <= len(rtc.stage_diff) <= optional: pass else: diff --git a/test_api/runner.py b/test_api/runner.py index 78fdd82..9cb6426 100644 --- a/test_api/runner.py +++ b/test_api/runner.py @@ -29,7 +29,7 @@ def start() -> None: Instantiate and run the tests. :return: """ - print_text('OpenLP - API Test Runner V0_1') + print_text('OpenLP - API Test Runner V0_2') print_text('Check OpenLP is running') op_address, op_http_port = check_for_openlp('http') if not op_http_port: @@ -41,6 +41,7 @@ def start() -> None: print_ok(f'OpenLP is running network Address {op_address}') print_ok(f'OpenLP is running on port (ws) {op_ws_port}') rtc = RunTestsController(op_address, op_http_port, op_ws_port) + rtc.connect() rtc.marshal_full() #nrtc.marshal_media() print_text('Finished running tests') diff --git a/x1.py b/x1.py deleted file mode 100644 index ca80eca..0000000 --- a/x1.py +++ /dev/null @@ -1,56 +0,0 @@ -import websocket -import ssl -import sys -from time import sleep -import threading - - -class MyWebSocket(): - def connect(self, wsURL="wss://www.bitmex.com/realtime?subscribe=quote:XBTUSD"): - print("Starting thread") - ssl_defaults = ssl.get_default_verify_paths() - sslopt_ca_certs = {"ca_certs": ssl_defaults.cafile} - self.ws = websocket.WebSocketApp(wsURL, - on_message=self.__on_message, - on_close=self.__on_close, - on_open=self.__on_open, - on_error=self.__on_error, - ) - self.wst = threading.Thread(target=lambda: self.ws.run_forever(sslopt=sslopt_ca_certs)) - self.wst.daemon = True - self.wst.start() - - conn_timeout = 5 - while (not self.ws.sock or not self.ws.sock.connected) and conn_timeout: - sleep(1) - conn_timeout -= 1 - if not conn_timeout: - print("Could not connect to WS! Exiting.") - sys.exit(1) - - def __on_message(self, message): - print(message) - - def __on_open(self): - print("opened") - - def __on_close(self): - print("closed") - - def __on_error(self, error): - print("error") - - def run(self): - self.connect() - while True: - print("hello mum") - sleep(1) - -websocket.enableTrace(True) -mysocket = MyWebSocket() -mysocket.run() -#mysocket.connect() - -#while True:# -# sleep(1) -print("the end") \ No newline at end of file From 26cbcb96b1208647c9ce9ec01015623c64fe1536 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 21 Jun 2020 08:57:12 +0000 Subject: [PATCH 2/2] Fixes2 --- .gitlab-ci.yml | 6 +++++ requirements.txt | 3 +++ setup.cfg | 3 +++ test_api/__pycache__/runner.cpython-38.pyc | Bin 1036 -> 0 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 163 -> 0 bytes .../__pycache__/constants.cpython-38.pyc | Bin 797 -> 0 bytes .../apitest/__pycache__/logger.cpython-38.pyc | Bin 1013 -> 0 bytes .../apitest/__pycache__/runner.cpython-38.pyc | Bin 9772 -> 0 bytes .../apitest/__pycache__/zero.cpython-38.pyc | Bin 1641 -> 0 bytes test_api/apitest/constants.py | 4 +-- test_api/apitest/logger.py | 4 +++ test_api/apitest/runner.py | 24 +++++++++--------- test_api/runner.py | 2 +- 13 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 requirements.txt create mode 100644 setup.cfg delete mode 100644 test_api/__pycache__/runner.cpython-38.pyc delete mode 100644 test_api/apitest/__pycache__/__init__.cpython-38.pyc delete mode 100644 test_api/apitest/__pycache__/constants.cpython-38.pyc delete mode 100644 test_api/apitest/__pycache__/logger.cpython-38.pyc delete mode 100644 test_api/apitest/__pycache__/runner.cpython-38.pyc delete mode 100644 test_api/apitest/__pycache__/zero.cpython-38.pyc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..dbb371b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,6 @@ +lint-python: + stage: test + image: python:latest + script: + - pip install tox flake8 + - flake8 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..acf673b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +colorama==0.4.1 +websocket-client==0.56.0 + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..58bf450 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 120 +ignore = E402,W503,W504,D diff --git a/test_api/__pycache__/runner.cpython-38.pyc b/test_api/__pycache__/runner.cpython-38.pyc deleted file mode 100644 index d154de008e84a26597c9e8b17b4c8e2a261615d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1036 zcmZuwPiqu06i?>Q?(BA3M05*^7<+P{yQ>E;MT(^$7D_EvJq%(PHfeXLbqz?DiMYn{@zq;3!N(^RTV4@ISz4kZ8+k?F+G)v%AAWd2jBG<6Y-L3qxYpS zN~S4SN8oNKZYD|$E&Ou$pm;F%Vd{?{3{aV4Y*(jVF>~kmjWa_tTw=X#9OhX+^G}d* zS);_C(br{Wv(9v8E<}P7ts*XKmF~*&N>t*~ox3xy^uGDufjI2eUZRF;#iKTXaUisb zg-K$=Nh}yq6G6;~6Jx3M>y(`ZrJdR+?mUMM93GP%**iWUwgUt@A-E#1AJB)z=Duwe zIZsNo1r&)mi@cFBdC|QH2x*ohVR%bq_)}$(>gfSwHdj}41Xd8w;TQ49gJkg2PVk|$4b8AL!$?aS_iVe zR=qe+dbaai4eUa}9@utp)z3dvJ{*-Yw*gAu0)hMh2e^Yhke;&v+6H_b95`wXqE$d? z7AJzzupMnK;rak+^?oYP&fuokj8|l%n^*D*4zIzsM-U}@{R0p)hwjc$Pd0Zx+`IsgCw diff --git a/test_api/apitest/__pycache__/__init__.cpython-38.pyc b/test_api/apitest/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 085acef1b70076f21e57f5d24f8296eda4954acb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmWIL<>g`kg2dJpaUl9Jh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6v5KO;XkRlg)N zS3jUAKPxr4q*&j-AT`e?KtCTytHEAe- diff --git a/test_api/apitest/__pycache__/constants.cpython-38.pyc b/test_api/apitest/__pycache__/constants.cpython-38.pyc deleted file mode 100644 index b56094ef9ce9fb608634fd86a35dd478e035d886..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 797 zcmbVK%W@Jy6dmY+JQUwXjqkUpWE|q#7z2b#fRU=&bXrc)eLK*^Q*>*7L_Ed1js$0IN#S)( zNvxszJlmnzPNb&v)APpM?y7LW*`B7*hKxwt6s~`fBhI!($l0!)y?fpp?w;Lxpol+?1bKapXx z<0vxYNl8qGrC91%MvgHb$aiQP?szKHu?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M{-X_LdRgN_@!!X@pk&n zqCP$-Ow8Diab$ZBYwj=cciSQI#dke?MCohpRM1T`8w6SY@=@WFMm5oUzL?T*vKQGT zLXfDOo7F2u%QFhX(a5D|2#F;bii5mJ96fDOGY6CVRHBt~) zF!K^5??CoN(4r=3+z_!R8GJete%z4wuY|BmCs>W(By=a2M|gv^;rl4ygQLQq{BhF5 zca=Wov~V76;3#MZ>DoX8eRa30DjltJA;!@Q3?3hwK{XgNk0r#w#!sIu@d4;%`u@KK zlWtzt3hyyD!=kkTr%d`EmGxyLcDMHjT;}n%;#5S%)&w8D1PoVrX*a#DE~&!ohQ@J>*LHqgP^u8}z>>e6-33ayUYVR&rFiLZj$- zMABITXUS>mNjqlXD9Lk6jzc%7MAGLiO>LhUL7*~muBB(l*H=)BNXOH!f1rpCd2LxQ XwVcwDQF8b%Q_3%|ESHxGON;*pJY}V# diff --git a/test_api/apitest/__pycache__/zero.cpython-38.pyc b/test_api/apitest/__pycache__/zero.cpython-38.pyc deleted file mode 100644 index 028aec3f527b4f2ee0a381cdf674d3f55c6a21d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1641 zcma)6O>Y}T7@m*a_1bZQDWSjtutX(fiP$Y1kWf@AsDxA%Qz_!I2Ugb3IN5YR+?h$M zSkB4$6VO&lj`;~3`5SxX#EE-PJnybeot`q*yfd@jdFOea_nG~5d%MHX{@wlSx1!D1 z-?Z3l5{n1u_922|if1gMQDi(9k;r8vIjv>p<$mPXb1w_>R@CB5hdNaLE1?3_I`^Ws z;s|R10$(D?dw1XO1_fHQ~tTP zt7usASOT-2G0U_ui zD7IiR2qOXsvWoG%eedgUhj;P2N5aiYZT)CKB^3cqBpAvYNjGRX0paOJZ8 ze7kRSUOv~V52^cxGMM)$kOocI#;n?DUW?&Lvga3gW=U-(=HJ|i%k}+9tpx2yqeK6P zKE`6fFJQWbyc94Y2Mt-%@YXaI-Z3nx>d9*fM#lUDQqsY%N?liP|eyX=~_XGVsk7B_Utd6>QRZgy3DNx3G16{+D>))?Xvu z<-6!zKEHb-y*HAK2W|2pStgFFP8{c@I>~6>jpJu0ldSp2?BKAf3x+ODa_x>vWyn?L zLkb^IAYX03tvyoPqx1Gseuj5!h!FD76MR>iPqC5KaI21N5Ig58=z`Dy>~St43-EozS9eE1$Q~{ zanr|>LC4(2&=jYJLA3E*O>^BK`e=Q>hpYPy5{HM{G|s5?p+p-f-bxehH*(*nGgiX% Icvp1gfAU|9p#T5? diff --git a/test_api/apitest/constants.py b/test_api/apitest/constants.py index a9d0df7..f9865c5 100644 --- a/test_api/apitest/constants.py +++ b/test_api/apitest/constants.py @@ -18,8 +18,8 @@ # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # ########################################################################## -BookNames = ['Gen', 'Exod', 'Lev', 'Num', 'Deut', 'Josh', 'Judg', 'Ruth', '1Sam', '2Sam', '1Kgs', '2Kgs', '1Chr', +BookNames = ['Gen', 'Exod', 'Lev', 'Num', 'Deut', 'Josh', 'Judg', 'Ruth', '1Sam', '2Sam', '1Kgs', '2Kgs', '1Chr', '2Chr', 'Esra', 'Neh', 'Esth', 'Job', 'Ps', 'Prov', 'Eccl', 'Song', 'Isa', 'Jer', 'Lam', 'Ezek', 'Dan', 'Hos', 'Joel', 'Amos', 'Obad', 'Jonah', 'Mic', 'Nah', 'Hab', 'Zeph', 'Hag', 'Zech', 'Mal', 'Matt', 'Mark', 'Luke', 'John', 'Acts', 'Rom', '1Cor', '2Cor', 'Gal', 'Eph', 'Phil', 'Col', '1Thess', '2Thess', '1Tim', - '2Tim', 'Titus', 'Phlm', 'Heb', 'Jas', '1Pet', '2Pet', '1John', '2John', '3John', 'Jude', 'Rev'] + '2Tim', 'Titus', 'Phlm', 'Heb', 'Jas', '1Pet', '2Pet', '1John', '2John', '3John', 'Jude', 'Rev'] diff --git a/test_api/apitest/logger.py b/test_api/apitest/logger.py index 370e610..cf7133e 100644 --- a/test_api/apitest/logger.py +++ b/test_api/apitest/logger.py @@ -40,3 +40,7 @@ def print_warn(text: str): def print_info(text: str): print(Fore.MAGENTA + '[!] = ' + text) + + +def print_debug(text: str): + print(Fore.CYAN + '[#] = ' + text) diff --git a/test_api/apitest/runner.py b/test_api/apitest/runner.py index dc8011d..c39e39b 100644 --- a/test_api/apitest/runner.py +++ b/test_api/apitest/runner.py @@ -28,8 +28,8 @@ import websocket from websocket import create_connection from test_api.apitest.constants import BookNames - from test_api.apitest.logger import print_text, print_error, print_ok, print_info +# from test_api.apitest.logger import print_debug class RunTestsController(object): @@ -61,7 +61,7 @@ class RunTestsController(object): print_error("Could not connect to WS! Exiting.") def on_message(self, message: str) -> None: - print_info("Message returned") + # print_debug("Message returned") self.result_stage = message self.compare_stage() self.received = True @@ -128,10 +128,10 @@ class RunTestsController(object): print_ok('Running media test script') if self.load_and_check_sockets(True): clear_controllers(self) - #search_and_live(self, 'songs', 1) - #media_play(self) - #human_delay() - #clear_controllers(self) + # search_and_live(self, 'songs', 1) + # media_play(self) + # human_delay() + # clear_controllers(self) search_and_live(self, 'media', 1) media_play(self) human_delay(5) @@ -256,7 +256,7 @@ def search_and_live(rtc: RunTestsController, plugin: str, count: int) -> None: random_service = [random.randint(1, limit) for itr in range(count)] for pos in random_service: item = items[pos - 1] - ret = requests.post(base_url + f'live', json=dict(id=item[0])) + ret = requests.post(base_url + 'live', json=dict(id=item[0])) assert ret.status_code == 204, f'{ret.status_code} returned from add' human_delay() @@ -265,7 +265,7 @@ def search_and_add(rtc: RunTestsController, plugin: str, count: int) -> None: print_text(f'Search_and_add for {plugin}') base_url = f'http://{rtc.address}:{rtc.http_port}/api/v2/plugins/{plugin}/' if plugin == 'bibles': - for i in range(1, count): + for i in range(1, count): bk_id = random.randint(1, len(BookNames) - 1) bk = BookNames[bk_id] ch = random.randint(1, 10) @@ -275,7 +275,7 @@ def search_and_add(rtc: RunTestsController, plugin: str, count: int) -> None: assert ret.status_code == 200, f'{ret.status_code} returned from searcg' items = json.loads(ret.text) if items: - ret = requests.post(base_url + f'add', json=dict(id=items[0][0])) + ret = requests.post(base_url + 'add', json=dict(id=items[0][0])) assert ret.status_code == 204, f'{ret.status_code} returned from add' human_delay() else: @@ -297,7 +297,7 @@ def search_and_add(rtc: RunTestsController, plugin: str, count: int) -> None: random_service = [random.randint(1, limit) for itr in range(count)] for pos in random_service: item = items[pos - 1] - ret = requests.post(base_url + f'add', json=dict(id=item[0])) + ret = requests.post(base_url + 'add', json=dict(id=item[0])) assert ret.status_code == 204, f'{ret.status_code} returned from add' human_delay() @@ -319,13 +319,13 @@ def live_item(rtc: RunTestsController, plugin: str) -> None: print_text(f'test_live_item - {plugin}') base_url = f'http://{rtc.address}:{rtc.http_port}/api/v2/' ret = requests.get(base_url + 'controller/live-item') - assert ret.status_code == 200 + assert ret.status_code == 200, f'{ret.status_code} returned from live_item' i = 0 for _ in json.loads(ret.text): ret = requests.post(base_url + 'controller/show', json=dict(id=i)) i += 1 human_delay() - assert ret.status_code == 204 + assert ret.status_code == 204, f'{ret.status_code} returned from show' if plugin in {'image'}: check_websocket_changes(rtc, 0, 0) else: diff --git a/test_api/runner.py b/test_api/runner.py index 9cb6426..286cb15 100644 --- a/test_api/runner.py +++ b/test_api/runner.py @@ -43,7 +43,7 @@ def start() -> None: rtc = RunTestsController(op_address, op_http_port, op_ws_port) rtc.connect() rtc.marshal_full() - #nrtc.marshal_media() + # nrtc.marshal_media() print_text('Finished running tests')