Coverage for seedboxsync/core/dao/seedboxsync.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-26 17:46 +0000

1# 

2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr> 

3# 

4# For the full copyright and license information, please view the LICENSE 

5# file that was distributed with this source code. 

6# 

7"""Peewee DAO model for SeedboxSync.""" 

8 

9from peewee import CharField, TextField 

10from seedboxsync.core.dao import SeedboxSyncModel 

11 

12 

13class SeedboxSync(SeedboxSyncModel): 

14 """ 

15 Data Access Object (DAO) for application metadata and internal configuration. 

16 

17 This table stores key-value pairs used for SeedboxSync's internal state 

18 management and configuration, such as taskstatus, versioning, or runtime 

19 parameters. 

20 

21 Attributes: 

22 key (str): Unique identifier for the configuration entry. 

23 value (str): Stored value associated with the key. 

24 """ 

25 

26 key = CharField(primary_key=True) 

27 value = TextField() 

28 

29 @staticmethod 

30 def get_db_version() -> str: 

31 """ 

32 Return database model version. 

33 

34 Returns: 

35 str: The database model version. 

36 """ 

37 return str(SeedboxSync.select(SeedboxSync.value).where(SeedboxSync.key == "db_version").first().value) # Use old style to prevent Peewee 2 databases. 

38 

39 @staticmethod 

40 def set_db_version(db_version: str) -> None: 

41 """ 

42 Upsert database model version. 

43 

44 Args: 

45 db_version (str): The database model version. 

46 """ 

47 SeedboxSync.replace(key="db_version", value=db_version).execute() # type: ignore[no-untyped-call]