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

Develop #8

Merged
merged 7 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
status:
project:
default:
target: auto
threshold: 5%
9 changes: 3 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
jobs:
publish:
strategy:
max-parallel: 1
matrix:
python-version: [3.11]
defaults:
Expand All @@ -35,11 +34,9 @@ jobs:
# ----- install & configure poetry -----
#----------------------------------------------
- name: 📜 Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
run: |
python -m pip install -U pip poetry
poetry --version

#----------------------------------
# ----- load cached venv -----
Expand Down
34 changes: 19 additions & 15 deletions .github/workflows/test_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ on:
jobs:
test:
strategy:
max-parallel: 1
max-parallel: 3
matrix:
os: [
ubuntu-latest,
# windows-latest,
macos-latest,
]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.11]
defaults:
run:
Expand Down Expand Up @@ -49,11 +45,9 @@ jobs:
# ----- install & configure poetry -----
#----------------------------------------------
- name: 📜 Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
run: |
python -m pip install -U pip poetry
poetry --version

#----------------------------------
# ----- load cached venv -----
Expand All @@ -72,16 +66,26 @@ jobs:
run: |
poetry install --no-interaction

#------------------------------------------------------
# ------------ setup creds based on os ------------
#------------------------------------------------------
- name: Setup creds based on os
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "CREDENTIALS_JSON=${{ secrets.PYTEST_CREDENTIALS_WIN }}" >> $GITHUB_ENV
elif [[ "${{ runner.os }}" == "macOS" ]]; then
echo "CREDENTIALS_JSON=${{ secrets.PYTEST_CREDENTIALS_MAC }}" >> $GITHUB_ENV
else
echo "CREDENTIALS_JSON=${{ secrets.PYTEST_CREDENTIALS_LINUX }}" >> $GITHUB_ENV
fi

#-----------------------------------------------
# ------------- run test suite ------------
#-----------------------------------------------
- name: 🧪 Run tests
if: always()
env:
CREDENTIALS_JSON: ${{ secrets.PYTEST_CREDENTIALS }}
run: |
source $VENV
echo $CREDENTIALS_JSON | base64 -d > ./tests/test_creds.json
echo $CREDENTIALS_JSON | base64 -d > ./tests/credentials/test_creds.json
make test

#----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ test_init.py
.mypy_cache
.pytest_cache
.ruff_cache
.coverage
.coverage*
coverage.xml
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ format:
### Commands to run the tests ###
# base64 encode the credentials: base64 -i tests/test_creds.json
test-gen-creds:
@poetry run pyrevolut auth-manual --credentials-json tests/test_creds.json
@poetry run pyrevolut auth-manual --credentials-json tests/credentials/test_creds.json

test-lint:
@echo "Running lint tests..."
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Pyrevolut: A Revolut Business API Wrapper

[![codecov](https://codecov.io/gh/Trevypants/pyrevolut/graph/badge.svg?token=55UY8J1YZM)](https://codecov.io/gh/Trevypants/pyrevolut)
[![PyPI Package latest release](https://badge.fury.io/py/pyrevolut.svg)](https://badge.fury.io/py/pyrevolut)
[![Supported versions](https://img.shields.io/pypi/pyversions/pyrevolut)](https://pypi.org/project/pyrevolut/)
[![License](https://img.shields.io/pypi/l/pyrevolut)](https://pypi.org/project/pyrevolut/)
[![PyPI Package download count (per month)](https://img.shields.io/pypi/dm/pyrevolut)](https://pypi.org/project/pyrevolut/)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Trevypants/pyrevolut/test_integration.yml?branch=develop)](https://github.com/Trevypants/pyrevolut/actions)

`pyrevolut` is an un-official wrapper around the [Revolut Business API](https://developer.revolut.com/docs/business/business-api).

## Installation
Expand Down
803 changes: 1 addition & 802 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,18 @@ black = "24.*"
pytest-sugar = "0.*"
pytest-instafail = "0.*"
pytest-profiling = "1.*"
pytest-memray = "1.*"
pytest-randomly = "3.*"
pytest-clarity = "1.*"
pytest-network = "0.*"
pytest-resource-usage = "1.*"
pytest-split = "0.*"
pytest-env = "1.*"
locust = "2.*"
requests-toolbelt = "1.*"

[tool.pytest.ini_options]
pythonpath = ["."]
filterwarnings = []
addopts = "--instafail -vv"
env = ["TEST_MODE=True"]
asyncio_mode = "auto"
log_cli = false
log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
Expand Down
1 change: 0 additions & 1 deletion pyrevolut/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# flake8: noqa: F401
from .concurrency import execute_async_group, empty_async
from .date import Date
from .datetime import DateTime
114 changes: 0 additions & 114 deletions pyrevolut/utils/concurrency.py

This file was deleted.

39 changes: 30 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
import glob
import asyncio
import time
import random
import itertools

import pytest
import pytest_asyncio
Expand All @@ -17,7 +20,9 @@
5. session: the fixture is destroyed at the end of the test session.
"""

CREDENTIALS_LOC = "tests/test_creds.json"
# All the JSON files in the credentials folder
CREDENTIALS_LOC = glob.glob(os.path.join("tests/credentials", "*.json"))
CREDENTIALS_LOC_ITER = itertools.cycle(CREDENTIALS_LOC)


@pytest.fixture(scope="session", autouse=True)
Expand All @@ -30,8 +35,24 @@ def event_loop():
loop.close()


@pytest.fixture(scope="session")
def base_sync_client():
@pytest.fixture(scope="function")
def random_creds_file():
"""Context manager that selects a random credentials file

Yields
------
str
The path to the credentials file
"""
# Select a random credentials file
creds_loc = next(CREDENTIALS_LOC_ITER)

# Yield for test
yield creds_loc


@pytest.fixture(scope="function")
def base_sync_client(random_creds_file: str):
"""Context manager that initializes the sync client

Yields
Expand All @@ -40,7 +61,7 @@ def base_sync_client():
"""
# Initialize the client
client = Client(
creds_loc=CREDENTIALS_LOC,
creds_loc=random_creds_file,
sandbox=True,
return_type="dict",
)
Expand All @@ -49,8 +70,8 @@ def base_sync_client():
yield client


@pytest.fixture(scope="session")
def base_async_client():
@pytest.fixture(scope="function")
def base_async_client(random_creds_file: str):
"""Context manager that initializes the async client

Yields
Expand All @@ -59,7 +80,7 @@ def base_async_client():
"""
# Initialize the client
client = AsyncClient(
creds_loc=CREDENTIALS_LOC,
creds_loc=random_creds_file,
sandbox=True,
return_type="dict",
)
Expand All @@ -68,7 +89,7 @@ def base_async_client():
yield client


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def sync_client(base_sync_client: Client):
"""Context manager that initializes the sync client

Expand Down Expand Up @@ -106,7 +127,7 @@ def sync_client(base_sync_client: Client):
base_sync_client.close()


@pytest_asyncio.fixture(scope="session")
@pytest_asyncio.fixture(scope="function")
async def async_client(base_async_client: AsyncClient):
"""Context manager that initializes the async client

Expand Down
5 changes: 5 additions & 0 deletions tests/credentials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Credentials

For testing purposes, place your credentials in this directory. They will be ignored by git.
It is possible to place multiple credentials files in this directory, as long as they have the same format.
The tests will randomly pick one of the files per test.
Loading
Loading