From 7fdc04f661ac0243ff0f62f213d4709323350dfb Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Thu, 7 Dec 2023 21:33:25 +0300 Subject: [PATCH 1/6] fixed "notes" coverage Signed-off-by: Alexander Piskun --- tests/actual_tests/notes_test.py | 72 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/tests/actual_tests/notes_test.py b/tests/actual_tests/notes_test.py index 49898bbb..be7d1d75 100644 --- a/tests/actual_tests/notes_test.py +++ b/tests/actual_tests/notes_test.py @@ -2,36 +2,33 @@ import pytest -from nc_py_api import NextcloudException +from nc_py_api import NextcloudException, notes -# Currently we test only with the client mode, waiting this to be resolved to use it in Application mode: -# https://github.com/cloud-py-api/app_api/issues/80 - -def test_settings(nc_client): - if nc_client.notes.available is False: +def test_settings(nc_any): + if nc_any.notes.available is False: pytest.skip("Notes is not installed") - original_settings = nc_client.notes.get_settings() + original_settings = nc_any.notes.get_settings() assert isinstance(original_settings["file_suffix"], str) assert isinstance(original_settings["notes_path"], str) - nc_client.notes.set_settings(file_suffix=".ncpa") - modified_settings = nc_client.notes.get_settings() + nc_any.notes.set_settings(file_suffix=".ncpa") + modified_settings = nc_any.notes.get_settings() assert modified_settings["file_suffix"] == ".ncpa" assert modified_settings["notes_path"] == original_settings["notes_path"] - nc_client.notes.set_settings(file_suffix=original_settings["file_suffix"]) - modified_settings = nc_client.notes.get_settings() + nc_any.notes.set_settings(file_suffix=original_settings["file_suffix"]) + modified_settings = nc_any.notes.get_settings() assert modified_settings["file_suffix"] == original_settings["file_suffix"] with pytest.raises(ValueError): - nc_client.notes.set_settings() + nc_any.notes.set_settings() -def test_create_delete(nc_client): - if nc_client.notes.available is False: +def test_create_delete(nc_any): + if nc_any.notes.available is False: pytest.skip("Notes is not installed") unix_timestamp = (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() - new_note = nc_client.notes.create(str(unix_timestamp)) - nc_client.notes.delete(new_note) + new_note = nc_any.notes.create(str(unix_timestamp)) + nc_any.notes.delete(new_note) assert isinstance(new_note.note_id, int) assert isinstance(new_note.etag, str) assert isinstance(new_note.title, str) @@ -43,35 +40,40 @@ def test_create_delete(nc_client): assert str(new_note).find("title=") != -1 -def test_get_update_note(nc_client): - if nc_client.notes.available is False: +def test_get_update_note(nc_any): + if nc_any.notes.available is False: pytest.skip("Notes is not installed") - for i in nc_client.notes.get_list(): - nc_client.notes.delete(i) + for i in nc_any.notes.get_list(): + nc_any.notes.delete(i) - assert not nc_client.notes.get_list() + assert not nc_any.notes.get_list() unix_timestamp = (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() - new_note = nc_client.notes.create(str(unix_timestamp)) + new_note = nc_any.notes.create(str(unix_timestamp)) try: - all_notes = nc_client.notes.get_list() + all_notes = nc_any.notes.get_list() assert all_notes[0] == new_note - assert not nc_client.notes.get_list(etag=True) - assert nc_client.notes.get_list()[0] == new_note - assert nc_client.notes.by_id(new_note) == new_note - updated_note = nc_client.notes.update(new_note, content="content") + assert not nc_any.notes.get_list(etag=True) + assert nc_any.notes.get_list()[0] == new_note + assert nc_any.notes.by_id(new_note) == new_note + updated_note = nc_any.notes.update(new_note, content="content") assert updated_note.content == "content" - all_notes = nc_client.notes.get_list() + all_notes = nc_any.notes.get_list() assert all_notes[0].content == "content" - all_notes_no_content = nc_client.notes.get_list(no_content=True) + all_notes_no_content = nc_any.notes.get_list(no_content=True) assert all_notes_no_content[0].content == "" - assert nc_client.notes.by_id(new_note).content == "content" + assert nc_any.notes.by_id(new_note).content == "content" with pytest.raises(NextcloudException): - assert nc_client.notes.update(new_note, content="should be rejected") - new_note = nc_client.notes.update(new_note, content="should not be rejected", overwrite=True) - nc_client.notes.update(new_note, category="test_category", favorite=True) - new_note = nc_client.notes.by_id(new_note) + assert nc_any.notes.update(new_note, content="should be rejected") + new_note = nc_any.notes.update(new_note, content="should not be rejected", overwrite=True) + nc_any.notes.update(new_note, category="test_category", favorite=True) + new_note = nc_any.notes.by_id(new_note) assert new_note.favorite is True assert new_note.category == "test_category" finally: - nc_client.notes.delete(new_note) + nc_any.notes.delete(new_note) + + +def test_update_note_invalid_param(nc_any): + with pytest.raises(ValueError): + nc_any.notes.update(notes.Note({"id": 0, "etag": "42242"})) From fc15016cea400e5a83364a4e0d70b62af88ae8d8 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Thu, 7 Dec 2023 21:50:17 +0300 Subject: [PATCH 2/6] fixed "notes" coverage (2) Signed-off-by: Alexander Piskun --- tests/actual_tests/notes_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/actual_tests/notes_test.py b/tests/actual_tests/notes_test.py index be7d1d75..3fd8777c 100644 --- a/tests/actual_tests/notes_test.py +++ b/tests/actual_tests/notes_test.py @@ -75,5 +75,7 @@ def test_get_update_note(nc_any): def test_update_note_invalid_param(nc_any): + if nc_any.notes.available is False: + pytest.skip("Notes is not installed") with pytest.raises(ValueError): nc_any.notes.update(notes.Note({"id": 0, "etag": "42242"})) From e45b30d7ca8086bd2d459b801414fd35d46f9e4f Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Thu, 7 Dec 2023 22:28:51 +0300 Subject: [PATCH 3/6] after_n_builds 9 -> 11 Signed-off-by: Alexander Piskun --- .github/.codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.codecov.yml b/.github/.codecov.yml index 1937ecdc..a746e6f4 100644 --- a/.github/.codecov.yml +++ b/.github/.codecov.yml @@ -1,6 +1,6 @@ codecov: notify: - after_n_builds: 9 + after_n_builds: 11 comment: require_changes: true From 910f248c307658a53a611a40fc3cfc5ce101f1ff Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Thu, 7 Dec 2023 22:30:13 +0300 Subject: [PATCH 4/6] speed up Oracle coverage Signed-off-by: Alexander Piskun --- .github/workflows/analysis-coverage.yml | 38 +++++++++++-------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/analysis-coverage.yml b/.github/workflows/analysis-coverage.yml index 015d3531..55e3fb6a 100644 --- a/.github/workflows/analysis-coverage.yml +++ b/.github/workflows/analysis-coverage.yml @@ -360,13 +360,7 @@ jobs: tests-oci: needs: [analysis] runs-on: ubuntu-22.04 - name: ${{ matrix.nextcloud }} • 🐘${{ matrix.php-version }} • 🐍${{ matrix.python }} • OCI - strategy: - fail-fast: false - matrix: - nextcloud: [ "27.1.4" ] - python: [ "3.11" ] - php-version: [ "8.2" ] + name: stable27 • 🐘8.1 • 🐍3.11 • OCI services: oracle: @@ -387,28 +381,30 @@ jobs: - name: Set up php uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: '8.1' extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, \ posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, oci8 - uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: '3.11' - - name: cache-nextcloud - id: nextcloud_setup - uses: actions/cache@v3 + - name: Checkout server + uses: actions/checkout@v4 with: - path: nextcloud-${{ matrix.nextcloud }}.tar.bz2 - key: ${{ matrix.nextcloud }} + submodules: true + repository: nextcloud/server + ref: 'stable27' - - name: Download Nextcloud - if: steps.nextcloud_setup.outputs.cache-hit != 'true' - run: wget -q https://download.nextcloud.com/server/releases/nextcloud-${{ matrix.nextcloud }}.tar.bz2 + - name: Checkout Notifications + uses: actions/checkout@v4 + with: + repository: nextcloud/notifications + ref: 'stable27' + path: apps/notifications - name: Set up Nextcloud run: | - tar -xjf nextcloud-${{ matrix.nextcloud }}.tar.bz2 --strip-components 1 mkdir data php occ maintenance:install --verbose --database=oci --database-name=XE \ --database-host=127.0.0.1 --database-port=1521 --database-user=useroracle --database-pass=userpassword \ @@ -457,7 +453,7 @@ jobs: - name: HTML coverage to artifacts uses: actions/upload-artifact@v3 with: - name: coverage_oci_${{ matrix.nextcloud }}_${{ matrix.python }}_${{ matrix.php-version }} + name: coverage_oci_stable27_3.11_8.1 path: nc_py_api/htmlcov if-no-files-found: error @@ -465,7 +461,7 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - name: coverage_oci_${{ matrix.nextcloud }}_${{ matrix.python }}_${{ matrix.php-version }} + name: coverage_oci_stable27_3.11_8.1 file: coverage.xml fail_ci_if_error: true verbose: true @@ -475,7 +471,7 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: nc_log_oci_${{ matrix.nextcloud }}_${{ matrix.python }}_${{ matrix.php-version }} + name: nc_log_oci_stable27_3.11_8.1 path: data/nextcloud.log if-no-files-found: warn From 535470d99d47f5fd9723ee90d35f49e9732faa0d Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Fri, 8 Dec 2023 10:50:47 +0300 Subject: [PATCH 5/6] added icon Signed-off-by: Alexander Piskun --- .github/workflows/analysis-coverage.yml | 4 +- img/icon.svg | 1188 +++++++++++++++++++++++ 2 files changed, 1190 insertions(+), 2 deletions(-) create mode 100644 img/icon.svg diff --git a/.github/workflows/analysis-coverage.yml b/.github/workflows/analysis-coverage.yml index 55e3fb6a..184d3448 100644 --- a/.github/workflows/analysis-coverage.yml +++ b/.github/workflows/analysis-coverage.yml @@ -357,7 +357,7 @@ jobs: path: data/nextcloud.log if-no-files-found: warn - tests-oci: + tests-stable27-oci: needs: [analysis] runs-on: ubuntu-22.04 name: stable27 • 🐘8.1 • 🐍3.11 • OCI @@ -927,7 +927,7 @@ jobs: permissions: contents: none runs-on: ubuntu-22.04 - needs: [tests-maria, tests-pgsql, tests-oci, tests-latest-maria, test-latest-pgsql, tests-client-sqlite] + needs: [tests-maria, tests-pgsql, tests-stable27-oci, tests-latest-maria, test-latest-pgsql, tests-client-sqlite] name: Tests-OK steps: - run: echo "Tests passed successfully" diff --git a/img/icon.svg b/img/icon.svg new file mode 100644 index 00000000..c13b8598 --- /dev/null +++ b/img/icon.svg @@ -0,0 +1,1188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 438225bf2110f0ebd7b3478bdfe5195f1dd090c5 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Fri, 8 Dec 2023 11:04:42 +0300 Subject: [PATCH 6/6] added check for "appid" and method str() Signed-off-by: Alexander Piskun --- tests/actual_tests/ui_files_actions_test.py | 2 ++ tests/actual_tests/ui_top_menu_test.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/actual_tests/ui_files_actions_test.py b/tests/actual_tests/ui_files_actions_test.py index 0b69aac4..e214760b 100644 --- a/tests/actual_tests/ui_files_actions_test.py +++ b/tests/actual_tests/ui_files_actions_test.py @@ -13,6 +13,7 @@ def test_register_ui_file_actions(nc_app): assert result.permissions == 31 assert result.order == 0 assert result.icon == "" + assert result.appid == "nc_py_api" nc_app.ui.files_dropdown_menu.unregister(result.name) nc_app.ui.files_dropdown_menu.register("test_ui_action_any", "UI TEST", "ui_action", permissions=1, order=1) result = nc_app.ui.files_dropdown_menu.get_entry("test_ui_action_any") @@ -33,6 +34,7 @@ def test_register_ui_file_actions(nc_app): assert result.order == 0 assert result.icon == "img/icon.svg" nc_app.ui.files_dropdown_menu.unregister(result.name) + assert str(result).find("name=test_ui_action") def test_unregister_ui_file_actions(nc_app): diff --git a/tests/actual_tests/ui_top_menu_test.py b/tests/actual_tests/ui_top_menu_test.py index cee885ba..4753b24e 100644 --- a/tests/actual_tests/ui_top_menu_test.py +++ b/tests/actual_tests/ui_top_menu_test.py @@ -10,6 +10,7 @@ def test_register_ui_top_menu(nc_app): assert result.display_name == "Disp name" assert result.icon == "" assert result.admin_required is False + assert result.appid == "nc_py_api" nc_app.ui.top_menu.unregister(result.name) assert nc_app.ui.top_menu.get_entry("test_name") is None nc_app.ui.top_menu.unregister(result.name) @@ -29,3 +30,4 @@ def test_register_ui_top_menu(nc_app): assert result.admin_required is False nc_app.ui.top_menu.unregister(result.name) assert nc_app.ui.top_menu.get_entry("test_name") is None + assert str(result).find("name=test_name")