Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

List of the most important changes for each release.

## 0.8.8
- Adds support for Python 3.14

## 0.8.7
- Adds flexibility for customizing deserialization behavior using sync filter to `SyncableModel` methods

Expand Down
2 changes: 1 addition & 1 deletion morango/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.7"
__version__ = "0.8.8"
10 changes: 4 additions & 6 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# These are for testing
factory-boy==2.7.0
fake-factory==0.5.7
mock==2.0.0
pytest==6.2.5
factory-boy>=3.0,<4
mock>=4.0,<6
pytest>=6.2.5,<8
pytest-django==4.5.2
more-itertools<=8.10.0
typing
more-itertools<=10.0.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
],
python_requires=">=3.6, <3.14",
python_requires=">=3.6, <3.15",
)
32 changes: 21 additions & 11 deletions tests/testapp/tests/compat.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
try:
# In the Python EOL GH workflows, we have to install backported version
# as the Docker container images we use does not have the test module installed.
from backports.test.support import EnvironmentVarGuard # noqa F401
except ImportError:
try:
# For python >3.8 and <3.10
from test.support import EnvironmentVarGuard # noqa F401
except ImportError:
# In Python 3.10, this has been moved to test.support.os_helper
from test.support.os_helper import EnvironmentVarGuard # noqa F401
import os
from unittest.mock import patch as _patch


class EnvironmentVarGuard:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No don't do this.

"""
Vendored replacement for the removed test.support EnvironmentVarGuard.
Uses unittest.mock.patch.dict(os.environ) under the hood.
Supports the context-manager-with-dict-assignment pattern:
with EnvironmentVarGuard() as env: env[k] = v
"""

def __init__(self):
self._patcher = _patch.dict(os.environ)

def __enter__(self):
self._patcher.start()
return os.environ

def __exit__(self, *args):
self._patcher.stop()
8 changes: 4 additions & 4 deletions tests/testapp/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
from morango.sync.syncsession import TransferClient


class FacilityFactory(factory.DjangoModelFactory):
class FacilityFactory(factory.django.DjangoModelFactory):
class Meta:
model = Facility

name = factory.Sequence(lambda n: "Fac %d" % n)


class AbstractStoreFactory(factory.DjangoModelFactory):
class AbstractStoreFactory(factory.django.DjangoModelFactory):
class Meta:
model = AbstractStore

Expand All @@ -61,12 +61,12 @@ class Meta:
model = Store


class RecordMaxCounterBufferFactory(factory.DjangoModelFactory):
class RecordMaxCounterBufferFactory(factory.django.DjangoModelFactory):
class Meta:
model = RecordMaxCounterBuffer


class RecordMaxCounterFactory(factory.DjangoModelFactory):
class RecordMaxCounterFactory(factory.django.DjangoModelFactory):
class Meta:
model = RecordMaxCounter

Expand Down
10 changes: 1 addition & 9 deletions tests/testapp/tests/integration/test_signals.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import factory
from django.test import TestCase
from facility_profile.models import Facility

from ..helpers import FacilityFactory as FacilityModelFactory
from morango.models.core import DeletedModels
from morango.models.core import InstanceIDModel
from morango.sync.controller import MorangoProfileController


class FacilityModelFactory(factory.DjangoModelFactory):

class Meta:
model = Facility

name = factory.Sequence(lambda n: "Fac %d" % n)


class PostDeleteSignalsTestCase(TestCase):

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/testapp/tests/models/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from morango.sync.controller import MorangoProfileController


class DatabaseMaxCounterFactory(factory.DjangoModelFactory):
class DatabaseMaxCounterFactory(factory.django.DjangoModelFactory):
class Meta:
model = DatabaseMaxCounter

Expand Down
10 changes: 2 additions & 8 deletions tests/testapp/tests/sync/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from facility_profile.models import SummaryLog

from ..compat import EnvironmentVarGuard
from ..helpers import FacilityFactory as FacilityModelFactory
from ..helpers import serialized_facility_factory
from ..helpers import TestSessionContext
from morango.constants import transfer_stages
Expand All @@ -26,14 +27,7 @@
from morango.sync.controller import SessionController


class FacilityModelFactory(factory.DjangoModelFactory):
class Meta:
model = Facility

name = factory.Sequence(lambda n: "Fac %d" % n)


class StoreModelFacilityFactory(factory.DjangoModelFactory):
class StoreModelFacilityFactory(factory.django.DjangoModelFactory):
class Meta:
model = Store

Expand Down
8 changes: 0 additions & 8 deletions tests/testapp/tests/sync/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import uuid
from time import sleep

import factory
import mock
import pytest
from django.conf import settings
Expand Down Expand Up @@ -53,13 +52,6 @@
DBBackend = load_backend(connection)


class FacilityModelFactory(factory.DjangoModelFactory):
class Meta:
model = Facility

name = factory.Sequence(lambda n: "Fac %d" % n)


def assertRecordsBuffered(records):
buffer_ids = Buffer.objects.values_list("model_uuid", flat=True)
rmcb_ids = RecordMaxCounterBuffer.objects.values_list("model_uuid", flat=True)
Expand Down
37 changes: 37 additions & 0 deletions tests/testapp/tests/test_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import uuid

from django.test import SimpleTestCase

from .compat import EnvironmentVarGuard


class EnvironmentVarGuardTestCase(SimpleTestCase):
"""Tests for the vendored EnvironmentVarGuard."""

def test_sets_env_var_inside_context(self):
key = "MORANGO_TEST_" + uuid.uuid4().hex[:8]
with EnvironmentVarGuard() as env:
env[key] = "test_value"
self.assertEqual(os.environ[key], "test_value")

def test_reverts_env_var_on_exit(self):
key = "MORANGO_TEST_" + uuid.uuid4().hex[:8]
with EnvironmentVarGuard() as env:
env[key] = "test_value"
self.assertNotIn(key, os.environ)

def test_reverts_modified_env_var_on_exit(self):
key = "MORANGO_TEST_" + uuid.uuid4().hex[:8]
os.environ[key] = "original"
try:
with EnvironmentVarGuard() as env:
env[key] = "modified"
self.assertEqual(os.environ[key], "modified")
self.assertEqual(os.environ[key], "original")
finally:
os.environ.pop(key, None)

def test_returns_os_environ(self):
with EnvironmentVarGuard() as env:
self.assertIs(env, os.environ)
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{3.6,3.7,3.8,3.9,3.10,3.11,3.12,3.13}-cryptography{40.0.2}
py{3.6,3.7,3.8,3.9,3.10,3.11,3.12,3.13,3.14}-cryptography{40.0.2}
postgres
windows

Expand All @@ -21,15 +21,13 @@ basepython =
py3.11: python3.11
py3.12: python3.12
py3.13: python3.13
py3.14: python3.14
postgres: python3.9
windows: python3.8

deps =
-r{toxinidir}/requirements/test.txt
cryptography40.0.2: cryptography==40.0.2
py3.6: backports.test.support==0.1.1
py3.7: backports.test.support==0.1.1
py3.8: backports.test.support==0.1.1
commands =
sh -c 'tests/testapp/manage.py makemigrations --check'
python -O -m pytest {posargs: --color=no}
Expand Down
Loading