Minor development-related issues. (#110)

This commit is contained in:
Antoine 2021-01-03 21:55:29 +01:00 committed by GitHub
parent 3d7fab29cd
commit d85a42cccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 32 deletions

View File

@ -1,4 +1,4 @@
polib==1.1.0
requests==2.25.0
simple-term-menu==0.10.4
gitignore_parser==0.0.8
gitignore-parser==0.0.8

View File

@ -20,7 +20,7 @@ setuptools.setup(
package_dir={"potodo": "potodo"},
entry_points={"console_scripts": ["potodo=potodo.potodo:main"]},
include_package_data=True,
install_requires=["polib", "requests", "simple-term-menu", "gitignore_parser"],
install_requires=["polib", "requests", "simple-term-menu", "gitignore-parser"],
license="MIT license",
zip_safe=False,
keywords="potodo",

View File

@ -1,5 +1,5 @@
import sys
from pathlib import Path
from subprocess import check_output, CalledProcessError
REPO_DIR = "repository"
@ -29,19 +29,27 @@ class TestPotodoArgsErrors:
excluded_2 = str(config["exclude"][1])
def test_potodo_help(self):
output = check_output(["potodo", "--help"]).decode("utf-8")
output_short = check_output(["potodo", "-h"]).decode("utf-8")
output = check_output([sys.executable, "-m", "potodo", "--help"]).decode(
"utf-8"
)
output_short = check_output([sys.executable, "-m", "potodo", "-h"]).decode(
"utf-8"
)
assert output == output_short
assert "-h, --help show this help message and exit" in output
# TODO: Find a better way of testing help output
def test_potodo_above_below_conflict(self):
try:
check_output(["potodo", "--above", "50", "--below", "40"]).decode("utf-8")
check_output(
[sys.executable, "-m", "potodo", "--above", "50", "--below", "40"]
).decode("utf-8")
except CalledProcessError as e:
output = e.output
try:
check_output(["potodo", "-a", "50", "-b", "40"]).decode("utf-8")
check_output(
[sys.executable, "-m", "potodo", "-a", "50", "-b", "40"]
).decode("utf-8")
except CalledProcessError as e:
output_short = e.output
assert output == output_short
@ -49,11 +57,13 @@ class TestPotodoArgsErrors:
def test_potodo_json_interactive_conflict(self):
try:
check_output(["potodo", "--json", "--interactive"]).decode("utf-8")
check_output(
[sys.executable, "-m", "potodo", "--json", "--interactive"]
).decode("utf-8")
except CalledProcessError as e:
output = e.output
try:
check_output(["potodo", "-j", "-i"]).decode("utf-8")
check_output([sys.executable, "-m", "potodo", "-j", "-i"]).decode("utf-8")
except CalledProcessError as e:
output_short = e.output
assert output == output_short
@ -64,7 +74,9 @@ class TestPotodoArgsErrors:
def test_potodo_exclude_and_only_fuzzy_conflict(self):
try:
check_output(["potodo", "--exclude-fuzzy", "--only-fuzzy"]).decode("utf-8")
check_output(
[sys.executable, "-m", "potodo", "--exclude-fuzzy", "--only-fuzzy"]
).decode("utf-8")
except CalledProcessError as e:
output = e.output
assert (
@ -74,9 +86,15 @@ class TestPotodoArgsErrors:
def test_potodo_exclude_and_only_reserved_conflict(self):
try:
check_output(["potodo", "--exclude-reserved", "--only-reserved"]).decode(
"utf-8"
)
check_output(
[
sys.executable,
"-m",
"potodo",
"--exclude-reserved",
"--only-reserved",
]
).decode("utf-8")
except CalledProcessError as e:
output = e.output
assert (

View File

@ -1,5 +1,5 @@
import sys
from pathlib import Path
from subprocess import check_output
REPO_DIR = "repository"
@ -29,7 +29,7 @@ class TestPotodoCLI:
excluded_2 = str(config["exclude"][1])
def test_potodo_no_args(self):
output = check_output("potodo").decode("utf-8")
output = check_output([sys.executable, "-m", "potodo"]).decode("utf-8")
assert "# excluded (50.00% done)" in output
assert "# folder (33.33% done)" in output
assert (
@ -46,10 +46,17 @@ class TestPotodoCLI:
def test_potodo_exclude(self):
output = check_output(
["potodo", "--exclude", self.excluded_1, self.excluded_2]
[
sys.executable,
"-m",
"potodo",
"--exclude",
self.excluded_1,
self.excluded_2,
]
).decode("utf-8")
output_short = check_output(
["potodo", "-e", self.excluded_1, self.excluded_2]
[sys.executable, "-m", "potodo", "-e", self.excluded_1, self.excluded_2]
).decode("utf-8")
assert output == output_short
assert "# excluded (50.00% done)" not in output
@ -64,8 +71,12 @@ class TestPotodoCLI:
)
def test_potodo_above(self):
output = check_output(["potodo", "--above", "40"]).decode("utf-8")
output_short = check_output(["potodo", "-a", "40"]).decode("utf-8")
output = check_output([sys.executable, "-m", "potodo", "--above", "40"]).decode(
"utf-8"
)
output_short = check_output(
[sys.executable, "-m", "potodo", "-a", "40"]
).decode("utf-8")
assert output == output_short
assert (
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@ -76,8 +87,12 @@ class TestPotodoCLI:
)
def test_potodo_below(self):
output = check_output(["potodo", "--below", "40"]).decode("utf-8")
output_short = check_output(["potodo", "-b", "40"]).decode("utf-8")
output = check_output([sys.executable, "-m", "potodo", "--below", "40"]).decode(
"utf-8"
)
output_short = check_output(
[sys.executable, "-m", "potodo", "-b", "40"]
).decode("utf-8")
assert output == output_short
assert (
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@ -89,8 +104,12 @@ class TestPotodoCLI:
)
def test_potodo_onlyfuzzy(self):
output = check_output(["potodo", "--only-fuzzy"]).decode("utf-8")
output_short = check_output(["potodo", "-f"]).decode("utf-8")
output = check_output([sys.executable, "-m", "potodo", "--only-fuzzy"]).decode(
"utf-8"
)
output_short = check_output([sys.executable, "-m", "potodo", "-f"]).decode(
"utf-8"
)
assert output == output_short
assert (
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@ -102,8 +121,12 @@ class TestPotodoCLI:
)
def test_potodo_counts(self):
output = check_output(["potodo", "--counts"]).decode("utf-8")
output_short = check_output(["potodo", "-c"]).decode("utf-8")
output = check_output([sys.executable, "-m", "potodo", "--counts"]).decode(
"utf-8"
)
output_short = check_output([sys.executable, "-m", "potodo", "-c"]).decode(
"utf-8"
)
assert output == output_short
assert (
"- excluded.po 1 / 2 ( 50.0% translated)"
@ -116,7 +139,9 @@ class TestPotodoCLI:
)
def test_potodo_exclude_fuzzy(self):
output = check_output(["potodo", "--exclude-fuzzy"]).decode("utf-8")
output = check_output(
[sys.executable, "-m", "potodo", "--exclude-fuzzy"]
).decode("utf-8")
assert (
"- excluded.po 1 / 2 ( 50.0% translated)" in output
)
@ -126,8 +151,12 @@ class TestPotodoCLI:
)
def test_potodo_matching_files_solo(self):
output = check_output(["potodo", "--matching-files"]).decode("utf-8")
output_short = check_output(["potodo", "-l"]).decode("utf-8")
output = check_output(
[sys.executable, "-m", "potodo", "--matching-files"]
).decode("utf-8")
output_short = check_output([sys.executable, "-m", "potodo", "-l"]).decode(
"utf-8"
)
assert output == output_short
assert "excluded/file4.po" in output
assert "folder/excluded.po" in output
@ -136,10 +165,12 @@ class TestPotodoCLI:
assert "file2.po" in output
def test_potodo_matching_files_fuzzy(self):
output = check_output(["potodo", "--matching-files", "--only-fuzzy"]).decode(
"utf-8"
)
output_short = check_output(["potodo", "-l", "-f"]).decode("utf-8")
output = check_output(
[sys.executable, "-m", "potodo", "--matching-files", "--only-fuzzy"]
).decode("utf-8")
output_short = check_output(
[sys.executable, "-m", "potodo", "-l", "-f"]
).decode("utf-8")
assert output == output_short
assert "file1.po" in output