Skip to content

Commit

Permalink
1.0 branch created. And python module renamed.
Browse files Browse the repository at this point in the history
Signed-off-by: Lalith Kota <kotalalith@gmail.com>
  • Loading branch information
lalithkota committed Jan 6, 2025
1 parent 9e00e55 commit 11b1bc0
Show file tree
Hide file tree
Showing 67 changed files with 113 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ github_ci_precommit: true
github_ci_pypi_publish: true
github_ci_tests: true
github_ci_tests_codecov: true
module_name: openg2p_portal_api
module_name: openg2p_beneficiary_portal_api
org_name: OpenG2P
org_slug: OpenG2P
package_name: openg2p-portal-api
repo_name: OpenG2P Portal API
package_name: openg2p-beneficiary-portal-api
repo_name: OpenG2P Beneficiary Portal API
repo_slug: openg2p-portal-api

2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
SERVICE_NAME: openg2p-selfservice-api
SERVICE_NAME: openg2p-beneficiary-portal-api
steps:
- uses: actions/checkout@v3
- name: Docker build
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/openapi-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
python-version: "3.10"
- name: Install app
run: |
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-common
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-auth
python -m pip install .
- name: Generate openapi json
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Publish to PyPI

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish-to-pypi:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Tag the repo
on:
workflow_dispatch:
inputs:
new-tag:
description: Tag in "vN.N.N" format
required: true
type: string
previous-tag:
description: Previous tag. "None" if no previous tag
required: true
type: string
default: latest
jobs:
tag-repo:
uses: openg2p/openg2p-packaging/.github/workflows/tag.yml@main
with:
new-tag: ${{ inputs.new-tag }}
previous-tag: ${{ inputs.previous-tag }}
secrets:
OPENG2P_BOT_GITHUB_PAT: ${{ secrets.OPENG2P_BOT_GITHUB_PAT }}
11 changes: 1 addition & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ jobs:
- "3.10"
os:
- ubuntu-latest
services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: openg2p
POSTGRES_PASSWORD: openg2p
POSTGRES_DB: openg2p
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -43,7 +34,7 @@ jobs:
python -m pip install -e .
- name: Run test suite
run: |
pytest --cov-branch --cov-report=term-missing --cov=openg2p_portal_api --cov=tests
pytest --cov-branch --cov-report=term-missing --cov=openg2p_beneficiary_portal_api --cov=tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ USER ${container_user}
ADD --chown=${container_user}:${container_user_group} . /app/src
ADD --chown=${container_user}:${container_user_group} main.py /app

RUN python3 -m venv venv \
&& . ./venv/bin/activate
RUN python3 -m pip install \
git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-common \
git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-auth \
./src
RUN python3 -m pip install ./src

CMD python3 main.py migrate; \
python3 main.py run
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# OpenG2P Portal API
[![Pre-commit Status](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/pre-commit.yml/badge.svg?branch=develop)](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/pre-commit.yml?query=branch%3Adevelop)
[![Build Status](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/test.yml/badge.svg?branch=develop)](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/test.yml?query=branch%3Adevelop)
[![codecov](https://codecov.io/gh/OpenG2P/openg2p-portal-api/branch/develop/graph/badge.svg)](https://codecov.io/gh/OpenG2P/openg2p-portal-api)
[![openapi](https://img.shields.io/badge/open--API-swagger-brightgreen)](https://validator.swagger.io/?url=https://raw.githubusercontent.com/OpenG2P/openg2p-portal-api/develop/api-docs/generated/openapi.json)
![PyPI](https://img.shields.io/pypi/v/openg2p-portal-api?label=pypi%20package)
![PyPI - Downloads](https://img.shields.io/pypi/dm/openg2p-portal-api)

# OpenG2P Beneficiary Portal API
[![Pre-commit Status](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/pre-commit.yml/badge.svg?branch=1.0)](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/pre-commit.yml?query=branch%3A1.0)
[![Build Status](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/test.yml/badge.svg?branch=1.0)](https://github.com/OpenG2P/openg2p-portal-api/actions/workflows/test.yml?query=branch%3A1.0)
[![codecov](https://codecov.io/gh/OpenG2P/openg2p-portal-api/branch/1.0/graph/badge.svg)](https://codecov.io/gh/OpenG2P/openg2p-portal-api)
[![openapi](https://img.shields.io/badge/open--API-swagger-brightgreen)](https://validator.swagger.io/?url=https://raw.githubusercontent.com/OpenG2P/openg2p-portal-api/1.0/api-docs/generated/openapi.json)
[![PyPI](https://img.shields.io/pypi/v/openg2p-beneficiary-portal-api?label=pypi%20package)](https://pypi.org/project/openg2p-beneficiary-portal-api)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/openg2p-beneficiary-portal-api)](https://pypi.org/project/openg2p-beneficiary-portal-api)


## Licenses
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

# ruff: noqa: I001

from openg2p_portal_api.app import Initializer as SelfServicePortalInitializer
from openg2p_beneficiary_portal_api.app import (
Initializer as SelfServicePortalInitializer,
)
from openg2p_fastapi_common.ping import PingInitializer

main_init = SelfServicePortalInitializer()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "openg2p-portal-api"
name = "openg2p-beneficiary-portal-api"
authors = [
{ name="OpenG2P", email="info@openg2p.org" },
]
Expand All @@ -30,4 +30,4 @@ Repository = "https://github.com/OpenG2P/openg2p-portal-api"
Source = "https://github.com/OpenG2P/openg2p-portal-api"

[tool.hatch.version]
path = "src/openg2p_portal_api/__init__.py"
path = "src/openg2p_beneficiary_portal_api/__init__.py"
1 change: 1 addition & 0 deletions src/openg2p_beneficiary_portal_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
UnauthorizedError,
)

from openg2p_portal_api.models.document_file import DocumentFile

from ..config import Settings
from ..dependencies import JwtBearerAuth
from ..models.credentials import AuthCredentials
from ..models.document_file import DocumentFile
from ..services.document_file_service import DocumentFileService

_config = Settings.get_config()
Expand Down
File renamed without changes.
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 @@ -4,7 +4,7 @@
from sqlalchemy import JSON, Boolean, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship

from openg2p_portal_api.models.orm.document_file_orm import DocumentFileORM
from .document_file_orm import DocumentFileORM


class DocumentStoreORM(BaseORMModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from sqlalchemy.ext.asyncio import async_sessionmaker
from sqlalchemy.orm import Mapped, mapped_column, relationship

from openg2p_portal_api.models.orm.document_file_orm import DocumentFileORM

from .document_file_orm import DocumentFileORM
from .reg_id_orm import RegIDORM


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from sqlalchemy.ext.asyncio import async_sessionmaker
from sqlalchemy.orm import Mapped, mapped_column, relationship

from openg2p_portal_api.models.orm.document_file_orm import DocumentFileORM

from .document_file_orm import DocumentFileORM
from .program_registrant_info_orm import ProgramRegistrantInfoORM


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import async_sessionmaker

from openg2p_portal_api.exception import handle_exception
from openg2p_portal_api.models.document_file import DocumentFile
from openg2p_portal_api.services.membership_service import MembershipService
from openg2p_portal_api.utils.file_utils import (
from ..exception import handle_exception
from ..models.document_file import DocumentFile
from ..models.orm.document_file_orm import DocumentFileORM
from ..utils.file_utils import (
compute_human_file_size,
create_or_update_tag,
extract_filename,
Expand All @@ -24,8 +24,7 @@
get_s3_backend_config,
update_slug_relative_path,
)

from ..models.orm.document_file_orm import DocumentFileORM
from .membership_service import MembershipService


class DocumentFileService(BaseService):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from sqlalchemy import select
from sqlalchemy.exc import SQLAlchemyError

from openg2p_portal_api.exception import handle_exception
from openg2p_portal_api.models.orm.document_file_orm import DocumentFileORM
from openg2p_portal_api.models.orm.document_store_orm import DocumentStoreORM
from openg2p_portal_api.models.orm.document_tag_orm import DocumentTagORM
from openg2p_portal_api.models.orm.program_orm import ProgramORM
from ..exception import handle_exception
from ..models.orm.document_file_orm import DocumentFileORM
from ..models.orm.document_store_orm import DocumentStoreORM
from ..models.orm.document_tag_orm import DocumentTagORM
from ..models.orm.program_orm import ProgramORM

# The methods below enable concurrent document uploads to Odoo and MinIO (S3-compatible).
# - get_s3_backend_config
Expand Down
1 change: 0 additions & 1 deletion src/openg2p_portal_api/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ pytest-cov
pytest-asyncio
pytest
pytest-mock
python-slugify>=8.0.0
git+https://github.com/openg2p/openg2p-fastapi-common@develop#subdirectory=openg2p-fastapi-common
git+https://github.com/openg2p/openg2p-fastapi-common@develop#subdirectory=openg2p-fastapi-auth
14 changes: 8 additions & 6 deletions tests/test_auth_controller.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from openg2p_fastapi_auth.models.orm.login_provider import LoginProvider
from openg2p_portal_api.controllers.auth_controller import AuthController
from openg2p_portal_api.models.orm.auth_oauth_provider import AuthOauthProviderORM
from openg2p_portal_api.models.orm.partner_orm import (
from openg2p_beneficiary_portal_api.controllers.auth_controller import AuthController
from openg2p_beneficiary_portal_api.models.orm.auth_oauth_provider import (
AuthOauthProviderORM,
)
from openg2p_beneficiary_portal_api.models.orm.partner_orm import (
BankORM,
PartnerBankORM,
PartnerORM,
PartnerPhoneNoORM,
)
from openg2p_portal_api.models.orm.reg_id_orm import RegIDORM, RegIDTypeORM
from openg2p_portal_api.models.profile import UpdateProfile
from openg2p_beneficiary_portal_api.models.orm.reg_id_orm import RegIDORM, RegIDTypeORM
from openg2p_beneficiary_portal_api.models.profile import UpdateProfile
from openg2p_fastapi_auth.models.orm.login_provider import LoginProvider
from sqlalchemy.exc import IntegrityError

TEST_CONSTANTS = {
Expand Down
8 changes: 5 additions & 3 deletions tests/test_discovery_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from unittest.mock import AsyncMock, patch

import pytest
from openg2p_portal_api.controllers.discovery_controller import DiscoveryController
from openg2p_portal_api.models.program import ProgramBase
from openg2p_portal_api.services.program_service import ProgramService
from openg2p_beneficiary_portal_api.controllers.discovery_controller import (
DiscoveryController,
)
from openg2p_beneficiary_portal_api.models.program import ProgramBase
from openg2p_beneficiary_portal_api.services.program_service import ProgramService

TEST_DATA = {
"PROGRAM_NAME": "Test Program",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_document_file_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import pytest
from fastapi import UploadFile
from openg2p_beneficiary_portal_api.controllers.document_file_controller import (
DocumentFileController,
)
from openg2p_beneficiary_portal_api.models.document_file import DocumentFile
from openg2p_fastapi_auth.models.credentials import AuthCredentials
from openg2p_fastapi_common.errors.http_exceptions import (
BadRequestError,
UnauthorizedError,
)
from openg2p_portal_api.controllers.document_file_controller import (
DocumentFileController,
)
from openg2p_portal_api.models.document_file import DocumentFile


@pytest.fixture
Expand Down
16 changes: 10 additions & 6 deletions tests/test_document_file_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import pytest
from fastapi import UploadFile
from openg2p_beneficiary_portal_api.models.document_file import DocumentFile
from openg2p_beneficiary_portal_api.models.orm.document_file_orm import DocumentFileORM
from openg2p_beneficiary_portal_api.models.orm.document_store_orm import (
DocumentStoreORM,
)
from openg2p_beneficiary_portal_api.models.orm.document_tag_orm import DocumentTagORM
from openg2p_beneficiary_portal_api.models.orm.program_orm import ProgramORM
from openg2p_beneficiary_portal_api.services.document_file_service import (
DocumentFileService,
)
from openg2p_fastapi_common.errors.http_exceptions import BadRequestError
from openg2p_portal_api.models.document_file import DocumentFile
from openg2p_portal_api.models.orm.document_file_orm import DocumentFileORM
from openg2p_portal_api.models.orm.document_store_orm import DocumentStoreORM
from openg2p_portal_api.models.orm.document_tag_orm import DocumentTagORM
from openg2p_portal_api.models.orm.program_orm import ProgramORM
from openg2p_portal_api.services.document_file_service import DocumentFileService
from sqlalchemy.ext.asyncio import AsyncSession

TEST_CONSTANTS = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from openg2p_beneficiary_portal_api.exception import handle_exception
from openg2p_fastapi_common.errors.http_exceptions import BadRequestError
from openg2p_portal_api.exception import handle_exception


class TestExceptionHandler:
Expand Down
11 changes: 7 additions & 4 deletions tests/test_form_controller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from unittest.mock import AsyncMock, MagicMock

import pytest
from openg2p_beneficiary_portal_api.controllers.form_controller import FormController
from openg2p_beneficiary_portal_api.models.credentials import AuthCredentials
from openg2p_beneficiary_portal_api.models.form import (
ProgramForm,
ProgramRegistrantInfo,
)
from openg2p_beneficiary_portal_api.models.program import Program
from openg2p_fastapi_common.errors.http_exceptions import (
BadRequestError,
UnauthorizedError,
)
from openg2p_portal_api.controllers.form_controller import FormController
from openg2p_portal_api.models.credentials import AuthCredentials
from openg2p_portal_api.models.form import ProgramForm, ProgramRegistrantInfo
from openg2p_portal_api.models.program import Program


@pytest.fixture
Expand Down
8 changes: 4 additions & 4 deletions tests/test_form_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import pytest
from fastapi import HTTPException
from openg2p_portal_api.models.form import ProgramForm
from openg2p_portal_api.models.orm.program_orm import ProgramORM
from openg2p_portal_api.models.orm.program_registrant_info_orm import (
from openg2p_beneficiary_portal_api.models.form import ProgramForm
from openg2p_beneficiary_portal_api.models.orm.program_orm import ProgramORM
from openg2p_beneficiary_portal_api.models.orm.program_registrant_info_orm import (
ProgramRegistrantInfoDraftORM,
)
from openg2p_portal_api.services.form_service import FormService
from openg2p_beneficiary_portal_api.services.form_service import FormService

TEST_DATA = {
"PROGRAM_ID": 1,
Expand Down
6 changes: 4 additions & 2 deletions tests/test_membership_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from openg2p_portal_api.models.orm.program_membership_orm import ProgramMembershipORM
from openg2p_portal_api.services.membership_service import MembershipService
from openg2p_beneficiary_portal_api.models.orm.program_membership_orm import (
ProgramMembershipORM,
)
from openg2p_beneficiary_portal_api.services.membership_service import MembershipService
from sqlalchemy.exc import IntegrityError


Expand Down
Loading

0 comments on commit 11b1bc0

Please sign in to comment.