Skip to content

Commit a7e0d78

Browse files
committed
dev: fixed tests with Oracle(2)
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 442ebf8 commit a7e0d78

File tree

8 files changed

+27
-17
lines changed

8 files changed

+27
-17
lines changed

nc_py_api/preferences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, session: NcSessionBasic):
1313
self._session = session
1414

1515
@property
16-
def avalaible(self) -> bool:
16+
def available(self) -> bool:
1717
return not check_capabilities("provisioning_api", self._session.capabilities)
1818

1919
def set(self, app_name: str, key: str, value: str) -> None:

nc_py_api/users_statuses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, session: NcSessionBasic):
3737
self._session = session
3838

3939
@property
40-
def avalaible(self) -> bool:
40+
def available(self) -> bool:
4141
return not check_capabilities("user_status", self._session.capabilities)
4242

4343
def get_all(self, limit: Optional[int] = None, offset: Optional[int] = None) -> list[UserStatus]:

tests/apps_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22

3+
from nc_py_api import Nextcloud
4+
35
from gfixture import NC_TO_TEST
46

57
APP_NAME = "files_trashbin"
@@ -19,6 +21,7 @@ def test_list_apps(nc):
1921
assert APP_NAME in apps
2022

2123

24+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
2225
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
2326
def test_enable_disable_app(nc):
2427
assert nc.apps.is_installed(APP_NAME)

tests/groups_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import pytest
22

3-
from nc_py_api import NextcloudException
3+
from nc_py_api import NextcloudException, Nextcloud
44

55
from gfixture import NC_TO_TEST
66

77
TEST_GROUP_NAME = "test_coverage_group"
88

99

10+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
1011
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
1112
def test_create_delete_group(nc):
1213
try:
@@ -21,6 +22,7 @@ def test_create_delete_group(nc):
2122
nc.users_groups.delete(TEST_GROUP_NAME)
2223

2324

25+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
2426
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
2527
def test_list_group(nc):
2628
try:
@@ -44,6 +46,7 @@ def test_list_group(nc):
4446
nc.users_groups.delete(TEST_GROUP_NAME + "2")
4547

4648

49+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
4750
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
4851
def test_group_members_promote_demote(nc):
4952
try:

tests/logs_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_loglvl_equal():
4343

4444
@pytest.mark.skipif(AE_CAPABILITIES.get("loglevel", LogLvl.FATAL) == LogLvl.DEBUG, reason="Log lvl to low")
4545
def test_loglvl_less():
46-
with mock.patch("gfixture.nc_app._session._ocs") as _ocs:
46+
with mock.patch("gfixture.NC_APP._session._ocs") as _ocs:
4747
NC_APP.log(int(AE_CAPABILITIES["loglevel"]) - 1, "will not be sent")
4848
_ocs.assert_not_called()
4949
NC_APP.log(AE_CAPABILITIES["loglevel"], "will be sent")
@@ -56,7 +56,7 @@ def test_log_without_app_ecosystem_v2():
5656
log_lvl = srv_capabilities["app_ecosystem_v2"].pop("loglevel")
5757
srv_capabilities.pop("app_ecosystem_v2")
5858
patched_capabilities = {"capabilities": srv_capabilities, "version": srv_version}
59-
with mock.patch.dict("gfixture.nc_app._session._capabilities", patched_capabilities, clear=True):
60-
with mock.patch("gfixture.nc_app._session._ocs") as _ocs:
59+
with mock.patch.dict("gfixture.NC_APP._session._capabilities", patched_capabilities, clear=True):
60+
with mock.patch("gfixture.NC_APP._session._ocs") as _ocs:
6161
NC_APP.log(log_lvl, "will not be sent")
6262
_ocs.assert_not_called()

tests/preferences_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66

77

88
@pytest.mark.parametrize("nc", NC_TO_TEST)
9-
def test_avalaible(nc):
10-
assert nc.preferences_api.avalaible
9+
def test_available(nc):
10+
assert nc.preferences_api.available
1111

1212

1313
@pytest.mark.parametrize("nc", NC_TO_TEST)
1414
def test_preferences_set(nc):
15-
if not nc.preferences_api.avalaible:
16-
pytest.skip("preferences_api is not avalaible")
15+
if not nc.preferences_api.available:
16+
pytest.skip("preferences_api is not available")
1717
nc.preferences_api.set("dav", key="user_status_automation", value="yes")
1818
with pytest.raises(NextcloudException):
1919
nc.preferences_api.set("non_existing_app", "some_cfg_name", "2")
2020

2121

2222
@pytest.mark.parametrize("nc", NC_TO_TEST)
2323
def test_preferences_delete(nc):
24-
if not nc.preferences_api.avalaible:
25-
pytest.skip("preferences_api is not avalaible")
24+
if not nc.preferences_api.available:
25+
pytest.skip("preferences_api is not available")
2626
nc.preferences_api.delete("dav", key="user_status_automation")
2727
with pytest.raises(NextcloudException):
2828
nc.preferences_api.delete("non_existing_app", "some_cfg_name")

tests/users_statuses_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99
@pytest.mark.parametrize("nc", NC_TO_TEST)
10-
def test_avalaible(nc):
11-
assert nc.users_statuses.avalaible
10+
def test_available(nc):
11+
assert nc.users_statuses.available
1212

1313

1414
def compare_user_statuses(p1, p2):
@@ -36,8 +36,8 @@ def test_get_status(nc, message):
3636
assert not r1["messageIsPredefined"]
3737

3838

39-
@pytest.mark.parametrize("nc", NC_TO_TEST)
4039
@pytest.mark.skipif(NC_VERSION.get("major", 0) < 27, reason="NC27 required.")
40+
@pytest.mark.parametrize("nc", NC_TO_TEST)
4141
def test_get_predefined(nc):
4242
r = nc.users_statuses.get_predefined()
4343
assert isinstance(r, list)
@@ -89,9 +89,9 @@ def test_set_status_type(nc, value):
8989
assert r["statusIsUserDefined"]
9090

9191

92+
@pytest.mark.skipif(NC_VERSION.get("major", 0) < 27, reason="NC27 required.")
9293
@pytest.mark.parametrize("nc", NC_TO_TEST)
9394
@pytest.mark.parametrize("clear_at", (None, int(time()) + 360))
94-
@pytest.mark.skipif(NC_VERSION.get("major", 0) < 27, reason="NC27 required.")
9595
def test_set_predefined(nc, clear_at):
9696
predefined_statuses = nc.users_statuses.get_predefined()
9797
for i in predefined_statuses:

tests/users_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from nc_py_api import NextcloudException
3+
from nc_py_api import NextcloudException, Nextcloud
44

55
from gfixture import NC_TO_TEST
66

@@ -21,6 +21,7 @@ def test_get_user_404(nc):
2121
nc.users.get("non existing user")
2222

2323

24+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
2425
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
2526
def test_create_user(nc):
2627
try:
@@ -32,6 +33,7 @@ def test_create_user(nc):
3233
nc.users.create(TEST_USER_NAME, password=TEST_USER_PASSWORD)
3334

3435

36+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
3537
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
3638
def test_delete_user(nc):
3739
try:
@@ -43,6 +45,7 @@ def test_delete_user(nc):
4345
nc.users.delete(TEST_USER_NAME)
4446

4547

48+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
4649
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
4750
def test_list_users(nc):
4851
try:
@@ -59,6 +62,7 @@ def test_list_users(nc):
5962
nc.users.delete(TEST_USER_NAME)
6063

6164

65+
@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1], Nextcloud), reason="Not available for NextcloudApp.")
6266
@pytest.mark.parametrize("nc", NC_TO_TEST[:1])
6367
def test_enable_disable_user(nc):
6468
try:

0 commit comments

Comments
 (0)