55
66from posit import connect
77
8+ from .fixtures import email , name , password , username
9+
810if TYPE_CHECKING :
911 from posit .connect .content import ContentItem
1012 from posit .connect .permissions import Permission
@@ -16,42 +18,33 @@ class TestContentPermissions:
1618 @classmethod
1719 def setup_class (cls ):
1820 cls .client = connect .Client ()
19- cls .content = cls .client .content .create (name = "example" )
21+ cls .content = cls .client .content .create (name = name () )
2022
21- cls .user_aron = cls .client .users .create (
22- username = "permission_aron" ,
23- 24- password = "permission_s3cur3p@ssword" ,
25- )
26- cls .user_bill = cls .client .users .create (
27- username = "permission_bill" ,
28- 29- password = "permission_s3cur3p@ssword" ,
23+ cls .alice = cls .client .users .create (
24+ username = name (),
25+ email = email (),
26+ password = password (),
3027 )
3128
32- cls .group_friends = cls .client .groups .create (name = "Friends" )
33-
34- @classmethod
35- def teardown_class (cls ):
36- cls .content .delete ()
37- assert cls .client .content .count () == 0
29+ cls .bob = cls .client .users .create (
30+ username = username (),
31+ email = email (),
32+ password = password (),
33+ )
3834
39- cls .group_friends .delete ()
40- assert cls .client .groups .count () == 0
35+ cls .group = cls .client .groups .create (name = name ())
4136
4237 def test_permissions_add_destroy (self ):
43- assert self .client .groups .count () == 1
44- assert self .client .users .count () == 3
4538 assert self .content .permissions .find () == []
4639
4740 # Add permissions
4841 self .content .permissions .create (
49- principal_guid = self .user_aron ["guid" ],
42+ principal_guid = self .alice ["guid" ],
5043 principal_type = "user" ,
5144 role = "viewer" ,
5245 )
5346 self .content .permissions .create (
54- principal_guid = self .group_friends ["guid" ],
47+ principal_guid = self .group ["guid" ],
5548 principal_type = "group" ,
5649 role = "owner" ,
5750 )
@@ -63,22 +56,22 @@ def assert_permissions_match_guids(permissions: list[Permission], objs_with_guid
6356 # Prove they have been added
6457 assert_permissions_match_guids (
6558 self .content .permissions .find (),
66- [self .user_aron , self .group_friends ],
59+ [self .alice , self .group ],
6760 )
6861
6962 # Remove permissions (and from some that isn't an owner)
70- self .content .permissions .destroy (self .user_aron )
63+ self .content .permissions .destroy (self .alice )
7164 with pytest .raises (ValueError ):
72- self .content .permissions .destroy (self .user_bill )
65+ self .content .permissions .destroy (self .bob )
7366
7467 # Prove they have been removed
7568 assert_permissions_match_guids (
7669 self .content .permissions .find (),
77- [self .group_friends ],
70+ [self .group ],
7871 )
7972
8073 # Remove the last permission
81- self .content .permissions .destroy (self .group_friends )
74+ self .content .permissions .destroy (self .group )
8275
8376 # Prove they have been removed
8477 assert self .content .permissions .find () == []
0 commit comments