@@ -57,6 +57,15 @@ def setup_class(cls):
5757 },
5858 )
5959
60+ cls .connect_integration = cls .client .oauth .integrations .create (
61+ name = "connect integration" ,
62+ description = "a connect description" ,
63+ template = "connect" ,
64+ config = {
65+ "max_role" : "admin" ,
66+ },
67+ )
68+
6069 # create content
6170 # requires full bundle deployment to produce an interactive content type
6271 cls .content = cls .client .content .create (name = "example-flask-minimal" )
@@ -77,6 +86,7 @@ def teardown_class(cls):
7786 # Destroy created integrations.
7887 cls .integration .delete ()
7988 cls .another_integration .delete ()
89+ cls .connect_integration .delete ()
8090
8191 # Assert that no integrations exist
8292 assert len (cls .client .oauth .integrations .find ()) == 0
@@ -95,6 +105,14 @@ def test_find_by_integration(self):
95105 no_associations = self .another_integration .associations .find ()
96106 assert len (no_associations ) == 0
97107
108+ def test_find_by_content (self ):
109+ association = self .content .oauth .associations .find_by (integration_type = "custom" )
110+ assert association is not None
111+ assert association ["oauth_integration_guid" ] == self .integration ["guid" ]
112+
113+ no_association = self .content .oauth .associations .find_by (integration_type = "connect" )
114+ assert no_association is None
115+
98116 def test_find_update_by_content (self ):
99117 associations = self .content .oauth .associations .find ()
100118 assert len (associations ) == 1
@@ -114,3 +132,41 @@ def test_find_update_by_content(self):
114132 self .content .oauth .associations .delete ()
115133 no_associations = self .content .oauth .associations .find ()
116134 assert len (no_associations ) == 0
135+
136+ def test_find_update_by_content_multiple (self ):
137+ associations = self .content .oauth .associations .find ()
138+ assert len (associations ) == 1
139+ assert associations [0 ]["app_guid" ] == self .content ["guid" ]
140+ assert associations [0 ]["oauth_integration_guid" ] == self .integration ["guid" ]
141+
142+ # update to have multiple associations
143+ self .content .oauth .associations .update (
144+ [
145+ self .integration ["guid" ],
146+ self .another_integration ["guid" ],
147+ self .connect_integration ["guid" ],
148+ ]
149+ )
150+ updated_associations = self .content .oauth .associations .find ()
151+ assert len (updated_associations ) == 3
152+ for assoc in updated_associations :
153+ assert assoc ["app_guid" ] == self .content ["guid" ]
154+ assert assoc ["oauth_integration_guid" ] in [
155+ self .integration ["guid" ],
156+ self .another_integration ["guid" ],
157+ self .connect_integration ["guid" ],
158+ ]
159+
160+ associated_connect_integration = self .content .oauth .associations .find_by (
161+ name = "connect integration"
162+ )
163+ assert associated_connect_integration is not None
164+ assert (
165+ associated_connect_integration ["oauth_integration_guid" ]
166+ == self .connect_integration ["guid" ]
167+ )
168+
169+ # unset content association
170+ self .content .oauth .associations .delete ()
171+ no_associations = self .content .oauth .associations .find ()
172+ assert len (no_associations ) == 0
0 commit comments