@@ -46,6 +46,7 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
4646 "fullscreen_layout" : False ,
4747 },
4848 "web" : {
49+ "allowed_layouts" : None ,
4950 "always_pinned" : True ,
5051 "default_layout" : "full" ,
5152 "expanded_layout" : "full" ,
@@ -69,6 +70,7 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
6970 "fullscreen_layout" : False ,
7071 },
7172 "web" : {
73+ "allowed_layouts" : None ,
7274 "always_pinned" : True ,
7375 "default_layout" : "full" ,
7476 "expanded_layout" : "full" ,
@@ -155,6 +157,7 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
155157 "fullscreen_layout" : False ,
156158 },
157159 "web" : {
160+ "allowed_layouts" : None ,
158161 "always_pinned" : False ,
159162 "default_layout" : "minimal" ,
160163 "expanded_layout" : "half" ,
@@ -196,3 +199,324 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
196199 app_id = [],
197200 ),
198201 )
202+
203+
204+ async def test__send_smartapp_manifest__with_only_full_layout__succeed (
205+ respx_mock : MockRouter ,
206+ host : str ,
207+ bot_id : UUID ,
208+ bot_account : BotAccountWithSecret ,
209+ ) -> None :
210+ # - Arrange -
211+ endpoint = respx_mock .post (
212+ f"https://{ host } /api/v1/botx/smartapps/manifest" ,
213+ headers = {"Authorization" : "Bearer token" , "Content-Type" : "application/json" },
214+ json = {
215+ "manifest" : {
216+ "android" : {"fullscreen_layout" : False },
217+ "ios" : {"fullscreen_layout" : False },
218+ "unread_counter_link" : {
219+ "app_id" : ["test_app" ],
220+ "group_chat_id" : [],
221+ "user_huid" : [],
222+ },
223+ "web" : {
224+ "allowed_layouts" : ["full" ],
225+ "always_pinned" : False ,
226+ "default_layout" : "full" ,
227+ "expanded_layout" : "full" ,
228+ },
229+ },
230+ },
231+ ).mock (
232+ return_value = httpx .Response (
233+ HTTPStatus .ACCEPTED ,
234+ json = {
235+ "result" : {
236+ "android" : {
237+ "always_pinned" : False ,
238+ "fullscreen_layout" : False ,
239+ "lock_portrait_orientation" : False ,
240+ },
241+ "ios" : {"always_pinned" : False , "fullscreen_layout" : False },
242+ "unread_counter_link" : {
243+ "app_id" : ["test_app" ],
244+ "group_chat_id" : [],
245+ "user_huid" : [],
246+ },
247+ "web" : {
248+ "allowed_layouts" : ["full" ],
249+ "always_pinned" : False ,
250+ "default_layout" : "full" ,
251+ "expanded_layout" : "full" ,
252+ "raster_icon" : None ,
253+ "vector_icon" : None ,
254+ },
255+ },
256+ "status" : "ok" ,
257+ },
258+ ),
259+ )
260+
261+ built_bot = Bot (collectors = [HandlerCollector ()], bot_accounts = [bot_account ])
262+
263+ # - Act -
264+ async with lifespan_wrapper (built_bot ) as bot :
265+ smartapp_manifest = await bot .send_smartapp_manifest (
266+ bot_id = bot_id ,
267+ ios = SmartappManifestIosParams (
268+ fullscreen_layout = False ,
269+ ),
270+ android = SmartappManifestAndroidParams (
271+ fullscreen_layout = False ,
272+ ),
273+ web_layout = SmartappManifestWebParams (
274+ default_layout = SmartappManifestWebLayoutChoices .full ,
275+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
276+ allowed_layouts = [SmartappManifestWebLayoutChoices .full ],
277+ always_pinned = False ,
278+ ),
279+ unread_counter = SmartappManifestUnreadCounterParams (
280+ user_huid = [],
281+ group_chat_id = [],
282+ app_id = ["test_app" ],
283+ ),
284+ )
285+
286+ # - Assert -
287+ assert endpoint .called
288+ assert smartapp_manifest == SmartappManifest (
289+ ios = SmartappManifestIosParams (
290+ fullscreen_layout = False ,
291+ ),
292+ android = SmartappManifestAndroidParams (
293+ fullscreen_layout = False ,
294+ ),
295+ web = SmartappManifestWebParams (
296+ default_layout = SmartappManifestWebLayoutChoices .full ,
297+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
298+ allowed_layouts = [SmartappManifestWebLayoutChoices .full ],
299+ always_pinned = False ,
300+ ),
301+ unread_counter_link = SmartappManifestUnreadCounterParams (
302+ user_huid = [],
303+ group_chat_id = [],
304+ app_id = ["test_app" ],
305+ ),
306+ )
307+
308+
309+ async def test__send_smartapp_manifest__with_only_minimal_and_full_layout__succeed (
310+ respx_mock : MockRouter ,
311+ host : str ,
312+ bot_id : UUID ,
313+ bot_account : BotAccountWithSecret ,
314+ ) -> None :
315+ # - Arrange -
316+ endpoint = respx_mock .post (
317+ f"https://{ host } /api/v1/botx/smartapps/manifest" ,
318+ headers = {"Authorization" : "Bearer token" , "Content-Type" : "application/json" },
319+ json = {
320+ "manifest" : {
321+ "android" : {"fullscreen_layout" : False },
322+ "ios" : {"fullscreen_layout" : False },
323+ "unread_counter_link" : {
324+ "app_id" : ["test_app" ],
325+ "group_chat_id" : [],
326+ "user_huid" : [],
327+ },
328+ "web" : {
329+ "allowed_layouts" : ["minimal" , "full" ],
330+ "always_pinned" : False ,
331+ "default_layout" : "minimal" ,
332+ "expanded_layout" : "full" ,
333+ },
334+ },
335+ },
336+ ).mock (
337+ return_value = httpx .Response (
338+ HTTPStatus .ACCEPTED ,
339+ json = {
340+ "result" : {
341+ "android" : {
342+ "always_pinned" : False ,
343+ "fullscreen_layout" : False ,
344+ "lock_portrait_orientation" : False ,
345+ },
346+ "ios" : {"always_pinned" : False , "fullscreen_layout" : False },
347+ "unread_counter_link" : {
348+ "app_id" : ["test_app" ],
349+ "group_chat_id" : [],
350+ "user_huid" : [],
351+ },
352+ "web" : {
353+ "allowed_layouts" : ["minimal" , "full" ],
354+ "always_pinned" : False ,
355+ "default_layout" : "minimal" ,
356+ "expanded_layout" : "full" ,
357+ "raster_icon" : None ,
358+ "vector_icon" : None ,
359+ },
360+ },
361+ "status" : "ok" ,
362+ },
363+ ),
364+ )
365+
366+ built_bot = Bot (collectors = [HandlerCollector ()], bot_accounts = [bot_account ])
367+
368+ # - Act -
369+ async with lifespan_wrapper (built_bot ) as bot :
370+ smartapp_manifest = await bot .send_smartapp_manifest (
371+ bot_id = bot_id ,
372+ ios = SmartappManifestIosParams (
373+ fullscreen_layout = False ,
374+ ),
375+ android = SmartappManifestAndroidParams (
376+ fullscreen_layout = False ,
377+ ),
378+ web_layout = SmartappManifestWebParams (
379+ default_layout = SmartappManifestWebLayoutChoices .minimal ,
380+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
381+ allowed_layouts = [
382+ SmartappManifestWebLayoutChoices .minimal ,
383+ SmartappManifestWebLayoutChoices .full ,
384+ ],
385+ always_pinned = False ,
386+ ),
387+ unread_counter = SmartappManifestUnreadCounterParams (
388+ user_huid = [],
389+ group_chat_id = [],
390+ app_id = ["test_app" ],
391+ ),
392+ )
393+
394+ # - Assert -
395+ assert endpoint .called
396+ assert smartapp_manifest == SmartappManifest (
397+ ios = SmartappManifestIosParams (
398+ fullscreen_layout = False ,
399+ ),
400+ android = SmartappManifestAndroidParams (
401+ fullscreen_layout = False ,
402+ ),
403+ web = SmartappManifestWebParams (
404+ default_layout = SmartappManifestWebLayoutChoices .minimal ,
405+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
406+ allowed_layouts = [
407+ SmartappManifestWebLayoutChoices .minimal ,
408+ SmartappManifestWebLayoutChoices .full ,
409+ ],
410+ always_pinned = False ,
411+ ),
412+ unread_counter_link = SmartappManifestUnreadCounterParams (
413+ user_huid = [],
414+ group_chat_id = [],
415+ app_id = ["test_app" ],
416+ ),
417+ )
418+
419+
420+ async def test__send_smartapp_manifest__with_empty_layout__succeed (
421+ respx_mock : MockRouter ,
422+ host : str ,
423+ bot_id : UUID ,
424+ bot_account : BotAccountWithSecret ,
425+ ) -> None :
426+ # - Arrange -
427+ endpoint = respx_mock .post (
428+ f"https://{ host } /api/v1/botx/smartapps/manifest" ,
429+ headers = {"Authorization" : "Bearer token" , "Content-Type" : "application/json" },
430+ json = {
431+ "manifest" : {
432+ "android" : {"fullscreen_layout" : False },
433+ "ios" : {"fullscreen_layout" : False },
434+ "unread_counter_link" : {
435+ "app_id" : ["test_app" ],
436+ "group_chat_id" : [],
437+ "user_huid" : [],
438+ },
439+ "web" : {
440+ "allowed_layouts" : [],
441+ "always_pinned" : False ,
442+ "default_layout" : "minimal" ,
443+ "expanded_layout" : "full" ,
444+ },
445+ },
446+ },
447+ ).mock (
448+ return_value = httpx .Response (
449+ HTTPStatus .ACCEPTED ,
450+ json = {
451+ "result" : {
452+ "android" : {
453+ "always_pinned" : False ,
454+ "fullscreen_layout" : False ,
455+ "lock_portrait_orientation" : False ,
456+ },
457+ "ios" : {"always_pinned" : False , "fullscreen_layout" : False },
458+ "unread_counter_link" : {
459+ "app_id" : ["test_app" ],
460+ "group_chat_id" : [],
461+ "user_huid" : [],
462+ },
463+ "web" : {
464+ "allowed_layouts" : [],
465+ "always_pinned" : False ,
466+ "default_layout" : "minimal" ,
467+ "expanded_layout" : "full" ,
468+ "raster_icon" : None ,
469+ "vector_icon" : None ,
470+ },
471+ },
472+ "status" : "ok" ,
473+ },
474+ ),
475+ )
476+
477+ built_bot = Bot (collectors = [HandlerCollector ()], bot_accounts = [bot_account ])
478+
479+ # - Act -
480+ async with lifespan_wrapper (built_bot ) as bot :
481+ smartapp_manifest = await bot .send_smartapp_manifest (
482+ bot_id = bot_id ,
483+ ios = SmartappManifestIosParams (
484+ fullscreen_layout = False ,
485+ ),
486+ android = SmartappManifestAndroidParams (
487+ fullscreen_layout = False ,
488+ ),
489+ web_layout = SmartappManifestWebParams (
490+ default_layout = SmartappManifestWebLayoutChoices .minimal ,
491+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
492+ allowed_layouts = [],
493+ always_pinned = False ,
494+ ),
495+ unread_counter = SmartappManifestUnreadCounterParams (
496+ user_huid = [],
497+ group_chat_id = [],
498+ app_id = ["test_app" ],
499+ ),
500+ )
501+
502+ # - Assert -
503+ assert endpoint .called
504+ assert smartapp_manifest == SmartappManifest (
505+ ios = SmartappManifestIosParams (
506+ fullscreen_layout = False ,
507+ ),
508+ android = SmartappManifestAndroidParams (
509+ fullscreen_layout = False ,
510+ ),
511+ web = SmartappManifestWebParams (
512+ default_layout = SmartappManifestWebLayoutChoices .minimal ,
513+ expanded_layout = SmartappManifestWebLayoutChoices .full ,
514+ allowed_layouts = [],
515+ always_pinned = False ,
516+ ),
517+ unread_counter_link = SmartappManifestUnreadCounterParams (
518+ user_huid = [],
519+ group_chat_id = [],
520+ app_id = ["test_app" ],
521+ ),
522+ )
0 commit comments