update tests and add coverage report
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
7bcaca4a29
commit
d6725d1e7c
7 changed files with 138 additions and 30 deletions
28
.coveragerc
Normal file
28
.coveragerc
Normal file
|
@ -0,0 +1,28 @@
|
|||
# .coveragerc to control coverage.py
|
||||
[run]
|
||||
branch = True
|
||||
source = mangadlp
|
||||
|
||||
[report]
|
||||
# Regexes for lines to exclude from consideration
|
||||
exclude_lines =
|
||||
# Have to re-enable the standard pragma
|
||||
pragma: no cover
|
||||
|
||||
# Don't complain about missing debug-only code:
|
||||
def __repr__
|
||||
if self\.debug
|
||||
|
||||
# Don't complain if tests don't hit defensive assertion code:
|
||||
raise AssertionError
|
||||
raise NotImplementedError
|
||||
|
||||
# Don't complain if non-runnable code isn't run:
|
||||
if 0:
|
||||
if __name__ == .__main__.:
|
||||
|
||||
# Don't complain about abstract methods, they aren't run:
|
||||
@(abc\.)?abstractmethod
|
||||
|
||||
ignore_errors = True
|
||||
|
66
.drone.yml
66
.drone.yml
|
@ -11,8 +11,6 @@ platform:
|
|||
arch: amd64
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
||||
|
@ -25,17 +23,30 @@ sq_secrets: &sq_secrets
|
|||
sq_analysis: &sq_analysis
|
||||
image: 'cr.44net.ch/drone-plugins/sonarqube'
|
||||
pull: if-not-exists
|
||||
group: sonarqube
|
||||
group: test
|
||||
|
||||
# build steps
|
||||
test_plugin: &test_plugin
|
||||
image: 'cr.44net.ch/drone-plugins/test'
|
||||
pull: if-not-exists
|
||||
group: publish
|
||||
|
||||
# steps
|
||||
steps:
|
||||
# test python code
|
||||
- name: 'test code and generate coverage report'
|
||||
<<: *test_plugin
|
||||
commands:
|
||||
- coverage erase
|
||||
- coverage run -m pytest
|
||||
- coverage xml -i
|
||||
|
||||
# upload analysis to sonarqube
|
||||
- name: 'sonarqube: analyse code'
|
||||
<<: *sq_analysis
|
||||
settings:
|
||||
<<: *sq_secrets
|
||||
sources: .
|
||||
exclusions: contrib/**
|
||||
|
||||
exclusions: contrib/**, docker/**
|
||||
|
||||
|
||||
---
|
||||
|
@ -151,6 +162,43 @@ depends_on:
|
|||
- docker-build-amd64
|
||||
- docker-build-arm64
|
||||
|
||||
---
|
||||
#################
|
||||
# gitea release #
|
||||
#################
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: gitea-release
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
# anchors
|
||||
gitea_secrets: &gitea_secrets
|
||||
api_key:
|
||||
from_secret: gitea-token
|
||||
|
||||
gitea_plugin: &gitea_plugin
|
||||
image: plugins/gitea-release
|
||||
pull: if-not-exists
|
||||
group: publish
|
||||
|
||||
# publish release on gitea
|
||||
steps:
|
||||
- name: 'publish or update pypi package'
|
||||
<<: *gitea_plugin
|
||||
settings:
|
||||
base_url: https://git.44net.ch
|
||||
files: ./*
|
||||
title: 'manga-dlp release: ${DRONE_TAG}'
|
||||
note: CHANGELOG.md
|
||||
<<: *gitea_secrets
|
||||
|
||||
#---
|
||||
#################
|
||||
## publish pypi #
|
||||
|
@ -161,7 +209,7 @@ depends_on:
|
|||
#
|
||||
#platform:
|
||||
# os: linux
|
||||
# arch: arm64
|
||||
# arch: amd64
|
||||
#
|
||||
#trigger:
|
||||
# event:
|
||||
|
@ -177,9 +225,9 @@ depends_on:
|
|||
#pypi_plugin: &pypi_plugin
|
||||
# image: plugins/pypi
|
||||
# pull: if-not-exists
|
||||
# group: build
|
||||
# group: publish
|
||||
#
|
||||
## build steps arm64
|
||||
## publish package on pypi
|
||||
#steps:
|
||||
# - name: 'publish or update pypi package'
|
||||
# <<: *pypi_plugin
|
||||
|
|
0
conftest.py
Normal file
0
conftest.py
Normal file
|
@ -1 +1,2 @@
|
|||
sonar.python.version=3.9
|
||||
sonar.python.coverage.reportPaths=coverage.xml
|
|
@ -1,18 +1,47 @@
|
|||
import pytest
|
||||
from mangadlp.api.mangadex import Mangadex
|
||||
|
||||
def test_uuid():
|
||||
url = 'https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu'
|
||||
lang = 'en'
|
||||
test = Mangadex(url, lang)
|
||||
assert test.get_manga_uuid() == 'a96676e5-8ae2-425e-b549-7f15dd34a6d8'
|
||||
|
||||
def test_uuid_link():
|
||||
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.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||
|
||||
|
||||
def test_uuid_pure():
|
||||
url = "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||
lang = "en"
|
||||
forcevol = False
|
||||
verbose = False
|
||||
test = Mangadex(url, lang, forcevol, verbose)
|
||||
assert test.manga_uuid == "a96676e5-8ae2-425e-b549-7f15dd34a6d8"
|
||||
|
||||
|
||||
def test_title():
|
||||
url = 'https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu'
|
||||
lang = 'en'
|
||||
test = Mangadex(url, lang)
|
||||
title = test.get_manga_title(test.get_manga_uuid())
|
||||
assert title == 'Komi-san wa Komyushou Desu'
|
||||
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.manga_title == "Komi-san wa Komyushou Desu"
|
||||
|
||||
|
||||
def test_chapter_infos():
|
||||
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)
|
||||
chapter_infos = test.get_chapter_infos("1")
|
||||
chapter_uuid = chapter_infos["uuid"]
|
||||
chapter_name = chapter_infos["name"]
|
||||
chapter_num = chapter_infos["chapter"]
|
||||
chapter_volume = chapter_infos["volume"]
|
||||
assert [chapter_uuid, chapter_name, chapter_volume, chapter_num] == [
|
||||
"e86ec2c4-c5e4-4710-bfaa-7604f00939c7",
|
||||
"A Normal Person",
|
||||
"1",
|
||||
"1",
|
||||
]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu
|
||||
https://mangadex.org/title/bd6d0982-0091-4945-ad70-c028ed3c0917/mushoku-tensei-isekai-ittara-honki-dasu
|
||||
37f5cce0-8070-4ada-96e5-fa24b1bd4ff9
|
||||
37f5cce0-8070-4ada-96e5-fa24b1bd4ff9
|
|
@ -1,18 +1,20 @@
|
|||
import pytest
|
||||
from pathlib import Path
|
||||
import mangadlp.main as MdlpMain
|
||||
import mangadlp.utils as MdlpUtils
|
||||
import mangadlp.downloader as MdlpDownloader
|
||||
|
||||
|
||||
def test_readin_list():
|
||||
list_file = Path('test.txt')
|
||||
test_list = MdlpMain.readin_list(list_file)
|
||||
list_file = Path("tests/test_list.txt")
|
||||
test_list = MdlpMain.readin_list(list_file)
|
||||
|
||||
assert test_list == ['https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu', 'https://mangadex.org/title/bd6d0982-0091-4945-ad70-c028ed3c0917/mushoku-tensei-isekai-ittara-honki-dasu']
|
||||
assert test_list == [
|
||||
"https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu",
|
||||
"https://mangadex.org/title/bd6d0982-0091-4945-ad70-c028ed3c0917/mushoku-tensei-isekai-ittara-honki-dasu",
|
||||
"37f5cce0-8070-4ada-96e5-fa24b1bd4ff9",
|
||||
]
|
||||
|
||||
|
||||
def check_api():
|
||||
url = 'https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu'
|
||||
test = MdlpMain.check_api(url)
|
||||
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
|
||||
test = MdlpMain.check_api(url)
|
||||
|
||||
assert test == eval(mangadlp.api.mangadex.Mangadex)
|
||||
assert test == eval(mangadlp.api.mangadex.Mangadex)
|
||||
|
|
Loading…
Reference in a new issue