Skip to content

Commit 61f4858

Browse files
committed
pytest tests
pyinstaller based
1 parent be6c49a commit 61f4858

File tree

14 files changed

+316
-25
lines changed

14 files changed

+316
-25
lines changed

.github/workflows/tests.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
run-tests:
13+
name: Run Tests
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v4
22+
with:
23+
enable-cache: true # Enable caching for faster builds
24+
25+
- name: Set up Python
26+
run: uv python install
27+
28+
- name: Install dependencies
29+
run: uv sync --all-extras --dev
30+
31+
- name: Run tests
32+
run: uvx pytest
33+

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ Run app in development:
3333
uv run fob
3434
```
3535

36+
# Test
37+
38+
```
39+
uvx pytest
40+
```
41+
42+
This is an end-to-end test. It installs `fob` to a temporary directory using `install.sh` and runs commands against it.
43+
3644
# Release
3745

38-
From the root of this repository, run `dev_install.sh`. It uses pyinstaller to create a standalone binary and places it in `~/.local/bin` for access from anywhere on the system.
46+
From the root of this repository, run `install.sh`. It uses pyinstaller to create a standalone binary and places it in `~/.local/bin` for access from anywhere on the system.
3947

40-
Create a new Github Release with a new tag and upload the executable (path should be shown by `dev_install.sh`) to the Github Release.
48+
Create a new Github Release with a new tag and upload the executable. The binary is at: `dist/fob`.
4149

4250
# Features
4351

@@ -50,7 +58,9 @@ fob --database ~/Dropbox/my-fob.db help
5058
```
5159

5260
For more convenience, you can export a `FOB_DB_PATH` variable in your shell.
53-
For example, if you're using bash shell, add the following line to `~/.bashrc`:
61+
62+
For example, to use a database synchronized across devices on your Dropbox,
63+
add the following line to `~/.bashrc` (for bash shell):
5464
```
5565
export FOB_DB_PATH="~/Dropbox/my-fob.db"
5666
```

dev_install.sh renamed to install.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ if ! [ -x "$(command -v uv)" ]; then
1515
exit 1
1616
fi
1717

18+
# Check for custom installation path
19+
if [ -z "$1" ]; then
20+
INSTALL_PATH="$HOME/.local/bin"
21+
else
22+
INSTALL_PATH="$1"
23+
fi
24+
1825
# Activate the virtual environment
1926
uv venv
2027
source .venv/bin/activate
@@ -25,20 +32,14 @@ uv add pyinstaller
2532
# Call the tool
2633
pyinstaller --onefile --name fob src/fob/__init__.py
2734

28-
# Copy the executable to somewhere on your PATH
29-
DEST_PATH="$HOME/.local/bin"
30-
31-
# Delete previous version
32-
rm "$DEST_PATH/fob"
33-
34-
# Copy the executable to somewhere on your PATH
35-
echo "Copying the executable to $DEST_PATH..."
35+
# Copy the executable to the custom installation path
36+
echo "Copying the executable to $INSTALL_PATH..."
3637

37-
mkdir -p "$DEST_PATH"
38-
cp dist/fob "$DEST_PATH"
38+
mkdir -p "$INSTALL_PATH"
39+
cp dist/fob "$INSTALL_PATH"
3940

4041
# Clean up
4142
echo "Cleaning up..."
4243
rm -r dist build fob.spec
4344

44-
echo "Installation complete. The 'fob' command is now available. If not, please check that $DEST_PATH is in your PATH environment variable."
45+
echo "Installation complete. The 'fob' command is now available in $INSTALL_PATH. If not, please check that $INSTALL_PATH is in your PATH environment variable."

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ authors = [{ name = "tensorturtle", email = "[email protected]" }]
88
requires-python = ">=3.12"
99
dependencies = [
1010
"pyinstaller>=6.11.1",
11+
"pytest>=8.3.4",
1112
"rich>=13.9.4",
1213
"tinydb>=4.8.2",
1314
]
1415

1516
[project.scripts]
16-
fob = "fob:main"
17+
fob = "fob:main"

src/fob/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def run_app():
2020
print(
2121
'''[red][bold]Incorrect usage.[/bold][/red]
2222
23-
[green][bold]Usage:[/bold][/green] [cyan][bold]fob[/bold] [OPTIONS] <command>[/cyan]
23+
[cyan][bold]Usage:[/bold][/cyan] [green][bold]fob[/bold] [OPTIONS] <command>[/green]
2424
25-
Try [cyan bold]fob help[/cyan bold] for usage information.
25+
Try [green][bold]fob help[/green][/bold] for usage information.
2626
'''
2727
)
2828
sys.exit(1)

src/fob/commands/didnt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def didnt(args: Namespace, db: TinyDBWrapper):
9393

9494
# print success message
9595
display_checklist(args, db)
96-
print(f"[green]Block {num_to_convert} converted to Buffer block.[/green] See overview: [cyan]fob sup[/cyan]")
96+
print(f"[green]Block {num_to_convert} converted to Buffer block.[/green] See overview: [green]fob sup[/green]")
9797

9898
except ValueError:
9999
print("[red][bold]Please enter a number that corresponds to the checklist item[/red][/bold]")

src/fob/commands/help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def help(args: Namespace | None, db: TinyDBWrapper | None) -> None:
2222
[green bold]didnt[/green bold] Convert a block from today's checklist to to a 'Buffer' block.
2323
[green bold]reset[/green bold] Delete persistent database file.
2424
25-
[green bold]Global Options:[/green bold]
25+
[cyan bold]Global Options:[/cyan bold]
2626
[green bold]-d, --database[/green bold] [magenta not bold]<PATH_TO_DB_FILE>[/magenta not bold] Path to database file. You can use a cloud storage (eg. Dropbox) to sync the database across devices.
2727
[green bold]-x, --debug[/green bold] Enable debug mode.
2828

src/fob/commands/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def info(args: Namespace, db: TinyDBWrapper):
1717
print("Licensed under the MIT License. https://opensource.org/license/mit")
1818
print("\n")
1919
print("[reverse] Configuration Information [/reverse]")
20-
print(f"Using database at: [magenta]{get_db_path(args)}[/magenta]")
20+
print(f"Using database at: [magenta]{get_db_path(args)}[/magenta]")

src/fob/commands/overviews/day_checklist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def display_checklist(args: Namespace, db: TinyDBWrapper) -> None:
1111
checklist = db.all()[0]['checklist']
1212
except (IndexError, KeyError):
1313
print("[red][bold]No day data found.[/red][/bold]")
14-
print("Run [cyan][bold]fob gm[/cyan][/bold] to start a new day.")
14+
print("Run [green][bold]fob gm[/green][/bold] to start a new day.")
1515
return
1616
if args.debug:
1717
print("Checklist from DB:")

src/fob/commands/overviews/month_overview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def month_overview(args: Namespace, db: TinyDBWrapper) -> None:
2424
data = db.search(where('year') == today.year and where('month') == today.month)[0]
2525
except IndexError:
2626
print("[red][bold]No month data found.[/red][/bold]")
27-
print("Run [cyan][bold]fob new_month[/cyan][/bold] to start a new month.")
27+
print("Run [green][bold]fob new_month[/green][/bold] to start a new month.")
2828
return
2929

3030
console = Console()

0 commit comments

Comments
 (0)