@@ -160,6 +160,31 @@ def test_create_from_event(self, create_event, override_app_settings):
160160 repositories
161161 )
162162
163+ @pytest .mark .asyncio
164+ async def test_acreate_from_gh_data (self ):
165+ installation_data = {
166+ "id" : seq .next (),
167+ "app_id" : seq .next (),
168+ }
169+
170+ installation = await Installation .objects .acreate_from_gh_data (
171+ installation_data
172+ )
173+
174+ assert installation .installation_id == installation_data ["id" ]
175+ assert installation .data == installation_data
176+
177+ def test_create_from_gh_data (self ):
178+ installation_data = {
179+ "id" : seq .next (),
180+ "app_id" : seq .next (),
181+ }
182+
183+ installation = Installation .objects .create_from_gh_data (installation_data )
184+
185+ assert installation .installation_id == installation_data ["id" ]
186+ assert installation .data == installation_data
187+
163188 @pytest .mark .asyncio
164189 async def test_aget_from_event (self , ainstallation , create_event ):
165190 installation = await ainstallation
@@ -213,6 +238,60 @@ def test_from_event_invalid_action(self, create_event):
213238
214239
215240class TestRepositoryManager :
241+ @pytest .mark .asyncio
242+ async def test_acreate_from_gh_data_list (self , ainstallation ):
243+ installation = await ainstallation
244+ data = [
245+ {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" },
246+ {"id" : seq .next (), "node_id" : "node2" , "full_name" : "owner/repo2" },
247+ ]
248+
249+ repositories = await Repository .objects .acreate_from_gh_data (data , installation )
250+
251+ assert len (repositories ) == len (data )
252+ for i , repo in enumerate (repositories ):
253+ assert repo .repository_id == data [i ]["id" ]
254+ assert repo .repository_node_id == data [i ]["node_id" ]
255+ assert repo .full_name == data [i ]["full_name" ]
256+ assert repo .installation_id == installation .id
257+
258+ def test_create_from_gh_data_list (self , installation ):
259+ data = [
260+ {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" },
261+ {"id" : seq .next (), "node_id" : "node2" , "full_name" : "owner/repo2" },
262+ ]
263+
264+ repositories = Repository .objects .create_from_gh_data (data , installation )
265+
266+ assert len (repositories ) == len (data )
267+ for i , repo in enumerate (repositories ):
268+ assert repo .repository_id == data [i ]["id" ]
269+ assert repo .repository_node_id == data [i ]["node_id" ]
270+ assert repo .full_name == data [i ]["full_name" ]
271+ assert repo .installation_id == installation .id
272+
273+ @pytest .mark .asyncio
274+ async def test_acreate_from_gh_data_single (self , ainstallation ):
275+ installation = await ainstallation
276+ data = {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" }
277+
278+ repository = await Repository .objects .acreate_from_gh_data (data , installation )
279+
280+ assert repository .repository_id == data ["id" ]
281+ assert repository .repository_node_id == data ["node_id" ]
282+ assert repository .full_name == data ["full_name" ]
283+ assert repository .installation_id == installation .id
284+
285+ def test_create_from_gh_data_single (self , installation ):
286+ data = {"id" : seq .next (), "node_id" : "node1" , "full_name" : "owner/repo1" }
287+
288+ repository = Repository .objects .create_from_gh_data (data , installation )
289+
290+ assert repository .repository_id == data ["id" ]
291+ assert repository .repository_node_id == data ["node_id" ]
292+ assert repository .full_name == data ["full_name" ]
293+ assert repository .installation_id == installation .id
294+
216295 @pytest .mark .asyncio
217296 async def test_aget_from_event (self , arepository , create_event ):
218297 repository = await arepository
0 commit comments