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 d154de0..0000000 Binary files a/test_api/__pycache__/runner.cpython-38.pyc and /dev/null differ 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 085acef..0000000 Binary files a/test_api/apitest/__pycache__/__init__.cpython-38.pyc and /dev/null differ 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 b56094e..0000000 Binary files a/test_api/apitest/__pycache__/constants.cpython-38.pyc and /dev/null differ diff --git a/test_api/apitest/__pycache__/logger.cpython-38.pyc b/test_api/apitest/__pycache__/logger.cpython-38.pyc deleted file mode 100644 index 4f062f1..0000000 Binary files a/test_api/apitest/__pycache__/logger.cpython-38.pyc and /dev/null differ diff --git a/test_api/apitest/__pycache__/runner.cpython-38.pyc b/test_api/apitest/__pycache__/runner.cpython-38.pyc deleted file mode 100644 index 2d8ebed..0000000 Binary files a/test_api/apitest/__pycache__/runner.cpython-38.pyc and /dev/null differ 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 028aec3..0000000 Binary files a/test_api/apitest/__pycache__/zero.cpython-38.pyc and /dev/null differ 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')