Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Jan 1, 2024
1 parent de24e39 commit 1235a01
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ jobs:
with:
python-version: "3.8"
- uses: pre-commit/[email protected]
- run: pip install .
- run: bscal
- run: bscal 2079
- run: bscal 2079 3
- run: pip install -e ".[tests]"
- run: pytest
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ dynamic = ["version"]
[project.scripts]
bscal = "bscal:main"

[project.optional-dependencies]
tests = ["pytest", "hypothesis"]

[tool.setuptools]
license-files = ["LICENSE"]

[tool.setuptools_scm]

[tool.ruff]
ignore = ["ISC001"]
ignore = ["ISC001", "S101"]
select = [
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "PT", "Q", "RSE", "RET",
Expand Down
Empty file added tests/__init__.py
Empty file.
67 changes: 67 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import pytest

from bscal import main

results_2080_poush = """\
Poush 2080
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29
"""

results_2080 = """\
2080
Baisakh Jestha Asadh
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2
3 4 5 6 7 8 9 7 8 9 10 11 12 13 3 4 5 6 7 8 9
10 11 12 13 14 15 16 14 15 16 17 18 19 20 10 11 12 13 14 15 16
17 18 19 20 21 22 23 21 22 23 24 25 26 27 17 18 19 20 21 22 23
24 25 26 27 28 29 30 28 29 30 31 32 24 25 26 27 28 29 30
31 31
Shrawan Bhadra Asoj
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 1 2 1 2 3 4 5 6
7 8 9 10 11 12 13 3 4 5 6 7 8 9 7 8 9 10 11 12 13
14 15 16 17 18 19 20 10 11 12 13 14 15 16 14 15 16 17 18 19 20
21 22 23 24 25 26 27 17 18 19 20 21 22 23 21 22 23 24 25 26 27
28 29 30 31 32 24 25 26 27 28 29 30 28 29 30
31
Kartik Mangsir Poush
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 1 2 1 2 3 4 5 6 7
5 6 7 8 9 10 11 3 4 5 6 7 8 9 8 9 10 11 12 13 14
12 13 14 15 16 17 18 10 11 12 13 14 15 16 15 16 17 18 19 20 21
19 20 21 22 23 24 25 17 18 19 20 21 22 23 22 23 24 25 26 27 28
26 27 28 29 30 24 25 26 27 28 29 30 29
Magh Falgun Chaitra
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 1 2 3 4 5 1 2 3
7 8 9 10 11 12 13 6 7 8 9 10 11 12 4 5 6 7 8 9 10
14 15 16 17 18 19 20 13 14 15 16 17 18 19 11 12 13 14 15 16 17
21 22 23 24 25 26 27 20 21 22 23 24 25 26 18 19 20 21 22 23 24
28 29 27 28 29 30 25 26 27 28 29 30
"""


@pytest.mark.parametrize(
("args", "expected"),
[
(("2080", "9"), results_2080_poush),
(("2080",), results_2080),
],
)
def test_cli(capsys, args, expected):
main(args)
out, err = capsys.readouterr()
assert out == expected
assert not err
9 changes: 9 additions & 0 deletions tests/test_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from hypothesis import given
from hypothesis.strategies import dates

from bscal import ad_to_bs, bs_to_ad, new_years


@given(dates(min(new_years.values()), max(new_years.values())))
def test(date):
assert bs_to_ad(*ad_to_bs(date)) == date

0 comments on commit 1235a01

Please sign in to comment.