From fa2f913da41e5dbf33c3a6372372da8c53d519ee Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 16 Oct 2022 18:23:23 +0200 Subject: fix: fix testing --- build.yml | 1 - pyproject.toml | 5 +++-- pytest.ini | 3 --- reddit_nextcloud_importer/__init__.py | 3 ++- test/test_uploader.py | 20 -------------------- test_uploader.py | 20 ++++++++++++++++++++ 6 files changed, 25 insertions(+), 27 deletions(-) delete mode 100644 pytest.ini delete mode 100644 test/test_uploader.py create mode 100644 test_uploader.py diff --git a/build.yml b/build.yml index 88e61a8..fd39c42 100644 --- a/build.yml +++ b/build.yml @@ -15,7 +15,6 @@ secrets: environment: deploy: builds@gabrielgio.me target: artifacts.gabrielgio.me/reddit-nextcloud-importer/ - version: v0.1.1 tasks: - archive: | diff --git a/pyproject.toml b/pyproject.toml index adde93c..38672a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,14 @@ [tool.poetry] name = "reddit-nextcloud-importer" -version = "0.1.1" +version = "0.1.2" license = "Apache-2.0" homepage = "https://git.sr.ht/~gabrielgio/reddit-nextcloud-importer" repository = "https://git.sr.ht/~gabrielgio/reddit-nextcloud-importer" description = "Reddit to Nextcloud importer" authors = ["Gabriel Arakaki Giovanini "] packages = [ - { include = "reddit_nextcloud_importer" } + { include = "reddit_nextcloud_importer" }, + { include = "test_uploader.py" } ] [tool.poetry.dependencies] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 20c6e5e..0000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -pythonpath = . -testpaths = test diff --git a/reddit_nextcloud_importer/__init__.py b/reddit_nextcloud_importer/__init__.py index 6097ef4..c0d769c 100644 --- a/reddit_nextcloud_importer/__init__.py +++ b/reddit_nextcloud_importer/__init__.py @@ -1,6 +1,7 @@ import argparse import logging import os +from typing import List from time import sleep import praw @@ -92,7 +93,7 @@ def get_list_of_files(dirName): return allFiles -def download(url) -> [str]: +def download(url) -> List[str]: d = DownloadJob(url=url) d.run() basedir = d.pathfmt.basedirectory diff --git a/test/test_uploader.py b/test/test_uploader.py deleted file mode 100644 index 7fe2f44..0000000 --- a/test/test_uploader.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest - -from importer.uploader import create_folders - - -@pytest.fixture -def nxc(mocker): - return mocker.MagicMock() - - -@pytest.mark.parametrize("path,folders", [ - ("folder1", ["/folder1"]), - ("folder1/folder2", ["/folder1", "/folder1/folder2"]), - ("/folder1/folder2", ["/folder1", "/folder1/folder2"]) -]) -def test_create_folders(nxc, path, folders): - create_folders(path, nxc) - - for call, folder in zip(nxc.method_calls, folders): - assert folder == call.args[0] diff --git a/test_uploader.py b/test_uploader.py new file mode 100644 index 0000000..0f652ca --- /dev/null +++ b/test_uploader.py @@ -0,0 +1,20 @@ +import pytest + +from reddit_nextcloud_importer import create_folders + + +@pytest.fixture +def nxc(mocker): + return mocker.MagicMock() + + +@pytest.mark.parametrize("path,folders", [ + ("folder1", ["/folder1"]), + ("folder1/folder2", ["/folder1", "/folder1/folder2"]), + ("/folder1/folder2", ["/folder1", "/folder1/folder2"]) +]) +def test_create_folders(nxc, path, folders): + create_folders(path, nxc) + + for call, folder in zip(nxc.method_calls, folders): + assert folder == call.args[0] -- cgit v1.2.3