Browse Source

Final fixes

Getty Ritter 1 year ago
parent
commit
943ba09f33
3 changed files with 16 additions and 3 deletions
  1. 2 0
      .flake8
  2. 9 3
      lc/model.py
  3. 5 0
      tests/config.py

+ 2 - 0
.flake8

@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100

+ 9 - 3
lc/model.py

@@ -106,7 +106,8 @@ class User(Model):
         self, as_user: Optional["User"], page: int
     ) -> Tuple[List[v.Link], v.Pagination]:
         query = Link.select().where(
-            (Link.user == self) & ((self == as_user) | (Link.private == False))  # noqa: E712
+            (Link.user == self)
+            & ((self == as_user) | (Link.private == False))  # noqa: E712
         )
         links = query.order_by(-Link.created).paginate(page, c.app.per_page)
         link_views = [link.to_view(as_user) for link in links]
@@ -162,7 +163,9 @@ class User(Model):
         with self.atomic():
             for link in links:
                 try:
-                    time = datetime.datetime.strptime(link["time"], "%Y-%m-%dT%H:%M:%SZ")
+                    time = datetime.datetime.strptime(
+                        link["time"], "%Y-%m-%dT%H:%M:%SZ"
+                    )
                     ln = Link.create(
                         url=link["href"],
                         name=link["description"],
@@ -331,7 +334,10 @@ class Tag(Model):
             .join(Link)
             .where(
                 (HasTag.tag == self)
-                & ((HasTag.link.user == as_user) | (HasTag.link.private == False))  # noqa: E712
+                & (
+                    (HasTag.link.user == as_user)
+                    | (HasTag.link.private == False)  # noqa: E712
+                )
             )
         )
         links = [

+ 5 - 0
tests/config.py

@@ -0,0 +1,5 @@
+import os
+
+os.environ["LC_DB_PATH"] = ":memory:"
+os.environ["LC_SECRET_KEY"] = "TEST_KEY"
+os.environ["LC_APP_PATH"] = "localhost"