added new tests for more coverage & drone cleanup
This commit is contained in:
parent
925506ca47
commit
790f3f0049
8 changed files with 290 additions and 83 deletions
124
.drone.yml
124
.drone.yml
|
@ -14,27 +14,13 @@ trigger:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|
||||||
# anchors
|
|
||||||
sq_secrets: &sq_secrets
|
|
||||||
sonar_host: 'https://sonarqube.44net.ch'
|
|
||||||
sonar_token:
|
|
||||||
from_secret: sq-44net-token
|
|
||||||
|
|
||||||
sq_analysis: &sq_analysis
|
|
||||||
image: 'cr.44net.ch/drone-plugins/sonarqube'
|
|
||||||
pull: if-not-exists
|
|
||||||
group: test
|
|
||||||
|
|
||||||
test_plugin: &test_plugin
|
|
||||||
image: 'cr.44net.ch/drone-plugins/test'
|
|
||||||
pull: if-not-exists
|
|
||||||
group: publish
|
|
||||||
|
|
||||||
# steps
|
# steps
|
||||||
steps:
|
steps:
|
||||||
# test python code
|
# test python code
|
||||||
- name: 'test code and generate coverage report'
|
- name: 'test code and generate coverage report'
|
||||||
<<: *test_plugin
|
image: 'cr.44net.ch/drone-plugins/test'
|
||||||
|
pull: if-not-exists
|
||||||
|
group: publish
|
||||||
commands:
|
commands:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- coverage erase
|
- coverage erase
|
||||||
|
@ -43,9 +29,13 @@ steps:
|
||||||
|
|
||||||
# upload analysis to sonarqube
|
# upload analysis to sonarqube
|
||||||
- name: 'sonarqube: analyse code'
|
- name: 'sonarqube: analyse code'
|
||||||
<<: *sq_analysis
|
image: 'cr.44net.ch/drone-plugins/sonarqube'
|
||||||
|
pull: if-not-exists
|
||||||
|
group: test
|
||||||
settings:
|
settings:
|
||||||
<<: *sq_secrets
|
sonar_host: 'https://sonarqube.44net.ch'
|
||||||
|
sonar_token:
|
||||||
|
from_secret: sq-44net-token
|
||||||
usingProperties: true
|
usingProperties: true
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,29 +55,22 @@ trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
# anchors
|
|
||||||
cr_secrets: &cr_secrets
|
|
||||||
username:
|
|
||||||
from_secret: cr-dhub-username
|
|
||||||
password:
|
|
||||||
from_secret: cr-dhub-key
|
|
||||||
|
|
||||||
docker_build: &docker_build
|
|
||||||
image: plugins/docker
|
|
||||||
pull: if-not-exists
|
|
||||||
group: build
|
|
||||||
|
|
||||||
# build steps arm64
|
# build steps arm64
|
||||||
steps:
|
steps:
|
||||||
- name: 'build and publish docker image'
|
- name: 'build and publish docker image'
|
||||||
<<: *docker_build
|
image: plugins/docker
|
||||||
|
pull: if-not-exists
|
||||||
|
group: build
|
||||||
settings:
|
settings:
|
||||||
repo: olofvndrhr/manga-dlp
|
repo: olofvndrhr/manga-dlp
|
||||||
context: docker
|
context: docker
|
||||||
dockerfile: docker/Dockerfile.arm64
|
dockerfile: docker/Dockerfile.arm64
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm64
|
auto_tag_suffix: linux-arm64
|
||||||
<<: *cr_secrets
|
username:
|
||||||
|
from_secret: cr-dhub-username
|
||||||
|
password:
|
||||||
|
from_secret: cr-dhub-key
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -103,29 +86,22 @@ trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
# anchors
|
|
||||||
cr_secrets: &cr_secrets
|
|
||||||
username:
|
|
||||||
from_secret: cr-dhub-username
|
|
||||||
password:
|
|
||||||
from_secret: cr-dhub-key
|
|
||||||
|
|
||||||
docker_build: &docker_build
|
|
||||||
image: plugins/docker
|
|
||||||
pull: if-not-exists
|
|
||||||
group: build
|
|
||||||
|
|
||||||
# build steps amd64
|
# build steps amd64
|
||||||
steps:
|
steps:
|
||||||
- name: 'build and publish docker image'
|
- name: 'build and publish docker image'
|
||||||
<<: *docker_build
|
image: plugins/docker
|
||||||
|
pull: if-not-exists
|
||||||
|
group: build
|
||||||
settings:
|
settings:
|
||||||
repo: olofvndrhr/manga-dlp
|
repo: olofvndrhr/manga-dlp
|
||||||
context: docker
|
context: docker
|
||||||
dockerfile: docker/Dockerfile.amd64
|
dockerfile: docker/Dockerfile.amd64
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64
|
auto_tag_suffix: linux-amd64
|
||||||
<<: *cr_secrets
|
username:
|
||||||
|
from_secret: cr-dhub-username
|
||||||
|
password:
|
||||||
|
from_secret: cr-dhub-key
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -141,13 +117,6 @@ trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
# anchors
|
|
||||||
cr_secrets: &cr_secrets
|
|
||||||
username:
|
|
||||||
from_secret: cr-dhub-username
|
|
||||||
password:
|
|
||||||
from_secret: cr-dhub-key
|
|
||||||
|
|
||||||
# build steps
|
# build steps
|
||||||
steps:
|
steps:
|
||||||
- name: 'publish manifest'
|
- name: 'publish manifest'
|
||||||
|
@ -156,16 +125,19 @@ steps:
|
||||||
spec: docker/manifest.tmpl
|
spec: docker/manifest.tmpl
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
ignore_missing: true
|
ignore_missing: true
|
||||||
<<: *cr_secrets
|
username:
|
||||||
|
from_secret: cr-dhub-username
|
||||||
|
password:
|
||||||
|
from_secret: cr-dhub-key
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- docker-build-amd64
|
- docker-build-amd64
|
||||||
- docker-build-arm64
|
- docker-build-arm64
|
||||||
|
|
||||||
---
|
---
|
||||||
#################
|
###############
|
||||||
# gitea release #
|
# git release #
|
||||||
#################
|
###############
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: gitea-release
|
name: gitea-release
|
||||||
|
@ -178,37 +150,37 @@ trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
# anchors
|
# publish release on gitea and github
|
||||||
gitea_secrets: &gitea_secrets
|
steps:
|
||||||
api_key:
|
- name: 'create release tar'
|
||||||
from_secret: gitea-token
|
|
||||||
|
|
||||||
gitea_plugin: &gitea_plugin
|
|
||||||
image: plugins/gitea-release
|
|
||||||
pull: if-not-exists
|
|
||||||
group: publish
|
|
||||||
|
|
||||||
tar_plugin: &tar_plugin
|
|
||||||
image: 'cr.44net.ch/baseimages/debian-base'
|
image: 'cr.44net.ch/baseimages/debian-base'
|
||||||
pull: if-not-exists
|
pull: if-not-exists
|
||||||
group: publish
|
group: publish
|
||||||
|
|
||||||
# publish release on gitea
|
|
||||||
steps:
|
|
||||||
- name: 'create release tar'
|
|
||||||
<<: *tar_plugin
|
|
||||||
commands:
|
commands:
|
||||||
- tar -czf manga-dlp-${DRONE_TAG}.tar.gz --files-from=release-files.txt
|
- tar -czf manga-dlp-${DRONE_TAG}.tar.gz --files-from=release-files.txt
|
||||||
|
|
||||||
- name: 'publish gitea release'
|
- name: 'publish gitea release'
|
||||||
<<: *gitea_plugin
|
image: plugins/gitea-release
|
||||||
|
pull: if-not-exists
|
||||||
|
group: publish
|
||||||
settings:
|
settings:
|
||||||
<<: *gitea_secrets
|
api_key:
|
||||||
|
from_secret: gitea-token
|
||||||
base_url: https://git.44net.ch
|
base_url: https://git.44net.ch
|
||||||
files: manga-dlp-${DRONE_TAG}.tar.gz
|
files: manga-dlp-${DRONE_TAG}.tar.gz
|
||||||
title: 'manga-dlp release: ${DRONE_TAG}'
|
title: 'manga-dlp release: ${DRONE_TAG}'
|
||||||
note: CHANGELOG.md
|
note: CHANGELOG.md
|
||||||
|
|
||||||
|
- name: 'publish github release'
|
||||||
|
image: plugins/github-release
|
||||||
|
pull: if-not-exists
|
||||||
|
group: publish
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: github-token
|
||||||
|
files: manga-dlp-${DRONE_TAG}.tar.gz
|
||||||
|
title: 'manga-dlp release: ${DRONE_TAG}'
|
||||||
|
note: CHANGELOG.md
|
||||||
|
|
||||||
#---
|
#---
|
||||||
#################
|
#################
|
||||||
|
|
|
@ -11,6 +11,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
- Add support for more sites
|
- Add support for more sites
|
||||||
|
|
||||||
|
|
||||||
|
## [2.0.4] - 2022-05-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- New test cases for more coverage
|
||||||
|
- Github release
|
||||||
|
- Updated docker baseimage
|
||||||
|
|
||||||
|
|
||||||
## [2.0.3] - 2022-05-10
|
## [2.0.3] - 2022-05-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM cr.44net.ch/baseimages/debian-s6:1.3.1
|
FROM cr.44net.ch/baseimages/debian-s6:1.3.4
|
||||||
|
|
||||||
# set version label
|
# set version label
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||||
LABEL maintainer="Ivan Schaller"
|
LABEL maintainer="Ivan Schaller"
|
||||||
|
|
||||||
# manga-dlp version
|
# manga-dlp version
|
||||||
ARG MDLP_VERSION=2.0.3
|
ARG MDLP_VERSION=2.0.4
|
||||||
|
|
||||||
# install packages
|
# install packages
|
||||||
RUN \
|
RUN \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM cr.44net.ch/baseimages/debian-s6:1.3.1
|
FROM cr.44net.ch/baseimages/debian-s6:1.3.4
|
||||||
|
|
||||||
# set version label
|
# set version label
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||||
LABEL maintainer="Ivan Schaller"
|
LABEL maintainer="Ivan Schaller"
|
||||||
|
|
||||||
# manga-dlp version
|
# manga-dlp version
|
||||||
ARG MDLP_VERSION=2.0.3
|
ARG MDLP_VERSION=2.0.4
|
||||||
|
|
||||||
# install packages
|
# install packages
|
||||||
RUN \
|
RUN \
|
||||||
|
|
|
@ -8,13 +8,17 @@ from zipfile import ZipFile
|
||||||
def make_archive(chapter_path):
|
def make_archive(chapter_path):
|
||||||
image_folder = Path(chapter_path)
|
image_folder = Path(chapter_path)
|
||||||
zip_path = Path(f"{chapter_path}.zip")
|
zip_path = Path(f"{chapter_path}.zip")
|
||||||
|
if not image_folder.exists():
|
||||||
|
print(f"ERR: Folder: {image_folder} does not exist")
|
||||||
|
return False
|
||||||
with ZipFile(f"{image_folder}.zip", "w") as zip_archive:
|
with ZipFile(f"{image_folder}.zip", "w") as zip_archive:
|
||||||
for file in image_folder.iterdir():
|
for file in image_folder.iterdir():
|
||||||
zip_archive.write(file, file.name)
|
zip_archive.write(file, file.name)
|
||||||
|
|
||||||
zip_path.rename(zip_path.with_suffix(".cbz"))
|
zip_path.rename(zip_path.with_suffix(".cbz"))
|
||||||
shutil.rmtree(image_folder)
|
shutil.rmtree(image_folder)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# check if the file already exists
|
# check if the file already exists
|
||||||
def check_existence(chapter_path, manga_nocbz):
|
def check_existence(chapter_path, manga_nocbz):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ long_description = readme.read_text()
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="manga-dlp",
|
name="manga-dlp",
|
||||||
version="2.0.3",
|
version="2.0.4",
|
||||||
author="Ivan Schaller",
|
author="Ivan Schaller",
|
||||||
author_email="ivan@schaller.sh",
|
author_email="ivan@schaller.sh",
|
||||||
description="A cli manga downloader",
|
description="A cli manga downloader",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
from mangadlp.api.mangadex import Mangadex
|
from mangadlp.api.mangadex import Mangadex
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,3 +47,134 @@ def test_chapter_infos():
|
||||||
"1",
|
"1",
|
||||||
"1",
|
"1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_chapter_lang_en():
|
||||||
|
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = False
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
assert test.check_chapter_lang() > 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_not_existing_lang():
|
||||||
|
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
|
lang = "zz"
|
||||||
|
forcevol = False
|
||||||
|
verbose = False
|
||||||
|
with pytest.raises(SystemExit) as e:
|
||||||
|
Mangadex(url, lang, forcevol, verbose)
|
||||||
|
assert e.type == SystemExit
|
||||||
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_filename():
|
||||||
|
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = False
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
assert test.get_filename("1") == "Ch. 1 - A Normal Person"
|
||||||
|
|
||||||
|
|
||||||
|
def test_filename_forcevol():
|
||||||
|
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = True
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
assert test.get_filename("1:4") == "Vol. 1 Ch. 4 - Bad at This"
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_chapter_list():
|
||||||
|
url = "https://mangadex.org/title/6fef1f74-a0ad-4f0d-99db-d32a7cd24098/fire-punch"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = False
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
test_list = [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12",
|
||||||
|
"13",
|
||||||
|
"14",
|
||||||
|
"15",
|
||||||
|
"16",
|
||||||
|
"17",
|
||||||
|
"18",
|
||||||
|
"19",
|
||||||
|
"20",
|
||||||
|
"21",
|
||||||
|
]
|
||||||
|
assert test.create_chapter_list() == test_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_chapter_list_forcevol():
|
||||||
|
url = "https://mangadex.org/title/6fef1f74-a0ad-4f0d-99db-d32a7cd24098/fire-punch"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = True
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
test_list = [
|
||||||
|
"1:1",
|
||||||
|
"1:2",
|
||||||
|
"1:3",
|
||||||
|
"1:4",
|
||||||
|
"1:5",
|
||||||
|
"1:6",
|
||||||
|
"1:7",
|
||||||
|
"1:8",
|
||||||
|
"2:9",
|
||||||
|
"2:10",
|
||||||
|
"2:11",
|
||||||
|
"2:12",
|
||||||
|
"2:13",
|
||||||
|
"2:14",
|
||||||
|
"2:15",
|
||||||
|
"2:16",
|
||||||
|
"2:17",
|
||||||
|
"2:18",
|
||||||
|
"3:19",
|
||||||
|
"3:20",
|
||||||
|
"3:21",
|
||||||
|
]
|
||||||
|
assert test.create_chapter_list() == test_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_chapter_images():
|
||||||
|
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||||
|
lang = "en"
|
||||||
|
forcevol = False
|
||||||
|
verbose = False
|
||||||
|
test = Mangadex(url, lang, forcevol, verbose)
|
||||||
|
img_base_url = "https://uploads.mangadex.org"
|
||||||
|
chapter_hash = "0752bc5db298beff6b932b9151dd8437"
|
||||||
|
chapter_uuid = "e86ec2c4-c5e4-4710-bfaa-7604f00939c7"
|
||||||
|
chapter_num = "1"
|
||||||
|
test_list = [
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x1-0deb4c9bfedd5be49e0a90cfb17cf343888239898c9e7451d569c0b3ea2971f4.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x2-48c954f2f3a38211a7f461967cbceb068558d92b993cf535b26da36dfe356bb5.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x3-4578e53162520f459a8329f5440d28257be4c6fb0c2dfdba43695dbd59623c11.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x4-5fb8eb5e405a8d006fd1d325fe7d2396d4a65f8e1cbe8a5ca205d63f30d9897b.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x5-8a6abe9f5d1993b1f132f6461852d954adcc3fb214c160cda39aa8be2c080694.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x6-44f4bb7754798762d3960b6b21d3d2c6a28aeb589c11c1b6c9685f9e495b3446.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x7-11f65ce481b588e276ce391a45a26f6ccbe9fd8c9cebe6334c53d21d6cddcfa0.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x8-f7e369b49b577f4d27f036520c3b53041ded8009bb50d140cda8f85f549baadd.png",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x9-61c39d0150d3acb9b3c590b6519278aa1c64019926e10e2905f5523e4e1fffdc.png",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x10-0b8d9b9c623e1824c45a862a57147166ec3f638ae983c8366338e4ae5f7d862a.png",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x11-ab4e73dc9cd24a47cbdd1223dcf37233ec17f00f21213ac24a225f45a431c27d.png",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x12-b26d1f605ea402145931ed29dd60820865daab82483d6527e1aa51592eebb2b8.png",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x13-54d9718036b9d79e930e448b592c4a3df9045ed5b8c22ab411b09dadb864756f.jpg",
|
||||||
|
f"{img_base_url}/data/{chapter_hash}/x14-f6ed71bbb9af2bceab51028b460813c57935c923e1872fb277beb21d54425434.jpg",
|
||||||
|
]
|
||||||
|
assert test.get_chapter_images(chapter_num, 0.5) == test_list
|
||||||
|
|
90
tests/test_utils.py
Normal file
90
tests/test_utils.py
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import mangadlp.utils as utils
|
||||||
|
|
||||||
|
|
||||||
|
def test_existence_true():
|
||||||
|
path = "README.md"
|
||||||
|
nocbz = True
|
||||||
|
test = utils.check_existence(path, nocbz)
|
||||||
|
assert test
|
||||||
|
|
||||||
|
|
||||||
|
def test_existence_false():
|
||||||
|
path = "DONTEXIST.md"
|
||||||
|
nocbz = True
|
||||||
|
test = utils.check_existence(path, nocbz)
|
||||||
|
assert not test
|
||||||
|
|
||||||
|
|
||||||
|
def test_archive_true():
|
||||||
|
img_path = Path("tests/test_dir")
|
||||||
|
archive_path = Path("tests/test_dir.cbz")
|
||||||
|
img_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
for n in range(5):
|
||||||
|
img_name = img_path / f"page{n}"
|
||||||
|
img_name.with_suffix(".png").touch(exist_ok=True)
|
||||||
|
assert utils.make_archive("tests/test_dir")
|
||||||
|
assert archive_path.exists()
|
||||||
|
# cleanup
|
||||||
|
archive_path.unlink(missing_ok=True)
|
||||||
|
img_path.with_suffix(".zip").unlink(missing_ok=True)
|
||||||
|
shutil.rmtree(img_path, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_archive_false():
|
||||||
|
archive_path = Path("tests/test_dir2.cbz")
|
||||||
|
assert not utils.make_archive("tests/test_dir2")
|
||||||
|
assert not archive_path.exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_chapter_list():
|
||||||
|
chapters_in = "1-4,8,11,14-15,22"
|
||||||
|
chapters_out = ["1", "2", "3", "4", "8", "11", "14", "15", "22"]
|
||||||
|
assert utils.get_chapter_list(chapters_in) == chapters_out
|
||||||
|
|
||||||
|
|
||||||
|
def test_fix_name():
|
||||||
|
filename_in1 = "..hello?; @test1-*<>test2.cbz"
|
||||||
|
filename_in2 = "!hello: >test1-/test2<!.cbz"
|
||||||
|
filename_in3 = " hello test1-test2.cbz "
|
||||||
|
filename_in4 = "hello test1-test2..cbz."
|
||||||
|
# out
|
||||||
|
filename_out = "hello test1-test2.cbz"
|
||||||
|
assert utils.fix_name(filename_in1) == filename_out
|
||||||
|
assert utils.fix_name(filename_in2) == filename_out
|
||||||
|
assert utils.fix_name(filename_in3) == filename_out
|
||||||
|
assert utils.fix_name(filename_in4) == filename_out
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_filename_forcevol():
|
||||||
|
chapter_name = "The holy test Chapter"
|
||||||
|
chapter_vol = "2"
|
||||||
|
chapter_num = "44"
|
||||||
|
forcevol = True
|
||||||
|
filename = "Vol. 2 Ch. 44 - The holy test Chapter"
|
||||||
|
assert (
|
||||||
|
utils.get_filename(chapter_name, chapter_vol, chapter_num, forcevol) == filename
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_filename():
|
||||||
|
chapter_name = "The holy test Chapter"
|
||||||
|
chapter_vol = "2"
|
||||||
|
chapter_num = "44"
|
||||||
|
forcevol = False
|
||||||
|
filename = "Ch. 44 - The holy test Chapter"
|
||||||
|
assert (
|
||||||
|
utils.get_filename(chapter_name, chapter_vol, chapter_num, forcevol) == filename
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_filename_oneshot():
|
||||||
|
chapter_name = "Oneshot"
|
||||||
|
chapter_vol = ""
|
||||||
|
chapter_num = ""
|
||||||
|
forcevol = False
|
||||||
|
filename = "Oneshot"
|
||||||
|
assert (
|
||||||
|
utils.get_filename(chapter_name, chapter_vol, chapter_num, forcevol) == filename
|
||||||
|
)
|
Loading…
Reference in a new issue