Compare commits
3 Commits
b100533e03
...
add-ci-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
987ce19aec | ||
|
|
b5025bf7ec | ||
|
|
d3d861bd2d |
@@ -21,6 +21,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
- name: Run tests
|
||||||
|
run: python3 test_export.py
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pyinstaller --onefile --name tamigo-cli tamigo.py
|
run: pyinstaller --onefile --name tamigo-cli tamigo.py
|
||||||
- name: Upload Linux Artifact
|
- name: Upload Linux Artifact
|
||||||
@@ -53,6 +55,7 @@ jobs:
|
|||||||
export TEMP=C:\\\\temp && \
|
export TEMP=C:\\\\temp && \
|
||||||
mkdir -p /src/build /src/dist_win && \
|
mkdir -p /src/build /src/dist_win && \
|
||||||
pip install -r requirements.txt && \
|
pip install -r requirements.txt && \
|
||||||
|
python3 test_export.py && \
|
||||||
pyinstaller --onefile --name tamigo-cli \
|
pyinstaller --onefile --name tamigo-cli \
|
||||||
--workpath /src/build \
|
--workpath /src/build \
|
||||||
--distpath /src/dist_win \
|
--distpath /src/dist_win \
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
- name: Run tests
|
||||||
|
run: python3 test_export.py
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pyinstaller --onefile --name tamigo-cli tamigo.py
|
run: pyinstaller --onefile --name tamigo-cli tamigo.py
|
||||||
- name: Rename for release
|
- name: Rename for release
|
||||||
@@ -51,6 +53,7 @@ jobs:
|
|||||||
export TEMP=C:\\\\temp && \
|
export TEMP=C:\\\\temp && \
|
||||||
mkdir -p /src/build /src/dist_win && \
|
mkdir -p /src/build /src/dist_win && \
|
||||||
pip install -r requirements.txt && \
|
pip install -r requirements.txt && \
|
||||||
|
python3 test_export.py && \
|
||||||
pyinstaller --onefile --name tamigo-cli \
|
pyinstaller --onefile --name tamigo-cli \
|
||||||
--workpath /src/build \
|
--workpath /src/build \
|
||||||
--distpath /src/dist_win \
|
--distpath /src/dist_win \
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ def main():
|
|||||||
|
|
||||||
def menu(client):
|
def menu(client):
|
||||||
while True:
|
while True:
|
||||||
settings_text = "SETTINGS" if current_theme_name == "fallout" else "Settings"
|
settings_text = "Settings"
|
||||||
choice = questionary.select(
|
choice = questionary.select(
|
||||||
"SELECT ACTION:" if current_theme_name == "fallout" else "What would you like to do?",
|
"SELECT ACTION:" if current_theme_name == "fallout" else "What would you like to do?",
|
||||||
choices=["Calculate actual work days", "Export hours worked", "Show profile info", settings_text, "Logout and Exit"],
|
choices=["Calculate actual work days", "Export hours worked", "Show profile info", settings_text, "Logout and Exit"],
|
||||||
@@ -336,11 +336,9 @@ def menu(client):
|
|||||||
def settings_menu():
|
def settings_menu():
|
||||||
while True:
|
while True:
|
||||||
show_zero = current_config.get("show_zero_hours", False)
|
show_zero = current_config.get("show_zero_hours", False)
|
||||||
toggle_text = "HIDE ZERO-HOUR DAYS" if current_theme_name == "fallout" else "Hide zero-hour days"
|
toggle_text = "Hide zero-hour days" if show_zero else "Show zero-hour days"
|
||||||
if not show_zero:
|
|
||||||
toggle_text = "SHOW ZERO-HOUR DAYS" if current_theme_name == "fallout" else "Show zero-hour days"
|
|
||||||
|
|
||||||
back_text = "BACK" if current_theme_name == "fallout" else "Back"
|
back_text = "Back"
|
||||||
|
|
||||||
choice = questionary.select(
|
choice = questionary.select(
|
||||||
"SELECT SETTING:" if current_theme_name == "fallout" else "Settings:",
|
"SELECT SETTING:" if current_theme_name == "fallout" else "Settings:",
|
||||||
|
|||||||
@@ -68,6 +68,49 @@ class TestTamigoExport(unittest.TestCase):
|
|||||||
self.assertIn("2025-03-10", work_days)
|
self.assertIn("2025-03-10", work_days)
|
||||||
self.assertEqual(work_days["2025-03-10"]["hours"], 0)
|
self.assertEqual(work_days["2025-03-10"]["hours"], 0)
|
||||||
|
|
||||||
|
@patch('tamigo.select_date_range')
|
||||||
|
@patch('questionary.select')
|
||||||
|
@patch('questionary.text')
|
||||||
|
@patch('tamigo.console')
|
||||||
|
def test_export_worked_hours_respects_zero_hour_filtering(self, mock_console, mock_text, mock_select, mock_date_range):
|
||||||
|
from tamigo import export_worked_hours
|
||||||
|
|
||||||
|
# Mock API response with a 0-hour shift
|
||||||
|
mock_shifts = [
|
||||||
|
{
|
||||||
|
"Date": "/Date(1741564800000)/", # 2025-03-10
|
||||||
|
"StartTime": "2025-03-10T09:00:00Z",
|
||||||
|
"ActualShiftHours": 0,
|
||||||
|
"ActualShiftText": "Sick Day",
|
||||||
|
"IsAbsent": False
|
||||||
|
}
|
||||||
|
]
|
||||||
|
self.client.get_employee_actual_shifts.return_value = mock_shifts
|
||||||
|
mock_date_range.return_value = (datetime(2025, 3, 1), datetime(2025, 3, 15))
|
||||||
|
|
||||||
|
# 1. Test with show_zero_hours = False -> Should NOT export anything
|
||||||
|
with patch('tamigo.current_config', {'show_zero_hours': False}):
|
||||||
|
export_worked_hours(self.client)
|
||||||
|
# Verify the warning was printed
|
||||||
|
mock_console.print.assert_any_call("[warning]WARNING: NO LOG ENTRIES DETECTED.[/warning]")
|
||||||
|
self.assertFalse(os.path.exists("tamigo_export_20250301_20250315.csv"))
|
||||||
|
|
||||||
|
# 2. Test with show_zero_hours = True -> Should export the 0-hour day
|
||||||
|
mock_select.return_value.ask.return_value = "CSV"
|
||||||
|
mock_text.return_value.ask.return_value = "test_zero_export.csv"
|
||||||
|
|
||||||
|
with patch('tamigo.current_config', {'show_zero_hours': True}):
|
||||||
|
export_worked_hours(self.client)
|
||||||
|
|
||||||
|
self.assertTrue(os.path.exists("test_zero_export.csv"))
|
||||||
|
with open("test_zero_export.csv", "r") as f:
|
||||||
|
rows = list(csv.reader(f))
|
||||||
|
self.assertEqual(len(rows), 2) # Header + 1 data row
|
||||||
|
self.assertEqual(rows[1][0], "2025-03-10")
|
||||||
|
self.assertEqual(rows[1][1], "0.00")
|
||||||
|
|
||||||
|
os.remove("test_zero_export.csv")
|
||||||
|
|
||||||
@patch('tamigo.select_date_range')
|
@patch('tamigo.select_date_range')
|
||||||
@patch('tamigo.get_worked_days')
|
@patch('tamigo.get_worked_days')
|
||||||
@patch('questionary.select')
|
@patch('questionary.select')
|
||||||
|
|||||||
Reference in New Issue
Block a user