Skip to content

Commit 1ac2c73

Browse files
committed
Unit tests minor fixes 2 dependency for #167)
1 parent 0aed7f6 commit 1ac2c73

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

office365/directory/groupCreationProperties.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ def __init__(self, name):
1111
self.securityEnabled = True
1212
self.owners = []
1313
self.members = []
14+
self.groupTypes = []

tests/test_graph_group.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import unittest
12
import uuid
23

34
from office365.directory.groupCreationProperties import GroupCreationProperties
5+
from office365.runtime.client_request_exception import ClientRequestException
46
from tests.graph_case import GraphTestCase
57

68

@@ -10,14 +12,25 @@ class TestGraphGroup(GraphTestCase):
1012
target_group = None
1113

1214
def test1_create_group(self):
13-
grp_name = "Group_" + uuid.uuid4().hex
14-
properties = GroupCreationProperties(grp_name)
15-
new_group = self.client.groups.add(properties)
16-
self.client.execute_query()
17-
self.assertIsNotNone(new_group.properties['id'])
18-
self.__class__.target_group = new_group
15+
try:
16+
grp_name = "Group_" + uuid.uuid4().hex
17+
properties = GroupCreationProperties(grp_name)
18+
properties.securityEnabled = False
19+
properties.mailEnabled = True
20+
properties.groupTypes = ["Unified"]
21+
new_group = self.client.groups.add(properties)
22+
self.client.execute_query()
23+
self.assertIsNotNone(new_group.properties['id'])
24+
self.__class__.target_group = new_group
25+
except ClientRequestException as e:
26+
if e.code == 'Directory_QuotaExceeded':
27+
self.__class__.target_group = None
28+
else:
29+
raise
1930

2031
def test2_delete_group(self):
2132
grp_to_delete = self.__class__.target_group
22-
grp_to_delete.delete_object()
23-
self.client.execute_query()
33+
if grp_to_delete is not None:
34+
grp_to_delete.delete_object()
35+
self.client.execute_query()
36+

0 commit comments

Comments
 (0)