From c75fa2f669e166d9157c3212e7699de5893290e4 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Wed, 27 Apr 2022 03:04:55 +0200 Subject: [PATCH] PEP8 --- README.md | 2 +- dbmigration/create_empty_db.py | 12 ++++++------ dbmigration/migrate_from_1.1_to_2.0.py | 20 +++++++++++--------- flake8.ini | 1 - tests/test_api.py | 1 + 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 98b075e..d350d06 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![GitLicense](https://gitlicense.com/badge/kianby/stacosys)](https://gitlicense.com/license/kianby/stacosys) [![Python version](https://img.shields.io/badge/Python-3.9-blue.svg)](https://www.python.org/) [![Flask version](https://img.shields.io/badge/Flask-2.0.1-green.svg)](https://flask.palletsprojects.com) [![Peewee version](https://img.shields.io/badge/Peewee-3.14.0-green.svg)](https://docs.peewee-orm.com/) -[![Build Status - pytest](https://github.com/kianby/stacosys/workflows/pytest/badge.svg)](https://github.com/kianby/stacosys) [![Coverage Status](https://coveralls.io/repos/github/kianby/stacosys/badge.svg?branch=main)](https://coveralls.io/github/kianby/stacosys?branch=main) [![Build status - docker image](https://github.com/kianby/stacosys/workflows/docker/badge.svg)](https://hub.docker.com/r/kianby/stacosys) +[![Build Status - pytest](https://github.com/kianby/stacosys/workflows/pytest/badge.svg)](https://github.com/kianby/stacosys) [![Coverage Status](https://coveralls.io/repos/github/kianby/stacosys/badge.svg?branch=main)](https://coveralls.io/github/kianby/stacosys?branch=main) [![Build status - docker image](https://github.com/kianby/stacosys/workflows/docker/badge.svg)](https://hub.docker.com/r/kianby/stacosys) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) ## Stacosys diff --git a/dbmigration/create_empty_db.py b/dbmigration/create_empty_db.py index 987eab1..50bd0f2 100644 --- a/dbmigration/create_empty_db.py +++ b/dbmigration/create_empty_db.py @@ -8,15 +8,15 @@ cursor = connection.cursor() script = """ CREATE TABLE comment ( - id INTEGER NOT NULL PRIMARY KEY, - url VARCHAR(255) NOT NULL, + id INTEGER NOT NULL PRIMARY KEY, + url VARCHAR(255) NOT NULL, notified DATETIME, - created DATETIME NOT NULL, - published DATETIME, - author_name VARCHAR(255) NOT NULL, + created DATETIME NOT NULL, + published DATETIME, + author_name VARCHAR(255) NOT NULL, author_site VARCHAR(255) NOT NULL, author_gravatar varchar(255), - content TEXT NOT NULL + content TEXT NOT NULL , ulid INTEGER); """ diff --git a/dbmigration/migrate_from_1.1_to_2.0.py b/dbmigration/migrate_from_1.1_to_2.0.py index 9870d25..e86c433 100644 --- a/dbmigration/migrate_from_1.1_to_2.0.py +++ b/dbmigration/migrate_from_1.1_to_2.0.py @@ -8,25 +8,27 @@ cursor = connection.cursor() # What script performs: # - first, remove site table: crash here if table doesn't exist (compatibility test without effort) -# - remove site_id colum from comment table +# - remove site_id column from comment table script = """ PRAGMA foreign_keys = OFF; BEGIN TRANSACTION; DROP TABLE site; ALTER TABLE comment RENAME TO _comment_old; CREATE TABLE comment ( - id INTEGER NOT NULL PRIMARY KEY, - url VARCHAR(255) NOT NULL, + id INTEGER NOT NULL PRIMARY KEY, + url VARCHAR(255) NOT NULL, notified DATETIME, - created DATETIME NOT NULL, - published DATETIME, - author_name VARCHAR(255) NOT NULL, + created DATETIME NOT NULL, + published DATETIME, + author_name VARCHAR(255) NOT NULL, author_site VARCHAR(255) NOT NULL, author_gravatar varchar(255), - content TEXT NOT NULL + content TEXT NOT NULL ); -INSERT INTO comment (id, url, notified, created, published, author_name, author_site, author_gravatar, content) - SELECT id, url, notified, created, published, author_name, author_site, author_gravatar, content +INSERT INTO comment (id, url, notified, created, published, + author_name, author_site, author_gravatar, content) + SELECT id, url, notified, created, published, + author_name, author_site, author_gravatar, content FROM _comment_old; DROP TABLE _comment_old; COMMIT; diff --git a/flake8.ini b/flake8.ini index 01ad95a..9b8e5e8 100644 --- a/flake8.ini +++ b/flake8.ini @@ -1,5 +1,4 @@ [flake8] max-line-length = 88 extend-ignore = E203 -exclude = */tests/* spellcheck-targets=comments diff --git a/tests/test_api.py b/tests/test_api.py index a2b7033..6cb2196 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -17,6 +17,7 @@ def init_test_db(): c3 = dao.create_comment("/site3", "Jack", "/jack.site", "", "comment 3") dao.publish_comment(c1) dao.publish_comment(c3) + assert c2 @pytest.fixture