Skip to content

Commit

Permalink
tests included.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarimbinwaseem committed Feb 23, 2024
1 parent 7db799e commit 9831d01
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/salah_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Unit Test

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r windows-requirements.txt
- name: Testing
run: python salah_timings_test.py
8 changes: 4 additions & 4 deletions Utils/salahtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):

self.check_changes_flag = True
# Indexes where the data is
self._FAJIR = 2
self._FAJAR = 2
self._TULU = 3
self._ZUHUR = 5
self._ASAR = 6
Expand Down Expand Up @@ -100,7 +100,7 @@ def _number2month(self, number):

def _get_salah_time(self) -> datetime.time:
salah_times = (
self._today_data[self._FAJIR],
self._today_data[self._FAJAR],
self._today_data[self._TULU],
self._today_data[self._ZUHUR],
self._today_data[self._ASAR],
Expand All @@ -119,7 +119,7 @@ def _get_salah_time(self) -> datetime.time:
with shelve.open(f"Times/{self.month}") as db:
next_day_data = db[str(self.current_date.day + 1)]

salah_time = next_day_data[self._FAJIR]
salah_time = next_day_data[self._FAJAR]

except KeyError: # Possible month change.
current_month_number = self.current_date.strftime("%m").replace("0", "")
Expand All @@ -128,7 +128,7 @@ def _get_salah_time(self) -> datetime.time:
with shelve.open(f"Times/{next_month_name}") as db:
next_day_data = db[str(1)]

salah_time = next_day_data[self._FAJIR]
salah_time = next_day_data[self._FAJAR]

return salah_time

Expand Down
22 changes: 22 additions & 0 deletions salah_timings_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from Utils.salahtime import SalahTime
import datetime

st = SalahTime()

def test_num2month() -> None:
month = st._number2month(2)
assert month == "February"

def test_time2display() -> None:

date = datetime.datetime(2024, 1, 1, 14, 25).time()
res = st._time2display(date)
print(res)

assert type(res) is str
assert res == "02:25 PM"

def test_getalltimes() -> None:
res = st.get_all_times()
assert type(res) is tuple

0 comments on commit 9831d01

Please sign in to comment.