Skip to content

Commit

Permalink
Merge pull request #32 from barseghyanartur/dev
Browse files Browse the repository at this point in the history
Feature/sqlalchemy example (#31)
  • Loading branch information
barseghyanartur authored Dec 11, 2023
2 parents e94f38c + c528916 commit 8c01084
Show file tree
Hide file tree
Showing 18 changed files with 1,161 additions and 91 deletions.
229 changes: 229 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,235 @@ jobs:
parallel: true
flag-name: Run Tests

# *************************************
# ******** Customization example ******
# *************************************
test_customization_example:
needs: pre-commit
name: test customization example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/customization/ && python manage.py test

# *************************************
# ******** Dataclasses example ********
# *************************************
test_dataclasses_example:
needs: pre-commit
name: test dataclasse example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/dataclasses/ && python manage.py test

# *************************************
# ************ Django example *********
# *************************************
test_django_example:
needs: pre-commit
name: test django example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r examples/django/requirements.in
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/django/ && python manage.py test

# *************************************
# ********** Hypothesis example *******
# *************************************
test_hypothesis_example:
needs: pre-commit
name: test hypothesis example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r examples/hypothesis/requirements.in
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/hypothesis/ && python manage.py test

# *************************************
# *********** Pydantic example ********
# *************************************
test_pydantic_example:
needs: pre-commit
name: test pydantic example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r examples/pydantic/requirements.in
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/pydantic/ && python manage.py test

# *************************************
# *********** SQLAlchemy example ********
# *************************************
test_sqlalchemy_example:
needs: pre-commit
name: test sqlalchemy example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r examples/sqlalchemy/requirements.in
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/sqlalchemy/ && python manage.py test

# *************************************
# ********* TortoiseORM example *******
# *************************************
test_tortoise_example:
needs: pre-commit
name: test tortoise example ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-22.04
python-version:
- "3.12"
steps:
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r examples/tortoise/requirements.in
- name: Install package
run: |
pip install -e .[all]
- name: Run test suite
run: cd examples/tortoise/ && python manage.py test

# *************************************
# ************** Coveralls ************
# *************************************
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/htmlcov/
*.py,cover
.idea/
.vscode/
.pytest_cache/
/coverage.xml
.eggs/
Expand All @@ -30,6 +31,7 @@ fake.py.egg-info
matyan.log*
db.sqlite3
sample_db.sqlite
test_database.db
local_settings.py
/prof/
*.cast
Expand All @@ -40,3 +42,4 @@ examples/pydantic/media/
examples/tortoise/media/
examples/django/media/
examples/dataclasses/media/
examples/sqlalchemy/media/
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@
"filename": "Makefile",
"hashed_secret": "ee783f2421477b5483c23f47eca1f69a1f2bf4fb",
"is_verified": true,
"line_number": 80
"line_number": 86
},
{
"type": "Secret Keyword",
"filename": "Makefile",
"hashed_secret": "1457a35245051927fac6fa556074300f4162ed66",
"is_verified": true,
"line_number": 83
"line_number": 89
}
]
},
"generated_at": "2023-12-07T21:38:21Z"
"generated_at": "2023-12-10T22:39:54Z"
}
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.6.2
-----
2023-12-11

- Add ``SQLAlchemyModelFactory``.

0.6.1
-----
2023-12-10
Expand Down
6 changes: 4 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ For example:
Do not submit pull requests splitting the ``fake.py`` module into small
parts.
- Some tests contain simplified implementation of existing libraries (Django
ORM). If you need to add integration tests for existing functionality,
you can add the relevant code and requirements to the examples.
ORM, TortoiseORM, SQLAlchemy). If you need to add integration tests for
existing functionality, you can add the relevant code and requirements
to the examples, along with tests. Currently, all integration tests
are running in the CI against the latest version of Python.

**General list to go through:**

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update version ONLY here
VERSION := 0.6.1
VERSION := 0.6.2
SHELL := /bin/bash
# Makefile for project
VENV := ~/.virtualenvs/fake.py/bin/activate
Expand Down Expand Up @@ -55,6 +55,9 @@ hypothesis-test:
pydantic-test:
source $(VENV) && cd examples/pydantic/ && python manage.py test

sqlalchemy-test:
source $(VENV) && cd examples/sqlalchemy/ && python manage.py test

tortoise-test:
source $(VENV) && cd examples/tortoise/ && python manage.py test

Expand All @@ -73,6 +76,9 @@ django-shell:
pydantic-shell:
source $(VENV) && cd examples/pydantic/ && python manage.py shell

sqlalchemy-shell:
source $(VENV) && cd examples/sqlalchemy/ && python manage.py shell

tortoise-shell:
source $(VENV) && cd examples/tortoise/ && python manage.py shell

Expand Down Expand Up @@ -124,7 +130,7 @@ test-release:
source $(VENV) && twine upload --repository testpypi dist/*

mypy:
source $(VENV) && mypy .
source $(VENV) && mypy fake.py

%:
@:
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fake.py
.. _Django: https://www.djangoproject.com/
.. _TortoiseORM: https://tortoise.github.io/
.. _Pydantic: https://docs.pydantic.dev/
.. _SQLAlchemy: https://www.sqlalchemy.org/

.. Internal references
Expand Down Expand Up @@ -61,7 +62,7 @@ and `GIF`.

The package also supports file creation on the filesystem and includes
factories (dynamic fixtures) compatible with `Django`_, `TortoiseORM`_,
and `Pydantic`_.
`Pydantic`_ and `SQLAlchemy`_.

Features
========
Expand All @@ -70,7 +71,7 @@ Features
- Support for various file formats (`PDF`, `DOCX`, `TXT`, `PNG`, `SVG`,
`BMP`, `GIF`) and file creation on the filesystem.
- Basic factories for integration with `Django`_, `Pydantic`_,
and `TortoiseORM`_.
`TortoiseORM`_ and `SQLAlchemy`_.

Prerequisites
=============
Expand Down
Loading

0 comments on commit 8c01084

Please sign in to comment.