change boolean fields in schema from Bit(1) to Boolean
This commit is contained in:
@@ -25,8 +25,8 @@ def update_titles(db: SessionDep) -> list[MediaFileResponse]:
|
|||||||
file_name=mediafile.file_name,
|
file_name=mediafile.file_name,
|
||||||
cloud_link=mediafile.cloud_link,
|
cloud_link=mediafile.cloud_link,
|
||||||
url=str(mediafile.url),
|
url=str(mediafile.url),
|
||||||
review=(mediafile.review == 1),
|
review=mediafile.review,
|
||||||
should_download=(mediafile.should_download == 1))
|
should_download=mediafile.should_download)
|
||||||
results.append(response)
|
results.append(response)
|
||||||
db.commit()
|
db.commit()
|
||||||
return results
|
return results
|
||||||
@@ -37,9 +37,9 @@ def get_all_files(db: SessionDep, review: bool = False, download: bool = False)
|
|||||||
results: list[MediaFileResponse] = []
|
results: list[MediaFileResponse] = []
|
||||||
files: Sequence[MediaFile]
|
files: Sequence[MediaFile]
|
||||||
if review:
|
if review:
|
||||||
files = db.query(MediaFile).filter(MediaFile.review == 1).all()
|
files = db.query(MediaFile).filter(MediaFile.review == review).all()
|
||||||
elif download:
|
elif download:
|
||||||
files = db.query(MediaFile).filter(MediaFile.should_download == 1).all()
|
files = db.query(MediaFile).filter(MediaFile.should_download == download).all()
|
||||||
else:
|
else:
|
||||||
files = db.scalars(select(MediaFile)).all()
|
files = db.scalars(select(MediaFile)).all()
|
||||||
for mediafile in files:
|
for mediafile in files:
|
||||||
@@ -48,8 +48,8 @@ def get_all_files(db: SessionDep, review: bool = False, download: bool = False)
|
|||||||
file_name=mediafile.file_name,
|
file_name=mediafile.file_name,
|
||||||
cloud_link=mediafile.cloud_link,
|
cloud_link=mediafile.cloud_link,
|
||||||
url=str(mediafile.url),
|
url=str(mediafile.url),
|
||||||
review=(mediafile.review == 1),
|
review=mediafile.review,
|
||||||
should_download=(mediafile.should_download == 1))
|
should_download=mediafile.should_download)
|
||||||
results.append(response)
|
results.append(response)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -95,6 +95,6 @@ def add_file(new_link: Link, db: SessionDep) -> MediaFileResponse:
|
|||||||
file_name=mediaFile.file_name,
|
file_name=mediaFile.file_name,
|
||||||
cloud_link=mediaFile.cloud_link,
|
cloud_link=mediaFile.cloud_link,
|
||||||
url=new_link.url,
|
url=new_link.url,
|
||||||
review=(mediaFile.review == 1),
|
review=mediaFile.review,
|
||||||
should_download=(mediaFile.should_download == 1))
|
should_download=mediaFile.should_download)
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
from sqlalchemy.dialects.mysql import BIT
|
||||||
from sqlalchemy.orm import relationship, mapped_column, Mapped
|
from sqlalchemy.orm import relationship, mapped_column, Mapped
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class User(Base, BaseMixin):
|
|||||||
user_name = Column(String(255), nullable=False)
|
user_name = Column(String(255), nullable=False)
|
||||||
email = Column(String(255))
|
email = Column(String(255))
|
||||||
password = Column(String(255))
|
password = Column(String(255))
|
||||||
enabled = Column(BIT(1))
|
enabled = Column(Boolean)
|
||||||
matrix = relationship("AuthorizationMatrix")
|
matrix = relationship("AuthorizationMatrix")
|
||||||
tokens = relationship("Token")
|
tokens = relationship("Token")
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class Token(Base, BaseMixin):
|
|||||||
token = Column(String(255), nullable=False, unique=True)
|
token = Column(String(255), nullable=False, unique=True)
|
||||||
name = Column(String(255))
|
name = Column(String(255))
|
||||||
last_used_date: Mapped[datetime] = mapped_column()
|
last_used_date: Mapped[datetime] = mapped_column()
|
||||||
enabled = Column(BIT(1))
|
enabled = Column(Boolean)
|
||||||
user_id = Column(String(255), ForeignKey("user.id"), nullable=False)
|
user_id = Column(String(255), ForeignKey("user.id"), nullable=False)
|
||||||
user = relationship("User", back_populates="tokens")
|
user = relationship("User", back_populates="tokens")
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class AuthorizationMatrix(Base, BaseMixin):
|
|||||||
class ModuleData(Base, BaseMixin):
|
class ModuleData(Base, BaseMixin):
|
||||||
__tablename__ = "module_data"
|
__tablename__ = "module_data"
|
||||||
module_name = Column(String(255), nullable=False)
|
module_name = Column(String(255), nullable=False)
|
||||||
import_data = Column(BIT(1))
|
import_data = Column(Boolean)
|
||||||
|
|
||||||
|
|
||||||
class MailAccount(Base, BaseMixin):
|
class MailAccount(Base, BaseMixin):
|
||||||
@@ -66,7 +66,7 @@ class MailAccount(Base, BaseMixin):
|
|||||||
protocol = Column(String(255))
|
protocol = Column(String(255))
|
||||||
user_name = Column(String(255))
|
user_name = Column(String(255))
|
||||||
password = Column(String(255))
|
password = Column(String(255))
|
||||||
start_tls = Column(BIT(1))
|
start_tls = Column(Boolean)
|
||||||
|
|
||||||
|
|
||||||
class Mail(Base, BaseMixin):
|
class Mail(Base, BaseMixin):
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from sqlalchemy import func, Column, String
|
from sqlalchemy import Boolean, func, Column, String
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
|
||||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ class BaseVideoMixin:
|
|||||||
cloud_link = Column(String(255))
|
cloud_link = Column(String(255))
|
||||||
file_name = Column(String(255))
|
file_name = Column(String(255))
|
||||||
path = Column(String(255))
|
path = Column(String(255))
|
||||||
review = Column(BIT(1))
|
review = Column(Boolean)
|
||||||
title = Column(String(255))
|
title = Column(String(255))
|
||||||
url = Column(String(255), unique=True)
|
url = Column(String(255), unique=True)
|
||||||
should_download = Column(BIT(1))
|
should_download = Column(Boolean)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import Base, BaseMixin
|
from .base import Base, BaseMixin
|
||||||
@@ -22,8 +21,8 @@ class Comic(Base, BaseMixin):
|
|||||||
title = Column(String(length=255), unique=True)
|
title = Column(String(length=255), unique=True)
|
||||||
publisher_id = Column(String, ForeignKey('publisher.id'), nullable=False)
|
publisher_id = Column(String, ForeignKey('publisher.id'), nullable=False)
|
||||||
publisher = relationship("Publisher", back_populates="comics")
|
publisher = relationship("Publisher", back_populates="comics")
|
||||||
current_order = Column(BIT(1))
|
current_order = Column(Boolean)
|
||||||
completed = Column(BIT(1))
|
completed = Column(Boolean)
|
||||||
issues = relationship("Issue")
|
issues = relationship("Issue")
|
||||||
story_arcs = relationship("StoryArc")
|
story_arcs = relationship("StoryArc")
|
||||||
trade_paperbacks = relationship("TradePaperback")
|
trade_paperbacks = relationship("TradePaperback")
|
||||||
@@ -64,8 +63,8 @@ class StoryArc(Base, BaseMixin):
|
|||||||
class Issue(Base, BaseMixin):
|
class Issue(Base, BaseMixin):
|
||||||
__tablename__ = "issue"
|
__tablename__ = "issue"
|
||||||
issue_number = Column(String(255))
|
issue_number = Column(String(255))
|
||||||
in_stock = Column(BIT(1))
|
in_stock = Column(Boolean)
|
||||||
is_read = Column(BIT(1))
|
is_read = Column(Boolean)
|
||||||
comic_id = Column(String, ForeignKey("comic.id"), nullable=False)
|
comic_id = Column(String, ForeignKey("comic.id"), nullable=False)
|
||||||
comic = relationship("Comic", back_populates="issues")
|
comic = relationship("Comic", back_populates="issues")
|
||||||
volume_id = Column(String, ForeignKey("volume.id"), nullable=True)
|
volume_id = Column(String, ForeignKey("volume.id"), nullable=True)
|
||||||
|
|||||||
@@ -330,8 +330,8 @@ class KontorDB:
|
|||||||
media_file.last_modified_date = datetime.now()
|
media_file.last_modified_date = datetime.now()
|
||||||
media_file.version = 0
|
media_file.version = 0
|
||||||
media_file.url = link
|
media_file.url = link
|
||||||
media_file.review = 1
|
media_file.review = True
|
||||||
media_file.should_download = 1
|
media_file.should_download = True
|
||||||
try:
|
try:
|
||||||
session.add(media_file)
|
session.add(media_file)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from sqlalchemy import Column, DateTime, Integer, String, ForeignKey
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String, ForeignKey
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import Base, BaseMixin, BaseVideoMixin
|
from .base import Base, BaseMixin, BaseVideoMixin
|
||||||
@@ -29,10 +28,10 @@ class MediaFile(Base, BaseMixin, BaseVideoMixin):
|
|||||||
soup = BeautifulSoup(r.content, "html.parser")
|
soup = BeautifulSoup(r.content, "html.parser")
|
||||||
title = soup.title.string
|
title = soup.title.string
|
||||||
self.title = title
|
self.title = title
|
||||||
self.review = 0
|
self.review = False
|
||||||
except:
|
except:
|
||||||
self.title = None
|
self.title = None
|
||||||
self.review = 1
|
self.review = True
|
||||||
self.last_modified_date = datetime.now()
|
self.last_modified_date = datetime.now()
|
||||||
|
|
||||||
def download_file(self, download_dir: str, dl_tool: str):
|
def download_file(self, download_dir: str, dl_tool: str):
|
||||||
@@ -44,12 +43,12 @@ class MediaFile(Base, BaseMixin, BaseVideoMixin):
|
|||||||
lines_list = output.splitlines()
|
lines_list = output.splitlines()
|
||||||
file_name = self.__parse_output__(lines_list)
|
file_name = self.__parse_output__(lines_list)
|
||||||
if file_name is None:
|
if file_name is None:
|
||||||
self.review = 1
|
self.review = True
|
||||||
self.should_download = 1
|
self.should_download = True
|
||||||
self.file_name = None
|
self.file_name = None
|
||||||
else:
|
else:
|
||||||
download_file = Path(file_name)
|
download_file = Path(file_name)
|
||||||
self.should_download = 0
|
self.should_download = False
|
||||||
self.file_name = download_file.name
|
self.file_name = download_file.name
|
||||||
self.cloud_link = str(download_file.absolute())
|
self.cloud_link = str(download_file.absolute())
|
||||||
self.last_modified_date = datetime.now()
|
self.last_modified_date = datetime.now()
|
||||||
@@ -84,7 +83,7 @@ class MediaActorFile(Base, BaseMixin):
|
|||||||
|
|
||||||
class MediaArticle(Base, BaseMixin):
|
class MediaArticle(Base, BaseMixin):
|
||||||
__tablename__ = 'media_article'
|
__tablename__ = 'media_article'
|
||||||
review = Column(BIT(1))
|
review = Column(Boolean)
|
||||||
title = Column(String(255))
|
title = Column(String(255))
|
||||||
url = Column(String(255), unique=True)
|
url = Column(String(255), unique=True)
|
||||||
|
|
||||||
@@ -94,7 +93,7 @@ class MediaVideo(Base, BaseMixin):
|
|||||||
cloud_link = Column(String(255))
|
cloud_link = Column(String(255))
|
||||||
file_name = Column(String(255))
|
file_name = Column(String(255))
|
||||||
path = Column(String(255))
|
path = Column(String(255))
|
||||||
review = Column(BIT(1))
|
review = Column(Boolean)
|
||||||
title = Column(String(255))
|
title = Column(String(255))
|
||||||
url = Column(String(255), unique=True)
|
url = Column(String(255), unique=True)
|
||||||
should_download = Column(BIT(1))
|
should_download = Column(Boolean)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from sqlalchemy import Column, String, ForeignKey, DateTime, Integer, Boolean
|
from sqlalchemy import Column, String, ForeignKey, DateTime, Integer, Boolean
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import Base, BaseMixin
|
from .base import Base, BaseMixin
|
||||||
@@ -28,8 +27,8 @@ class MetaDataColumn(Base, BaseMixin):
|
|||||||
table = relationship("MetaDataTable", back_populates="table_columns")
|
table = relationship("MetaDataTable", back_populates="table_columns")
|
||||||
column_label = Column(String(255))
|
column_label = Column(String(255))
|
||||||
filter_label = Column(String(255))
|
filter_label = Column(String(255))
|
||||||
is_shown = Column(BIT(1))
|
is_shown = Column(Boolean)
|
||||||
show_filter = Column(BIT(1))
|
show_filter = Column(Boolean)
|
||||||
ref_column = Column(String, nullable=True)
|
ref_column = Column(String, nullable=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from sqlalchemy import Column, DateTime, Integer, String, ForeignKey, UniqueConstraint
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String, ForeignKey, UniqueConstraint
|
||||||
from sqlalchemy.dialects.mysql import BIT
|
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import Base, BaseMixin
|
from .base import Base, BaseMixin
|
||||||
@@ -78,8 +77,8 @@ class CardSet(Base, BaseMixin):
|
|||||||
UniqueConstraint("name", "vendor_id"),
|
UniqueConstraint("name", "vendor_id"),
|
||||||
)
|
)
|
||||||
name = Column(String(255), index=True)
|
name = Column(String(255), index=True)
|
||||||
parallel_set = Column(BIT(1))
|
parallel_set = Column(Boolean)
|
||||||
insert_set = Column(BIT(1))
|
insert_set = Column(Boolean)
|
||||||
vendor_id = Column(String, ForeignKey("vendor.id"), nullable=False, index=True)
|
vendor_id = Column(String, ForeignKey("vendor.id"), nullable=False, index=True)
|
||||||
vendor = relationship("Vendor", back_populates="card_sets")
|
vendor = relationship("Vendor", back_populates="card_sets")
|
||||||
cards = relationship("Card")
|
cards = relationship("Card")
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
import pytest
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
|
||||||
client = TestClient(app)
|
@pytest.fixture(name="client")
|
||||||
|
def client_fixture():
|
||||||
|
client = TestClient(app)
|
||||||
|
yield client
|
||||||
|
|
||||||
def test_get_authors():
|
|
||||||
|
def test_get_artists(client: TestClient):
|
||||||
response = client.get("/comic/artists")
|
response = client.get("/comic/artists")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert len(response.json()) == 5
|
assert len(response.json()) == 5
|
||||||
|
|||||||
Reference in New Issue
Block a user