mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
[ISSUE-3/4] Adds test container and tooling (#8)
* Adding black, isort, and flake8 to pytest * Applying black, flake8, and isort to codebase
This commit is contained in:
@@ -7,4 +7,5 @@
|
||||
!comic
|
||||
!comic_auth
|
||||
!manage.py
|
||||
!pytest
|
||||
!pyproject.toml
|
||||
!setup.cfg
|
||||
2
Pipfile
2
Pipfile
@@ -7,7 +7,9 @@ verify_ssl = true
|
||||
pdbpp = "*"
|
||||
pytest-django = "*"
|
||||
pytest-black = "*"
|
||||
pytest-cov = "*"
|
||||
pytest-flake8 = "*"
|
||||
pytest-isort = "*"
|
||||
|
||||
[packages]
|
||||
ujson = "*"
|
||||
|
||||
69
Pipfile.lock
generated
69
Pipfile.lock
generated
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "6ac08e443037cce0633c9272ad59f12fc7924be76f4cc10222825dc09d16b661"
|
||||
"sha256": "94f40433522196e554c531ddae0e2491a8713bbd73132c710ae1844aed548f3d"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@@ -292,13 +292,41 @@
|
||||
],
|
||||
"version": "==7.0"
|
||||
},
|
||||
"colorama": {
|
||||
"coverage": {
|
||||
"hashes": [
|
||||
"sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d",
|
||||
"sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"
|
||||
"sha256:3684fabf6b87a369017756b551cef29e505cb155ddb892a7a29277b978da88b9",
|
||||
"sha256:39e088da9b284f1bd17c750ac672103779f7954ce6125fd4382134ac8d152d74",
|
||||
"sha256:3c205bc11cc4fcc57b761c2da73b9b72a59f8d5ca89979afb0c1c6f9e53c7390",
|
||||
"sha256:465ce53a8c0f3a7950dfb836438442f833cf6663d407f37d8c52fe7b6e56d7e8",
|
||||
"sha256:48020e343fc40f72a442c8a1334284620f81295256a6b6ca6d8aa1350c763bbe",
|
||||
"sha256:5296fc86ab612ec12394565c500b412a43b328b3907c0d14358950d06fd83baf",
|
||||
"sha256:5f61bed2f7d9b6a9ab935150a6b23d7f84b8055524e7be7715b6513f3328138e",
|
||||
"sha256:68a43a9f9f83693ce0414d17e019daee7ab3f7113a70c79a3dd4c2f704e4d741",
|
||||
"sha256:6b8033d47fe22506856fe450470ccb1d8ba1ffb8463494a15cfc96392a288c09",
|
||||
"sha256:7ad7536066b28863e5835e8cfeaa794b7fe352d99a8cded9f43d1161be8e9fbd",
|
||||
"sha256:7bacb89ccf4bedb30b277e96e4cc68cd1369ca6841bde7b005191b54d3dd1034",
|
||||
"sha256:839dc7c36501254e14331bcb98b27002aa415e4af7ea039d9009409b9d2d5420",
|
||||
"sha256:8f9a95b66969cdea53ec992ecea5406c5bd99c9221f539bca1e8406b200ae98c",
|
||||
"sha256:932c03d2d565f75961ba1d3cec41ddde00e162c5b46d03f7423edcb807734eab",
|
||||
"sha256:988529edadc49039d205e0aa6ce049c5ccda4acb2d6c3c5c550c17e8c02c05ba",
|
||||
"sha256:998d7e73548fe395eeb294495a04d38942edb66d1fa61eb70418871bc621227e",
|
||||
"sha256:9de60893fb447d1e797f6bf08fdf0dbcda0c1e34c1b06c92bd3a363c0ea8c609",
|
||||
"sha256:9e80d45d0c7fcee54e22771db7f1b0b126fb4a6c0a2e5afa72f66827207ff2f2",
|
||||
"sha256:a545a3dfe5082dc8e8c3eb7f8a2cf4f2870902ff1860bd99b6198cfd1f9d1f49",
|
||||
"sha256:a5d8f29e5ec661143621a8f4de51adfb300d7a476224156a39a392254f70687b",
|
||||
"sha256:aca06bfba4759bbdb09bf52ebb15ae20268ee1f6747417837926fae990ebc41d",
|
||||
"sha256:bb23b7a6fd666e551a3094ab896a57809e010059540ad20acbeec03a154224ce",
|
||||
"sha256:bfd1d0ae7e292105f29d7deaa9d8f2916ed8553ab9d5f39ec65bcf5deadff3f9",
|
||||
"sha256:c62ca0a38958f541a73cf86acdab020c2091631c137bd359c4f5bddde7b75fd4",
|
||||
"sha256:c709d8bda72cf4cd348ccec2a4881f2c5848fd72903c185f363d361b2737f773",
|
||||
"sha256:c968a6aa7e0b56ecbd28531ddf439c2ec103610d3e2bf3b75b813304f8cb7723",
|
||||
"sha256:df785d8cb80539d0b55fd47183264b7002077859028dfe3070cf6359bf8b2d9c",
|
||||
"sha256:f406628ca51e0ae90ae76ea8398677a921b36f0bd71aab2099dfed08abd0322f",
|
||||
"sha256:f46087bbd95ebae244a0eda01a618aff11ec7a069b15a3ef8f6b520db523dcf1",
|
||||
"sha256:f8019c5279eb32360ca03e9fac40a12667715546eed5c5eb59eb381f2f501260",
|
||||
"sha256:fc5f4d209733750afd2714e9109816a29500718b32dd9a5db01c0cb3a019b96a"
|
||||
],
|
||||
"markers": "sys_platform == 'win32'",
|
||||
"version": "==0.4.1"
|
||||
"version": "==4.5.3"
|
||||
},
|
||||
"entrypoints": {
|
||||
"hashes": [
|
||||
@@ -328,6 +356,13 @@
|
||||
],
|
||||
"version": "==0.18"
|
||||
},
|
||||
"isort": {
|
||||
"hashes": [
|
||||
"sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1",
|
||||
"sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"
|
||||
],
|
||||
"version": "==4.3.21"
|
||||
},
|
||||
"mccabe": {
|
||||
"hashes": [
|
||||
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
|
||||
@@ -393,10 +428,10 @@
|
||||
},
|
||||
"pyparsing": {
|
||||
"hashes": [
|
||||
"sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a",
|
||||
"sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03"
|
||||
"sha256:43c5486cefefa536c9aab528881c992328f020eefe4f6d06332449c365218580",
|
||||
"sha256:d6c5ffe9d0305b9b977f7a642d36b9370954d1da7ada4c62393382cbadad4265"
|
||||
],
|
||||
"version": "==2.4.0"
|
||||
"version": "==2.4.1.1"
|
||||
},
|
||||
"pyreadline": {
|
||||
"hashes": [
|
||||
@@ -418,6 +453,14 @@
|
||||
"index": "pypi",
|
||||
"version": "==0.3.7"
|
||||
},
|
||||
"pytest-cov": {
|
||||
"hashes": [
|
||||
"sha256:2b097cde81a302e1047331b48cadacf23577e431b61e9c6f49a1170bbe3d3da6",
|
||||
"sha256:e00ea4fdde970725482f1f35630d12f074e121a23801aabf2ae154ec6bdd343a"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.7.1"
|
||||
},
|
||||
"pytest-django": {
|
||||
"hashes": [
|
||||
"sha256:264fb4c506db5d48a6364c311a0b00b7b48a52715bad8839b2d8bee9b99ed6bb",
|
||||
@@ -434,6 +477,14 @@
|
||||
"index": "pypi",
|
||||
"version": "==1.0.4"
|
||||
},
|
||||
"pytest-isort": {
|
||||
"hashes": [
|
||||
"sha256:3be60e0de277b420ff89303ca6494320c41f7819ffa898756b90ef976e4c636a",
|
||||
"sha256:4bfee60dad1870b51700d55a85f5ceda766bd9d3d2878c1bbabee80e61b1be1a"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.3.1"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from comic.models import Setting, ComicBook, ComicPage, ComicStatus, Directory
|
||||
from comic.models import ComicBook, ComicPage, ComicStatus, Directory, Setting
|
||||
|
||||
|
||||
@admin.register(Setting)
|
||||
|
||||
@@ -3,7 +3,7 @@ from os.path import isdir
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from comic.models import Setting, Directory, ComicBook
|
||||
from comic.models import ComicBook, Directory, Setting
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.utils.timezone import utc
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# Generated by Django 1.9.2 on 2016-03-31 10:40
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
import uuid
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def gen_uuid(apps, schema_editor):
|
||||
comicbook = apps.get_model("comic", "comicbook")
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# Generated by Django 1.9.2 on 2016-03-31 10:40
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
import uuid
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
# Generated by Django 1.9.2 on 2016-04-01 08:49
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ def gen_feeds(apps, schema_editor):
|
||||
user_misc = apps.get_model("comic", "UserMisc")
|
||||
User = apps.get_model("auth", "user")
|
||||
for user in User.objects.all():
|
||||
um = user_misc.objects.create(user=user)
|
||||
user_misc.objects.create(user=user)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import uuid
|
||||
import zipfile
|
||||
from os import path, listdir
|
||||
from os import listdir, path
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
@@ -83,12 +83,15 @@ __all__ = ["is_rarfile", "RarInfo", "RarFile", "RarExtFile"]
|
||||
## Imports and compat - support both Python 2.x and 3.x
|
||||
##
|
||||
|
||||
import sys, os, struct, errno
|
||||
from struct import pack, unpack
|
||||
import errno
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
from binascii import crc32
|
||||
from tempfile import mkstemp
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from datetime import datetime
|
||||
from struct import pack, unpack
|
||||
from subprocess import PIPE, STDOUT, Popen
|
||||
from tempfile import mkstemp
|
||||
|
||||
# only needed for encryped headers
|
||||
try:
|
||||
|
||||
@@ -3,10 +3,10 @@ import os
|
||||
from os import path
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase, Client
|
||||
from django.test import Client, TestCase
|
||||
from django.utils.http import urlsafe_base64_encode
|
||||
|
||||
from comic.models import ComicBook, ComicPage, Setting, ComicStatus, Directory
|
||||
from comic.models import ComicBook, ComicPage, ComicStatus, Directory, Setting
|
||||
from comic.util import generate_directory
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import feeds
|
||||
from . import views
|
||||
from . import feeds, views
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", views.comic_list, name="index"),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from collections import OrderedDict
|
||||
from os import path, listdir
|
||||
from os import listdir, path
|
||||
|
||||
from django.db.transaction import atomic
|
||||
from django.utils.http import urlsafe_base64_encode
|
||||
|
||||
from .models import ComicBook, Setting, ComicStatus, Directory
|
||||
from .models import ComicBook, ComicStatus, Directory, Setting
|
||||
|
||||
|
||||
def generate_title_from_path(file_path):
|
||||
|
||||
@@ -5,26 +5,26 @@ except ImportError:
|
||||
import uuid
|
||||
from os import path
|
||||
|
||||
from django.contrib.auth import login, authenticate
|
||||
from django.contrib.auth import authenticate, login
|
||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Max
|
||||
from django.db.transaction import atomic
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from .forms import SettingsForm, AccountForm, EditUserForm, AddUserForm, InitialSetupForm
|
||||
from .models import Setting, ComicBook, ComicStatus, Directory, ComicPage, UserMisc
|
||||
from .forms import AccountForm, AddUserForm, EditUserForm, InitialSetupForm, SettingsForm
|
||||
from .models import ComicBook, ComicPage, ComicStatus, Directory, Setting, UserMisc
|
||||
from .util import (
|
||||
generate_breadcrumbs_from_path,
|
||||
generate_breadcrumbs_from_menu,
|
||||
generate_title_from_path,
|
||||
Menu,
|
||||
generate_breadcrumbs_from_menu,
|
||||
generate_breadcrumbs_from_path,
|
||||
generate_directory,
|
||||
generate_label,
|
||||
generate_title_from_path,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib.auth.models import User
|
||||
from django.shortcuts import render, redirect
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from comic_auth.forms import LoginForm
|
||||
|
||||
|
||||
24
docker-compose.override.yml
Normal file
24
docker-compose.override.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
tests:
|
||||
build: .
|
||||
environment:
|
||||
- TEST_DATABASE_URL=postgres://admin:password@database:5432/cbwebreader_test
|
||||
- DJANGO_SETTINGS_MODULE=cbreader.settings.base
|
||||
links:
|
||||
- database
|
||||
command: >
|
||||
pytest
|
||||
-vvv
|
||||
--isort
|
||||
--flake8
|
||||
--black
|
||||
--cov=.
|
||||
--cov-report=term-missing
|
||||
--junitxml=/tmp/test-results.xml
|
||||
volumes:
|
||||
- ./cbreader:/src/cbreader
|
||||
- ./comic:/src/comic
|
||||
- ./comic_auth:/src/comic_auth
|
||||
- ${COMIC_BOOK_VOLUME}:/data
|
||||
@@ -1,7 +1,6 @@
|
||||
version: '3.7'
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
|
||||
app:
|
||||
build: .
|
||||
environment:
|
||||
@@ -15,11 +14,11 @@ services:
|
||||
- database
|
||||
ports:
|
||||
- "8000:8000"
|
||||
# volumes:
|
||||
# - ./cbreader:/src/cbreader
|
||||
# - ./comic:/src/comic
|
||||
# - ./comic_auth:/src/comic_auth
|
||||
# - ${COMIC_BOOK_VOLUME}:/data
|
||||
volumes:
|
||||
- ./cbreader:/src/cbreader
|
||||
- ./comic:/src/comic
|
||||
- ./comic_auth:/src/comic_auth
|
||||
- ${COMIC_BOOK_VOLUME}:/data
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
|
||||
database:
|
||||
|
||||
21
setup.cfg
Normal file
21
setup.cfg
Normal file
@@ -0,0 +1,21 @@
|
||||
[tool:pytest]
|
||||
addopts = -vv --black --isort --flake8
|
||||
|
||||
[flake8]
|
||||
max-line-length = 119
|
||||
ignore =
|
||||
# Ignore rules which contradicts black's formatting choices:
|
||||
* E501
|
||||
* W503
|
||||
* W504
|
||||
* E266
|
||||
exclude =
|
||||
# Exclude these files
|
||||
comic/rarfile.py
|
||||
|
||||
|
||||
[tool:isort]
|
||||
line_length = 119
|
||||
indent = ' '
|
||||
multi_line_output = 3
|
||||
include_trailing_comma = 1
|
||||
Reference in New Issue
Block a user