From 23e0d892f8087c76251c2ff6e4189ec57ab776f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pogoda?= <mipo57@e-science.pl> Date: Mon, 19 Jun 2023 08:43:32 +0200 Subject: [PATCH] Added test for readme example --- README.md | 2 +- tests/integration/readme_example/__init__.py | 0 .../test_wiktorner_jsonl_readme_example.py | 35 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/integration/readme_example/__init__.py create mode 100644 tests/integration/readme_example/test_wiktorner_jsonl_readme_example.py diff --git a/README.md b/README.md index 97d8b31..430b0f7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Anonymizer works in 3 modes, when sensitive data is detected, it can perform ope ## Running from cli ```bash -python3 cli.py example_inputs/wiktorner_jsonl output.json --configuration wiktorner_jsonl --language pl --replace-method tag +python3 cli.py example_inputs/wiktorner_jsonl.jsonl output.json --configuration wiktorner_jsonl --language pl --replace-method tag ``` ## How it works? diff --git a/tests/integration/readme_example/__init__.py b/tests/integration/readme_example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/integration/readme_example/test_wiktorner_jsonl_readme_example.py b/tests/integration/readme_example/test_wiktorner_jsonl_readme_example.py new file mode 100644 index 0000000..2edaa00 --- /dev/null +++ b/tests/integration/readme_example/test_wiktorner_jsonl_readme_example.py @@ -0,0 +1,35 @@ +"""Test for checking if the example from the readme works.""" + +import tempfile +from subprocess import run + + +def test_wiktorner_jsonl_readme_example(): + """Test wiktorner_jsonl readme example.""" + with tempfile.TemporaryDirectory() as tmpdirname: + run( + ( + f"python3 cli.py example_inputs/wiktorner_jsonl.jsonl" + f" {tmpdirname}/output.json --configuration wiktorner_jsonl --language" + " pl --replace-method tag" + ), + shell=True, + ) + with open(f"{tmpdirname}/output.json", "r", encoding="utf8") as f: + result = f.read() + + assert ( + result + == '{"text": "ROZDZIAŠI. CO NIECO O SAMEJ PIPIDÓWCE Przede wszystkim muszę' + " uprzedzić z góry czytelników, aby się daremnie nie trudzili nad" + " szukaniem wyżej wyrażonego miasteczka na mapach [MIEJSCE] i [MIEJSCE]," + " bo go tam nie znajdą. Nie dlatego, jakoby [MIEJSCE] nie istniała w" + " rzeczywistości i była tylko wytworem fantazji autora, ale po prostu" + " dlatego, że mieszkańcy owego sławnego grodu, urosłszy z czasem w" + " ambicję, uważali tę nazwę jako ubliżającą ich powadze i podali do c." + " k. namiestnictwa pokorną prośbę o pozwolenie zamienienia jej na inną." + " Podobne zamiany nazwisk praktykują się dość często w [MIEJSCE]," + " szczególnie u pojedynczych osób, które nie czując się na siłach" + " uszlachetnienia sobą, swymi czynami własnego nazwiska, chcą nazwiskiem" + ' uszlachetnić siebie, i tak np."}' + ) -- GitLab