Skip to content

Commit

Permalink
move the tests of models into a separate folder and parameterize the …
Browse files Browse the repository at this point in the history
…test of common utils
  • Loading branch information
Kashyap Maheshwari committed Jun 11, 2023
1 parent 013046a commit 80ce363
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
17 changes: 0 additions & 17 deletions findpapers/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
import logging
import os
from typing import Optional

from findpapers.tools.bibtex_generator_tool import generate_bibtex
from findpapers.tools.downloader_tool import download
from findpapers.tools.rayyan_tool import RayyanExport
from findpapers.tools.refiner_tool import refine
from findpapers.tools.refman_tool import RisExport
from findpapers.tools.search_runner_tool import search

try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata

__version__ = importlib_metadata.version(__name__)
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 14 additions & 13 deletions tests/unit/test_common_utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
from findpapers.utils.common_utils import get_numeric_month_by_string

import pytest

def test_get_numeric_month_by_string_when_ful_form_of_string_is_provided() -> None:
assert get_numeric_month_by_string(string="January") == "01"
from findpapers.utils.common_utils import get_numeric_month_by_string


def test_get_numeric_month_by_string_when_short_form_of_string_is_provided() -> None:
assert get_numeric_month_by_string(string="Mar") == "03"
@pytest.mark.parametrize(("month", "expected_output"), [("January", "01"), ("March", "03"), ("October", "10")])
def test_get_numeric_month_by_string_when_full_form_of_string_is_provided(month: str, expected_output: str) -> None:
assert get_numeric_month_by_string(string=month) == expected_output


def test_get_numeric_month_by_string_when_number_is_provided_as_string() -> None:
assert get_numeric_month_by_string(string="12") == "12"
@pytest.mark.parametrize(("month", "expected_output"), [("Feb", "02"), ("May", "05"), ("Nov", "11")])
def test_get_numeric_month_by_string_when_short_form_of_string_is_provided(month: str, expected_output: str) -> None:
assert get_numeric_month_by_string(string=month) == expected_output


def test_get_numeric_month_by_string_when_string_is_not_valid() -> None:
assert get_numeric_month_by_string(string="15") == "01"
assert get_numeric_month_by_string(string="fdgdf") == "01"
@pytest.mark.parametrize(("month", "expected_output"), [("06", "06"), ("08", "08"), ("11", "11")])
def test_get_numeric_month_by_string_when_month_is_provided_as_number(month: str, expected_output: str) -> None:
assert get_numeric_month_by_string(string=month) == expected_output


def test_get_numeric_month_by_string_when_string_is_not_provided() -> None:
assert get_numeric_month_by_string(string=None) == "01"
@pytest.mark.parametrize("string", ["15", "fdgdf", None])
def test_get_numeric_month_by_string_when_string_is_not_valid(string: str) -> None:
assert get_numeric_month_by_string(string=string) == "01"

0 comments on commit 80ce363

Please sign in to comment.