44from office365 .graph_client import GraphClient
55from office365 .onedrive .contenttypes .content_type import ContentType
66from tests import test_client_id , test_password , test_tenant , test_username
7+ from tests .decorators import requires_delegated_permission
78
89
910class TestContentType (TestCase ):
@@ -26,6 +27,7 @@ def test1_get_compatible_hub_content_types(self):
2627 )
2728 self .assertIsNotNone (cts .resource_path )
2829
30+ @requires_delegated_permission ("Sites.Manage.All" , "Sites.FullControl.All" )
2931 def test2_create_site_content_type (self ):
3032 name = "docSet" + uuid .uuid4 ().hex
3133 ct = self .client .sites .root .content_types .add (
@@ -34,19 +36,33 @@ def test2_create_site_content_type(self):
3436 self .assertIsNotNone (ct .resource_path )
3537 self .__class__ .target_ct = ct
3638
37- # def test3_publish_and_verify_if_published(self):
38- # result = self.__class__.target_ct.publish().is_published().execute_query()
39- # self.assertTrue(result.value)
39+ @requires_delegated_permission ("Sites.FullControl.All" )
40+ def test3_publish (self ):
41+ result = self .__class__ .target_ct .publish ().execute_query ()
42+ self .assertFalse (result .resource_path )
4043
41- # def test4_unpublish(self):
42- # result = self.__class__.target_ct.unpublish().is_published().execute_query()
43- # self.assertFalse(result.value)
44+ @requires_delegated_permission ("Sites.FullControl.All" )
45+ def test4_is_published (self ):
46+ result = self .__class__ .target_ct .is_published ().execute_query ()
47+ self .assertTrue (result .value )
4448
45- def test5_delete (self ):
49+ @requires_delegated_permission ("Sites.FullControl.All" )
50+ def test5_unpublish (self ):
51+ result = self .__class__ .target_ct .unpublish ().is_published ().execute_query ()
52+ self .assertFalse (result .value )
53+
54+ @requires_delegated_permission ("Sites.Manage.All" , "Sites.FullControl.All" )
55+ def test6_delete_site_content_type (self ):
4656 ct_to_del = self .__class__ .target_ct
4757 ct_to_del .delete_object ().execute_query ()
4858
49- def test6_get_applicable_content_types_for_list (self ):
59+ @requires_delegated_permission (
60+ "Sites.Read.All" ,
61+ "Sites.FullControl.All" ,
62+ "Sites.Manage.All" ,
63+ "Sites.ReadWrite.All" ,
64+ )
65+ def test7_get_applicable_content_types_for_list (self ):
5066 site = self .client .sites .root
5167 doc_lib = site .lists ["Documents" ].get ().execute_query ()
5268 cts = site .get_applicable_content_types_for_list (doc_lib .id ).execute_query ()
0 commit comments