Skip to content

Commit 09dc437

Browse files
authored
Merge pull request #10 from ElcanoTek/codex/move-tests-to-dedicated-folder-and-clean-up-du
Organize tests and auto-clean local database
2 parents cbc8343 + 17c031e commit 09dc437

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

.github/workflows/test-victoria.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ jobs:
3939
if [[ "${{ runner.os }}" == "Windows" ]]; then
4040
export PYTHONIOENCODING=utf-8
4141
chcp 65001 || true # Set Windows console to UTF-8
42-
python test_victoria.py
42+
python tests/test_victoria.py
43+
python tests/test_non_interactive.py
4344
else
44-
python3 test_victoria.py
45+
python3 tests/test_victoria.py
46+
python3 tests/test_non_interactive.py
4547
fi
4648
4749
- name: Test script execution with different terminal environments

TESTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ The GitHub Actions workflow (`.github/workflows/test-victoria.yml`) automaticall
2626

2727
### Running Tests Locally
2828

29-
To run the test suite locally:
29+
All test scripts now reside in the `tests/` directory. To run the full test suite:
3030

3131
```bash
32-
python test_victoria.py
32+
pytest tests/test_victoria.py tests/test_non_interactive.py
3333
```
3434

35-
Or with Python 3 explicitly:
35+
Or run the scripts directly:
3636

3737
```bash
38-
python3 test_victoria.py
38+
python tests/test_victoria.py
39+
python tests/test_non_interactive.py
3940
```
4041

4142
### Test Script Features
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,29 @@ def test_victoria_with_interrupt():
8181
try:
8282
python_cmd = sys.executable
8383

84+
# On Windows we need a process group to send CTRL_BREAK_EVENT
85+
creationflags = 0
86+
if platform.system() == 'Windows':
87+
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
88+
8489
# Start the process
8590
process = subprocess.Popen(
8691
[python_cmd, 'victoria.py'],
8792
stdin=subprocess.PIPE,
8893
stdout=subprocess.PIPE,
8994
stderr=subprocess.PIPE,
90-
text=True
95+
text=True,
96+
creationflags=creationflags
9197
)
92-
98+
9399
# Let it run for a moment
94100
time.sleep(1)
95-
101+
96102
# Send interrupt signal (Ctrl+C)
97-
process.send_signal(signal.SIGINT)
103+
if platform.system() == 'Windows':
104+
process.send_signal(signal.CTRL_BREAK_EVENT)
105+
else:
106+
process.send_signal(signal.SIGINT)
98107

99108
try:
100109
stdout, stderr = process.communicate(timeout=5)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,4 @@ def main():
369369
return 1
370370

371371
if __name__ == "__main__":
372-
sys.exit(main())
372+
sys.exit(main())

victoria.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,22 @@ def course_menu() -> str:
657657
warn("Invalid selection. Please choose 1 or 2.")
658658

659659
# ------------------ Main ------------------
660+
def remove_local_duckdb():
661+
"""Remove local DuckDB file to ensure a clean start."""
662+
db_path = Path("data") / "adtech.duckdb"
663+
try:
664+
if db_path.exists():
665+
db_path.unlink()
666+
info(f"Removed local database: {db_path}")
667+
else:
668+
info(f"No local database found at {db_path}")
669+
except Exception as e:
670+
warn(f"Could not remove {db_path}: {e}")
671+
660672
def main():
661673
clear_screen()
662674
banner()
675+
remove_local_duckdb()
663676

664677
print(f"{T.GREEN}{T.ROCKET} Welcome to Victoria - Your AdTech Data Navigator!{T.NC}")
665678

0 commit comments

Comments
 (0)