@@ -483,3 +483,75 @@ async def test_download_backup(
483483 assert isinstance (result , AsyncIterator )
484484 async for chunk in result :
485485 assert chunk == b"backup test"
486+
487+
488+ @pytest .mark .parametrize (
489+ ("options" , "as_dict" ),
490+ [
491+ (
492+ PartialBackupOptions (name = "Test" , folders = {Folder .SHARE }),
493+ {"name" : "Test" , "folders" : ["share" ]},
494+ ),
495+ (PartialBackupOptions (addons = {"core_ssh" }), {"addons" : ["core_ssh" ]}),
496+ (PartialBackupOptions (addons = AddonSet .ALL ), {"addons" : "all" }),
497+ (
498+ PartialBackupOptions (
499+ homeassistant = True , homeassistant_exclude_database = True
500+ ),
501+ {"homeassistant" : True , "homeassistant_exclude_database" : True },
502+ ),
503+ (
504+ PartialBackupOptions (
505+ folders = {Folder .SSL }, compressed = True , background = True
506+ ),
507+ {"folders" : ["ssl" ], "compressed" : True , "background" : True },
508+ ),
509+ (
510+ PartialBackupOptions (
511+ homeassistant = True , location = [".cloud_backup" , "test" ]
512+ ),
513+ {"homeassistant" : True , "location" : [".cloud_backup" , "test" ]},
514+ ),
515+ (
516+ PartialBackupOptions (homeassistant = True , location = "test" ),
517+ {"homeassistant" : True , "location" : "test" },
518+ ),
519+ (
520+ PartialBackupOptions (homeassistant = True , location = None ),
521+ {"homeassistant" : True , "location" : None },
522+ ),
523+ ],
524+ )
525+ async def test_partial_backup_model (
526+ options : PartialBackupOptions , as_dict : dict [str , Any ]
527+ ) -> None :
528+ """Test partial backup model parsing and serializing."""
529+ assert PartialBackupOptions .from_dict (as_dict ) == options
530+ assert options .to_dict () == as_dict
531+
532+
533+ @pytest .mark .parametrize (
534+ ("options" , "as_dict" ),
535+ [
536+ (FullBackupOptions (name = "Test" ), {"name" : "Test" }),
537+ (FullBackupOptions (password = "test" ), {"password" : "test" }), # noqa: S106
538+ (FullBackupOptions (compressed = True ), {"compressed" : True }),
539+ (
540+ FullBackupOptions (homeassistant_exclude_database = True ),
541+ {"homeassistant_exclude_database" : True },
542+ ),
543+ (FullBackupOptions (background = True ), {"background" : True }),
544+ (
545+ FullBackupOptions (location = [".cloud_backup" , "test" ]),
546+ {"location" : [".cloud_backup" , "test" ]},
547+ ),
548+ (FullBackupOptions (location = "test" ), {"location" : "test" }),
549+ (FullBackupOptions (location = None ), {"location" : None }),
550+ ],
551+ )
552+ async def test_full_backup_model (
553+ options : FullBackupOptions , as_dict : dict [str , Any ]
554+ ) -> None :
555+ """Test full backup model parsing and serializing."""
556+ assert FullBackupOptions .from_dict (as_dict ) == options
557+ assert options .to_dict () == as_dict
0 commit comments