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

Added testing multiple python version support #14

Merged
merged 6 commits into from
Oct 8, 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
103 changes: 103 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Test

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
schedule:
# cron every week on monday
- cron: "0 0 * * 1"

jobs:
test:
name: test ${{ matrix.os }} / ${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
# Python 3.8 and 3.9 are not available on macOS 14
- os: macos-13
python-version: '3.10'
- os: macos-13
python-version: '3.11'
- os: macos-13
python-version: '3.12'
- os: macos-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.9'
defaults:
run:
shell: bash
env:
OS: ${{ matrix.os }}
DEPS: yes

runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

#----------------------------------------------
# ----- Checkout and Python setup -----
#----------------------------------------------
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
# cache-dependency-path: pyproject.toml
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --only main,gh
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction --only main,gh
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: |
source $VENV
pytest -s
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: coverage
include-hidden-files: true
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ endif

SETTINGS_FILENAME = pyproject.toml

.PHONY: install
install:
poetry install --no-interaction

.PHONY: install-main
install-main:
poetry install --no-interaction --only main

.PHONY: secure
secure:
${PYTHON} -m bandit -r integrify --config ${SETTINGS_FILENAME}
poetry run bandit -r integrify --config ${SETTINGS_FILENAME}

.PHONY: test
test:
poetry run pytest -s
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,28 @@
<em>Integrify API inteqrasiyalarını rahatlaşdıran sorğular kitabaxanasıdır.</em>
</p>
<p align="center">
<a href="https://app.netlify.com/sites/integrify-docs/deploys">
<img src="https://api.netlify.com/api/v1/badges/d8931b6a-80c7-41cb-bdbb-bf6ef5789f80/deploy-status" alt="Netlify Status">
</a>
<a href="https://github.com/mmzeynalli/integrify/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
<img src="https://github.com/mmzeynalli/integrify/workflows/Test/badge.svg?event=push&branch=master" alt="Test">
</a>
<a href="https://pypi.org/project/integrify" target="_blank">
<img src="https://img.shields.io/pypi/v/integrify?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://app.netlify.com/sites/integrify-docs/deploys">
<img src="https://api.netlify.com/api/v1/badges/d8931b6a-80c7-41cb-bdbb-bf6ef5789f80/deploy-status" alt="Netlify Status">
</a>
<a href="https://pepy.tech/project/integrify" target="_blank">
<img src="https://static.pepy.tech/badge/integrify" alt="Downloads">
</a>
<a href="https://pypi.org/project/integrify" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/integrify.svg?color=%2334D058" alt="Supported Python versions">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/mmzeynalli/integrify" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/mmzeynalli/integrify.svg" alt="Coverage">
</a>

</p>


---

**Dokumentasiya**: [https://integrify.mmzeynalli.dev](https://integrify.mmzeynalli.dev)
Expand Down
4 changes: 2 additions & 2 deletions docs/epoint/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
???+ note

Bu artıq hazır yaradılmış klass obyektidir, birbaşa istifadə üçün nəzərdə tutulub. Əks halda
bütün sorğuları `_EPointRequest().save_card()` kimi istifadə etməlisiniz.
bütün sorğuları `EPointRequestClass().save_card()` kimi istifadə etməlisiniz.

::: integrify.epoint.sync._EPointRequest
::: integrify.epoint.sync.EPointRequestClass
handler: python
options:
members:
Expand Down
24 changes: 20 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<p align="center">
<a href="https://integrify.mmzeynalli.dev/"><img width="400" src="assets/integrify.png" alt="Integrify"></a>
<a href="https://integrify.mmzeynalli.dev/"><img width="400" src="https://raw.githubusercontent.com/mmzeynalli/integrify/main/docs/assets/integrify.png" alt="Integrify"></a>
</p>
<p align="center">
<em>Integrify API inteqrasiyalarını rahatlaşdıran sorğular kitabaxanasıdır.</em>
</p>
<p align="center">
<a href="https://app.netlify.com/sites/integrify-docs/deploys">
<img src="https://api.netlify.com/api/v1/badges/d8931b6a-80c7-41cb-bdbb-bf6ef5789f80/deploy-status" alt="Netlify Status">
</a>
<a href="https://github.com/mmzeynalli/integrify/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
<img src="https://github.com/mmzeynalli/integrify/workflows/Test/badge.svg?event=push&branch=master" alt="Test">
</a>
<a href="https://pypi.org/project/integrify" target="_blank">
<img src="https://img.shields.io/pypi/v/integrify?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://app.netlify.com/sites/integrify-docs/deploys">
<img src="https://api.netlify.com/api/v1/badges/d8931b6a-80c7-41cb-bdbb-bf6ef5789f80/deploy-status" alt="Netlify Status">
</a>
<a href="https://pepy.tech/project/integrify" target="_blank">
<img src="https://static.pepy.tech/badge/integrify" alt="Downloads">
</a>
<a href="https://pypi.org/project/integrify" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/integrify.svg?color=%2334D058" alt="Supported Python versions">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/mmzeynalli/integrify" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/mmzeynalli/integrify.svg" alt="Coverage">
</a>

</p>

---
Expand Down
1 change: 1 addition & 0 deletions docs/js/goatcounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script data-goatcounter="https://mmzeynalli.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
1 change: 0 additions & 1 deletion integrify/__init__.py

This file was deleted.

4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ plugins:
default_handler: python
handlers:
python:
paths: [src]
options:
show_root_heading: true
show_source: false
Expand Down Expand Up @@ -118,4 +119,5 @@ extra_css:

extra_javascript:
- js/termynal.js
- js/custom.js
- js/custom.js
- js/goatcounter.js
23 changes: 20 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "integrify"
packages = [{include = "integrify", from="src"}]
version = "1.0.3"
description = "Integrify API inteqrasiyalarını rahatlaşdıran sorğular kitabaxanasıdır."
license = "GPL-3.0-or-later"
Expand Down Expand Up @@ -32,6 +33,7 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -41,23 +43,35 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.8"
pydantic = "^2.8.2"
httpx = "^0.27.2"

# Packages needed for Github Actions, for future, we might add others
[tool.poetry.group.gh]
optional = true

[tool.poetry.group.gh.dependencies]
pytest = "^8.1.1"
pytest-mock = "^3.14.0"

[tool.poetry.group.dev.dependencies]
pytest = "^8.1.1"
pytest-mock = "^3.14.0"
mypy = "^1.9.0"
ruff = "^0.3.5"
pre-commit = "^3.6.2"
pre-commit = [
{ version = "^3.8.0", python = ">=3.9" },
{ version = "^3.5.0", python = "3.8" }
]
ptpython = "^3.0.29"
mkdocs-material = "^9.5.36"
mkdocstrings = {extras = ["python"], version = "^0.26.1"}
bandit = "^1.7.10"
coverage-badge = "^1.1.2"

[tool.ruff]
target-version = "py311"
target-version = "py38"
line-length = 100

[tool.ruff.lint]
Expand All @@ -78,6 +92,9 @@ quote-style = "single"
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.pytest.ini_options]
pythonpath = ["src/"]

[tool.bandit]
skips = []

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

from integrify.base import ApiResponse, AsyncApiRequest
from integrify.epoint.helper import generate_signature
from integrify.epoint.schemas.types import (
from integrify.epoint.schemas.response import (
BaseResponseSchema,
MinimalResponseSchema,
RedirectUrlResponseSchema,
RedirectUrlWithCardIdResponseSchema,
SplitPayWithSavedCardResponseSchema,
TransactionStatusResponseSchema,
)
from integrify.epoint.sync import _EPointRequest as SyncEPointRequest
from integrify.epoint.sync import EPointRequestClass as SyncEPointRequest

__all__ = ['EPointRequest']


class _EPointRequest(AsyncApiRequest, SyncEPointRequest):
class EPointRequestClass(AsyncApiRequest, SyncEPointRequest):
"""EPoint async sorğular üçün baza class"""

async def pay( # type: ignore[override]
Expand Down Expand Up @@ -349,4 +349,4 @@ async def __call__(self, *args, **kwargs):
return await super().__call__(*args, **kwargs)


EPointRequest = _EPointRequest()
EPointRequest = EPointRequestClass()
File renamed without changes.
14 changes: 11 additions & 3 deletions integrify/epoint/helper.py → src/integrify/epoint/helper.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import base64
import json

import sys
from functools import partial
from hashlib import sha1

from integrify.epoint import env
from integrify.epoint.schemas.types import CallbackDataSchema, DecodedCallbackDataSchema
from integrify.epoint.schemas.response import CallbackDataSchema, DecodedCallbackDataSchema

__all__ = ['generate_signature', 'decode_callback_data']

# Python 3.8 support
if sys.version_info >= (3, 9):
_sha1 = partial(sha1, usedforsecurity=False)
else:
_sha1 = sha1


def generate_signature(data: str) -> str:
sgn_string = env.EPOINT_PRIVATE_KEY + data + env.EPOINT_PRIVATE_KEY
return base64.b64encode(sha1(sgn_string.encode(), usedforsecurity=False).digest()).decode()
return base64.b64encode(_sha1(string=sgn_string.encode()).digest()).decode()


def decode_callback_data(data: CallbackDataSchema) -> DecodedCallbackDataSchema:
Expand Down
Empty file.
6 changes: 3 additions & 3 deletions integrify/epoint/sync.py → src/integrify/epoint/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from integrify.base import ApiResponse, SyncApiRequest, send_request
from integrify.epoint import env
from integrify.epoint.helper import generate_signature
from integrify.epoint.schemas.types import (
from integrify.epoint.schemas.response import (
BaseResponseSchema,
MinimalResponseSchema,
RedirectUrlResponseSchema,
Expand All @@ -18,7 +18,7 @@
__all__ = ['EPointRequest']


class _EPointRequest(SyncApiRequest):
class EPointRequestClass(SyncApiRequest):
"""EPoint sorğular üçün baza class"""

def __init__(self):
Expand Down Expand Up @@ -510,4 +510,4 @@ def __call__(self, *args, **kwargs):
return super().__call__(*args, **kwargs)


EPointRequest = _EPointRequest()
EPointRequest = EPointRequestClass()
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/epoint/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from typing import Any

import pytest
from pytest_mock import MockerFixture

from integrify.base import ApiResponse
from integrify.epoint.schemas.parts import TransactionStatus
from integrify.epoint.sync import _EPointRequest
from integrify.epoint.sync import EPointRequestClass
from pytest_mock import MockerFixture

from tests import epoint
from tests.epoint.mocks import * # noqa: F403


class TestEPointRequest(_EPointRequest):
class TestEPointRequest(EPointRequestClass):
__test__ = False

def __init__(self, resp_data: dict):
Expand Down
Loading