|
4 | 4 |
|
5 | 5 | from gfixture import NC_TO_TEST |
6 | 6 |
|
7 | | -TEST_GROUP_NAME = "test_coverage_group" |
| 7 | +TEST_GROUP_NAME = "test_coverage_group1" |
| 8 | +TEST_GROUP_NAME2 = "test_coverage_group2" |
8 | 9 |
|
9 | 10 |
|
10 | 11 | @pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
11 | 12 | @pytest.mark.parametrize("nc", NC_TO_TEST[:1]) |
12 | | -def test_create_delete_group(nc): |
| 13 | +@pytest.mark.parametrize("params", ((TEST_GROUP_NAME, ), (TEST_GROUP_NAME, "display name"))) |
| 14 | +def test_create_delete_group(nc, params): |
| 15 | + test_group_name = params[0] |
13 | 16 | try: |
14 | | - nc.users_groups.delete(TEST_GROUP_NAME) |
| 17 | + nc.users_groups.delete(test_group_name) |
15 | 18 | except NextcloudException: |
16 | 19 | pass |
17 | | - nc.users_groups.create(TEST_GROUP_NAME) |
| 20 | + nc.users_groups.create(*params) |
18 | 21 | with pytest.raises(NextcloudException): |
19 | | - nc.users_groups.create(TEST_GROUP_NAME) |
20 | | - nc.users_groups.delete(TEST_GROUP_NAME) |
| 22 | + nc.users_groups.create(*params) |
| 23 | + nc.users_groups.delete(test_group_name) |
21 | 24 | with pytest.raises(NextcloudException): |
22 | | - nc.users_groups.delete(TEST_GROUP_NAME) |
| 25 | + nc.users_groups.delete(test_group_name) |
| 26 | + |
| 27 | + |
| 28 | +@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
| 29 | +@pytest.mark.parametrize("nc", NC_TO_TEST[:1]) |
| 30 | +def test_get_group(nc): |
| 31 | + for i in (TEST_GROUP_NAME, TEST_GROUP_NAME2): |
| 32 | + try: |
| 33 | + nc.users_groups.create(i) |
| 34 | + except NextcloudException: |
| 35 | + pass |
| 36 | + groups = nc.users_groups.get() |
| 37 | + assert isinstance(groups, list) |
| 38 | + assert len(groups) >= 2 |
| 39 | + assert TEST_GROUP_NAME in groups |
| 40 | + assert TEST_GROUP_NAME2 in groups |
| 41 | + groups = nc.users_groups.get(mask=TEST_GROUP_NAME) |
| 42 | + assert len(groups) == 1 |
| 43 | + groups = nc.users_groups.get(limit=1) |
| 44 | + assert len(groups) == 1 |
| 45 | + assert groups[0] != nc.users_groups.get(limit=1, offset=1)[0] |
| 46 | + nc.users_groups.delete(TEST_GROUP_NAME) |
| 47 | + nc.users_groups.delete(TEST_GROUP_NAME2) |
| 48 | + |
| 49 | + |
| 50 | +@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
| 51 | +@pytest.mark.parametrize("nc", NC_TO_TEST[:1]) |
| 52 | +def test_get_non_existing_group(nc): |
| 53 | + groups = nc.users_groups.get(mask="Such group should not be present") |
| 54 | + assert isinstance(groups, list) |
| 55 | + assert not groups |
23 | 56 |
|
24 | 57 |
|
25 | 58 | @pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
26 | 59 | @pytest.mark.parametrize("nc", NC_TO_TEST[:1]) |
27 | | -def test_list_group(nc): |
| 60 | +def test_get_group_details(nc): |
28 | 61 | try: |
29 | | - nc.users_groups.create(TEST_GROUP_NAME) |
| 62 | + nc.users_groups.delete(TEST_GROUP_NAME) |
30 | 63 | except NextcloudException: |
31 | 64 | pass |
32 | 65 | try: |
33 | | - nc.users_groups.create(TEST_GROUP_NAME + "2") |
| 66 | + nc.users_groups.create(TEST_GROUP_NAME) |
34 | 67 | except NextcloudException: |
35 | 68 | pass |
36 | | - groups = nc.users_groups.list() |
37 | | - assert len(groups) >= 2 |
38 | | - assert TEST_GROUP_NAME in groups |
39 | | - assert TEST_GROUP_NAME + "2" in groups |
40 | | - groups = nc.users_groups.list(mask=TEST_GROUP_NAME) |
41 | | - assert len(groups) == 2 |
42 | | - groups = nc.users_groups.list(limit=1) |
| 69 | + groups = nc.users_groups.get_details(mask=TEST_GROUP_NAME) |
43 | 70 | assert len(groups) == 1 |
44 | | - assert groups[0] != nc.users_groups.list(limit=1, offset=1)[0] |
| 71 | + group = groups[0] |
| 72 | + assert group["id"] == TEST_GROUP_NAME |
| 73 | + assert group["display_name"] == TEST_GROUP_NAME |
| 74 | + assert not group["disabled"] |
| 75 | + assert isinstance(group["user_count"], int) |
| 76 | + assert isinstance(group["can_add"], bool) |
| 77 | + assert isinstance(group["can_remove"], bool) |
| 78 | + nc.users_groups.delete(TEST_GROUP_NAME) |
| 79 | + |
| 80 | + |
| 81 | +@pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
| 82 | +@pytest.mark.parametrize("nc", NC_TO_TEST[:1]) |
| 83 | +def test_group_edit(nc): |
| 84 | + try: |
| 85 | + nc.users_groups.create(TEST_GROUP_NAME) |
| 86 | + except NextcloudException: |
| 87 | + pass |
| 88 | + nc.users_groups.edit(TEST_GROUP_NAME, display_name="earth people") |
| 89 | + assert nc.users_groups.get_details(mask=TEST_GROUP_NAME)[0]["display_name"] == "earth people" |
45 | 90 | nc.users_groups.delete(TEST_GROUP_NAME) |
46 | | - nc.users_groups.delete(TEST_GROUP_NAME + "2") |
| 91 | + with pytest.raises(NextcloudException) as exc_info: |
| 92 | + nc.users_groups.edit(TEST_GROUP_NAME, display_name="earth people") |
| 93 | + assert exc_info.value.status_code == 996 |
47 | 94 |
|
48 | 95 |
|
49 | 96 | @pytest.mark.skipif(not isinstance(NC_TO_TEST[:1][0], Nextcloud), reason="Not available for NextcloudApp.") |
|
0 commit comments