Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/nav 145 extract python client package #1

Merged
merged 37 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ea2c9a4
ORG: NAV-145 - Setup poetry project
munterfi Aug 18, 2024
ae6f56e
ENH: NAV-145 - Add client sources
munterfi Aug 18, 2024
f825516
ORG: NAV-145 - Setup pycharm
munterfi Aug 18, 2024
c5bcf9f
ORG: NAV-145 - Build project, version current lock
munterfi Aug 18, 2024
9b2f6ae
TEST: NAV-145 - Setup unit tests
munterfi Aug 18, 2024
838e69b
TEST: NAV-145 - Setup integration tests
munterfi Aug 18, 2024
54bcf31
DOC: NAV-145 - Add readme describing the client, usage and testing
munterfi Aug 18, 2024
3a99023
ENH: NAV-145 - Define class methods as static methods since they don'…
munterfi Aug 18, 2024
4eaa38c
ENH: NAV-145 - Rename fields of pydantic model to snake_case
munterfi Aug 18, 2024
4794047
ENH: NAV-145 - Introduce error handling and logging
munterfi Aug 18, 2024
a0d425f
TEST: NAV-145 - Add unit test cases for the client
munterfi Aug 18, 2024
b5d00e0
FIX: NAV-145 - Fix mypy issues
munterfi Aug 18, 2024
383978f
STYLE: NAV-145 - Run black and isort
munterfi Aug 18, 2024
8220458
STYLE: NAV-145 - Add marker to unit tests
munterfi Aug 18, 2024
d763e44
DOC: NAV-145 - Update readme
munterfi Aug 18, 2024
92872cc
ORG: NAV-145 - Add poetry CI github action
munterfi Aug 18, 2024
9b38181
ORG: NAV-145 - Add poetry publish github action
munterfi Aug 18, 2024
993bd96
DOC: NAV-145 - Set title in README correctly
munterfi Aug 18, 2024
3c3295b
TEST: NAV-145 - Add integration test cases for client exceptions
munterfi Aug 19, 2024
6006672
ORG: NAV-145 - Enable dependabot
munterfi Aug 19, 2024
8bc2056
REFACTOR: NAV-145 - Remove typing imports in favor of inbuilt typing.
clukas1 Aug 20, 2024
3f4955f
FIX: NAV-145 - Fix mypy typing warning.
clukas1 Aug 20, 2024
f2c807d
DOC: NAV-145 - Add docstrings to models.
clukas1 Aug 20, 2024
e997111
DOC: NAV-145 - Add docstrings to client.
clukas1 Aug 20, 2024
034099f
ENH: NAV-145 - Add support for connections/isolines from coordinates.
clukas1 Aug 20, 2024
1844ab7
STYLE: NAV-145 - Run black, isort on project
clukas1 Aug 20, 2024
4729832
FIX: NAV-145 - Fix failing tests due to changed method signatures.
clukas1 Aug 20, 2024
ffbd13a
FIX: NAV-145 - More test adjustments.
clukas1 Aug 20, 2024
ce34d4c
STYLE: NAV-145 - Workaound for mypy to stop warnings that are none.
clukas1 Aug 20, 2024
b62ded5
DOC: NAV-145 - Update docstring of methods to specify connections can…
clukas1 Aug 20, 2024
f21a8b5
REFACTOR: NAV-145 - Rename start / destination to source / target to …
munterfi Aug 21, 2024
e00da29
FIX: NAV-145 - Fix mypy type ignore issue by adding a NONE check
munterfi Aug 21, 2024
496011c
STYLE: NAV-145 - Format
munterfi Aug 21, 2024
d7789c1
FIX: NAV-145 - Remove another type ignore
munterfi Aug 21, 2024
6abd840
DOC: NAV-145 - Update README
munterfi Aug 21, 2024
fe52793
DOC: NAV-145 - Set title level correctly
munterfi Aug 21, 2024
40a1664
DOC: NAV-145 - Remove development entry from README
munterfi Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
48 changes: 48 additions & 0 deletions .github/workflows/poetry-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Poetry CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [ 3.12 ]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH

- name: Set up cache
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/pypoetry
key: poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction --no-root

- name: Run unit tests
run: poetry run pytest -m unit

- name: Run mypy
run: poetry run mypy .
37 changes: 37 additions & 0 deletions .github/workflows/poetry-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Poetry Publish

on:
release:
types: [ created ]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction --no-root

- name: Build the package
run: |
poetry build

- name: Publish to PyPI
env:
TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --username __token__ --password $TOKEN --no-interaction --build
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/public-transit-client.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# public-transit-client
Client to access the public transit service.
# Public Transit Client

Client to access the [Public Transit Service](https://github.com/naviqore/public-transit-service) API endpoints.

It is designed to interact seamlessly with the service, offering easy-to-use methods to query
transit information and connections.

## Installation

To install the package, you can use pip:

```sh
pip install public-transit-client
```

## Usage

Here's a basic example of how to use the client:

```python
from public_transit_client.client import PublicTransitClient

client = PublicTransitClient("http://localhost:8080")
response = client.get_stop("NANAA")
print(response)
```

See the integration tests for more examples.

## Testing

This project uses pytest for both unit and integration testing. The tests are organized into separate folders to ensure
clarity and separation of concerns.

### Unit Tests

Unit tests are designed to test individual components in isolation. To run the unit tests, simply execute:

```sh
poetry run pytest -m unit
```

### Integration Tests

Integration tests ensure that the components work together as expected in a more realistic environment. These tests
require the service to be running, usually within a Docker container.

**Step 1: Start the Docker Compose Environment**

First, start the necessary services using Docker Compose:

```sh
docker compose up -d
```

**Step 2: Run Integration Tests**

Once the services are up and running, execute the integration tests with:

```sh
poetry run pytest -m integration
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'

services:
public-transit-service:
image: ghcr.io/naviqore/public-transit-service:latest
container_name: public-transit-service
ports:
- "8080:8080"
environment:
- GTFS_STATIC_URI=https://developers.google.com/static/transit/gtfs/examples/sample-feed.zip
healthcheck:
test: [ "CMD-SHELL", "curl -f http://localhost:8080/actuator/health | grep '\"status\":\"UP\"' || exit 1" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
restart: unless-stopped
Loading
Loading