def test_ensure_default_storage_present_does_nothing_if_default_is_present(peewee_database): from cozy.model.settings import Settings from cozy.db.storage import Storage settings = Settings() settings._load_all_storage_locations() settings._ensure_default_storage_present() assert not Storage.get(1).default assert Storage.get(2).default
def test_ensure_default_storage_present_adds_default_if_not_present(peewee_database): from cozy.model.settings import Settings from cozy.db.storage import Storage Storage.update(default=False).where(Storage.id == 2).execute() settings = Settings() settings._load_all_storage_locations() settings._ensure_default_storage_present() assert Storage.get(1).default assert not Storage.get(2).default