Skip to content

Commit

Permalink
set up a hello world unit test and Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hchen_codon committed Mar 12, 2024
1 parent f5afd7d commit 5141561
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python Application Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
- name: Test with pytest
run: |
pytest ./tests/
12 changes: 12 additions & 0 deletions phuego/cli_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# /repo/phuego/cli_app.py
import click

@click.command()
@click.option('--greeting', default='Hello', help='Greeting phrase.')
@click.option('--name', default='World', help='Name to greet.')
def greet(greeting, name):
"""Simple program that greets NAME for a total of COUNT times."""
click.echo(f"{greeting}, {name}!")

if __name__ == '__main__':
greet()
Empty file removed tests/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions tests/test_hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# /repo/tests/test_hello_world.py
from click.testing import CliRunner
from phuego.cli_app import greet

def test_greet():
runner = CliRunner()
result = runner.invoke(greet, ['--name', 'World'])
assert result.exit_code == 0
assert 'Hello, World!' in result.output

0 comments on commit 5141561

Please sign in to comment.