1
+ import unittest
1
2
import uuid
2
3
3
4
from office365 .directory .groupCreationProperties import GroupCreationProperties
5
+ from office365 .runtime .client_request_exception import ClientRequestException
4
6
from tests .graph_case import GraphTestCase
5
7
6
8
@@ -10,14 +12,25 @@ class TestGraphGroup(GraphTestCase):
10
12
target_group = None
11
13
12
14
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
19
30
20
31
def test2_delete_group (self ):
21
32
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