From 0aaf4db6c56b9bcce7d33cbe191ba7e4d1c6d43b Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Fri, 6 Oct 2023 19:05:56 -0600 Subject: [PATCH 01/13] Fix to_dict for IntEnum --- mongoengine_plus/models/helpers.py | 2 +- mongoengine_plus/version.py | 2 +- tests/models/test_helpers.py | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mongoengine_plus/models/helpers.py b/mongoengine_plus/models/helpers.py index 4925eab..416a1ab 100644 --- a/mongoengine_plus/models/helpers.py +++ b/mongoengine_plus/models/helpers.py @@ -70,7 +70,7 @@ def mongo_to_dict(obj, exclude_fields: list = None) -> dict: elif isinstance(obj._fields[field_name], DictField): return_data[field_name] = data elif isinstance(obj._fields[field_name], EnumField): - return_data[field_name] = data.value if data else None + return_data[field_name] = data.value if data is not None else None elif isinstance(obj._fields[field_name], LazyReferenceField): return_data[f'{field_name}_uri'] = ( f'/{data._DBRef__collection}/{data.id}' if data else None diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index b794fd4..e9856f7 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.0' +__version__ = '0.1.1.dev0' diff --git a/tests/models/test_helpers.py b/tests/models/test_helpers.py index b6a7b89..3912ee1 100644 --- a/tests/models/test_helpers.py +++ b/tests/models/test_helpers.py @@ -30,6 +30,12 @@ class EnumType(Enum): member = 'name' +class IntEnum(int, Enum): + exito = 0 + invalid = 1 + + + class Embedded(EmbeddedDocument): meta = {'allow_inheritance': True} name = StringField() @@ -59,6 +65,7 @@ class TestModel(Document): lazzy_field = LazyReferenceField(Reference) lazzy_list_field = ListField(LazyReferenceField(Reference)) generic_lazzy_field = GenericLazyReferenceField() + code = EnumField(IntEnum) __test__ = False @@ -71,6 +78,7 @@ def test_mongo_to_dict(): lazzy_list_field=[reference], embedded_field=Embedded(name='Peter'), heritage_field=HeritageEmbedded(name='some', lastname='other'), + code=IntEnum.exito, ) model.save() model_dict = mongo_to_dict(model, exclude_fields=['str_field']) @@ -95,3 +103,4 @@ def test_mongo_to_dict(): 'name': 'some', 'lastname': 'other', } + assert model_dict['code'] == 0 From c421b3ddd32508ad04abab866d65d3a310bda236 Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Fri, 6 Oct 2023 19:14:08 -0600 Subject: [PATCH 02/13] lint --- tests/models/test_helpers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/models/test_helpers.py b/tests/models/test_helpers.py index 3912ee1..141bb04 100644 --- a/tests/models/test_helpers.py +++ b/tests/models/test_helpers.py @@ -35,7 +35,6 @@ class IntEnum(int, Enum): invalid = 1 - class Embedded(EmbeddedDocument): meta = {'allow_inheritance': True} name = StringField() From 84f04b4b961676495c02fbddb3c2c3704b78cd29 Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Fri, 6 Oct 2023 19:15:37 -0600 Subject: [PATCH 03/13] fix GH action --- .github/workflows/release.yml | 7 ++++--- mongoengine_plus/version.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 68d56f1..649ca9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,8 @@ name: release -on: push +on: + release: + types: [published] jobs: publish-pypi: @@ -8,7 +10,7 @@ jobs: steps: - uses: actions/checkout@master - name: Set up Python 3.8 - uses: actions/setup-python@v2.2.2 + uses: actions/setup-python@v4.7.0 with: python-version: 3.8 - name: Install dependencies @@ -16,7 +18,6 @@ jobs: - name: Generating distribution archives run: python setup.py sdist bdist_wheel - name: Publish distribution 📦 to PyPI - if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master with: user: ${{ secrets.PYPI_USERNAME }} diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index e9856f7..f18b593 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev0' +__version__ = '0.1.1.dev1' From b8544e41110040ed85600ad72cb750974b1f7229 Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Fri, 6 Oct 2023 19:19:54 -0600 Subject: [PATCH 04/13] fix GH action --- .github/workflows/release.yml | 6 +++--- mongoengine_plus/version.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 649ca9a..9d19515 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@master - name: Set up Python 3.8 - uses: actions/setup-python@v4.7.0 + uses: actions/setup-python@v2.2.2 with: python-version: 3.8 - name: Install dependencies @@ -20,5 +20,5 @@ jobs: - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@master with: - user: ${{ secrets.PYPI_USERNAME }} - password: ${{ secrets.PYPI_PASSWORD }} + user: __token__ + password: ${{ secrets.pypi_password }} \ No newline at end of file diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index f18b593..27a28a2 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev1' +__version__ = '0.1.1.dev2' From 211762b873594130cd8d8e875690326ff9cadcda Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 11:20:42 -0600 Subject: [PATCH 05/13] vars --- .github/workflows/release.yml | 4 ++-- mongoengine_plus/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d19515..04bfa40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,5 +20,5 @@ jobs: - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@master with: - user: __token__ - password: ${{ secrets.pypi_password }} \ No newline at end of file + user: ${{ secrets.PYPI_USERNAME }} + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 27a28a2..53a3c7c 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev2' +__version__ = '0.1.1.dev3' From d1ad692343be2a7f38399cce61e12f8648b76c67 Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 11:33:50 -0600 Subject: [PATCH 06/13] test action --- .github/workflows/release.yml | 24 +++++++++--------------- mongoengine_plus/version.py | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04bfa40..540e62f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,20 +5,14 @@ on: types: [published] jobs: - publish-pypi: + pypi-publish: + name: Upload release to PyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/ + permissions: + id-token: write steps: - - uses: actions/checkout@master - - name: Set up Python 3.8 - uses: actions/setup-python@v2.2.2 - with: - python-version: 3.8 - - name: Install dependencies - run: pip install -qU setuptools wheel twine - - name: Generating distribution archives - run: python setup.py sdist bdist_wheel - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: ${{ secrets.PYPI_USERNAME }} - password: ${{ secrets.PYPI_PASSWORD }} + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 53a3c7c..87b8fdf 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev3' +__version__ = '0.1.1.dev4' From e1262fffecfb93275bccd42544de4f50b18b3f7e Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 11:47:59 -0600 Subject: [PATCH 07/13] other test --- .github/workflows/release.yml | 21 ++++++++++++--------- mongoengine_plus/version.py | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 540e62f..fbb4f47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,14 +5,17 @@ on: types: [published] jobs: - pypi-publish: - name: Upload release to PyPI + publish-pypi: runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/ - permissions: - id-token: write steps: - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + - uses: actions/checkout@master + - name: Set up Python 3.8 + uses: actions/setup-python@v2.2.2 + with: + python-version: 3.8 + - name: Install dependencies + run: pip install -qU setuptools wheel twine + - name: Generating distribution archives + run: python setup.py sdist bdist_wheel + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 87b8fdf..3910446 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev4' +__version__ = '0.1.1.dev5' From 522143e2c48a03d4287f7e100c542d78ae701bbd Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 11:51:47 -0600 Subject: [PATCH 08/13] other test --- .github/workflows/release.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fbb4f47..b947087 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,17 +5,14 @@ on: types: [published] jobs: - publish-pypi: + pypi-publish: + name: Upload release to PyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/mongoengine_plus + permissions: + id-token: write steps: - - uses: actions/checkout@master - - name: Set up Python 3.8 - uses: actions/setup-python@v2.2.2 - with: - python-version: 3.8 - - name: Install dependencies - run: pip install -qU setuptools wheel twine - - name: Generating distribution archives - run: python setup.py sdist bdist_wheel - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From 5a7f327475cc30d0f042ed44e6ac9d632525914e Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 11:55:11 -0600 Subject: [PATCH 09/13] more test --- .github/workflows/release.yml | 5 ++++- mongoengine_plus/version.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b947087..0cab245 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,4 +15,7 @@ jobs: id-token: write steps: - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 3910446..14d9494 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev5' +__version__ = '0.1.1.dev6' From 9fe7b4ea366be1efc53ec0ef7c884cd1a23c295a Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 12:00:32 -0600 Subject: [PATCH 10/13] build --- .github/workflows/release.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cab245..a01fa91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,8 +14,17 @@ jobs: permissions: id-token: write steps: - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file + - uses: actions/checkout@master + - name: Set up Python 3.8 + uses: actions/setup-python@v2.2.2 + with: + python-version: 3.8 + - name: Install dependencies + run: pip install -qU setuptools wheel twine + - name: Generating distribution archives + run: python setup.py sdist bdist_wheel + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file From 6ba8b75e448fbb9f65286af82df4c83d60b9f40e Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 12:00:55 -0600 Subject: [PATCH 11/13] version --- mongoengine_plus/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 14d9494..26ac65c 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev6' +__version__ = '0.1.1.dev7' From 9ecebf7292b95496ac32a2e63cf7ebf3a989998f Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 12:07:14 -0600 Subject: [PATCH 12/13] other test --- .github/workflows/release.yml | 3 +-- mongoengine_plus/version.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a01fa91..49d36f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,5 +26,4 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file + user: __token__ \ No newline at end of file diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 26ac65c..1cabc45 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev7' +__version__ = '0.1.1.dev8' From 834be8c2c35c594be644efe613cc46f4f0334fbe Mon Sep 17 00:00:00 2001 From: rogeliolopez Date: Mon, 9 Oct 2023 12:19:59 -0600 Subject: [PATCH 13/13] final version --- mongoengine_plus/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 1cabc45..df9144c 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.1.1.dev8' +__version__ = '0.1.1'