Added a hack to make testing the filesystem adapter tests working

This commit is contained in:
Sumner Evans
2020-04-21 13:50:01 -06:00
parent 9d7218afd9
commit 2863570e5b
7 changed files with 81 additions and 18 deletions

View File

@@ -0,0 +1,51 @@
from datetime import timedelta
from typing import Any, Optional
from peewee import (
BooleanField,
DateTimeField,
DatabaseProxy,
Field,
ForeignKeyField,
IntegerField,
Model,
TextField,
)
database = DatabaseProxy()
class BaseModel(Model):
class Meta:
database = database
class DurationField(IntegerField):
def db_value(self, value: timedelta) -> Optional[int]:
return value.microseconds if value else None
def python_value(self, value: Optional[int]) -> Optional[timedelta]:
return timedelta(microseconds=value) if value else None
class CoverArt(BaseModel):
id = TextField(unique=True, primary_key=True)
url = TextField()
filename = TextField(null=True)
class Playlist(BaseModel):
id = TextField(unique=True, primary_key=True)
name = TextField()
song_count = IntegerField()
duration = DurationField()
created = DateTimeField()
changed = DateTimeField()
public = BooleanField()
cover_art = TextField()
ALL_TABLES = (
CoverArt,
Playlist,
)