Skip to content

Commit

Permalink
Merge pull request #12 from druids/UpgradePynamoDB
Browse files Browse the repository at this point in the history
Upgraded pynamodb
  • Loading branch information
matllubos committed Jan 6, 2023
2 parents 270ac70 + 827da38 commit 1e4ab05
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11"]

services:
postgres:
Expand Down
2 changes: 0 additions & 2 deletions reversion/backends/dynamodb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def raw_field_dict(self):
"""
A dictionary mapping field names to field values in this version
of the model.
This method will follow parent links, if present.
"""
field_dict = self._local_raw_field_dict
Expand All @@ -191,7 +190,6 @@ def field_dict(self):
"""
A dictionary mapping field names to field values in this version
of the model.
This method will follow parent links, if present.
"""
field_dict = self._local_field_dict
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def read(filepath):
"django>=2.2<4",
"import_string>=0.1.0",
],
extras_require={
'dynamodb': ['pydjamodb>=0.0.9', 'pynamodb<=5.1.0', 'boto3<=1.24.96'],
},
python_requires='>=3.6',
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
10 changes: 6 additions & 4 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
django==3.1
pydjamodb==0.0.4
https://github.com/druids/pynamodb/tarball/AddTagsSupport
boto3==1.24.96
django==3.2
django-germanium==2.3.6
pydjamodb==0.0.9
pynamodb==5.1.0
flake8
coverage
sphinx
psycopg2-binary
mysqlclient
mysqlclient==2.1.1
-e .
4 changes: 3 additions & 1 deletion tests/test_app/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
from django.test.utils import override_settings
from django.utils import timezone

from germanium.test_cases.default import GermaniumTestCaseMixin

import reversion
from reversion.backends.sql.models import Revision, Version
from test_app.models import TestModel, TestModelParent


# Test helpers.

class TestBaseMixin(object):
class TestBaseMixin(GermaniumTestCaseMixin):

databases = list(settings.DATABASES.keys())

Expand Down
4 changes: 1 addition & 3 deletions tests/test_app/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from test_app.models import TestModel, TestModelRelated, TestModelThrough, TestModelParent, TestMeta
from test_app.tests.base import TestBase, TestBaseTransaction, TestModelMixin, UserMixin

from pydjamodb.tests import DynamoDBTestMixin


class SaveTest(TestModelMixin, TestBase):

Expand Down Expand Up @@ -137,7 +135,7 @@ def testPostRevisionCommitSignal(self):
self.assertEqual(_callback.call_count, 1)


class CreateRevisionAtomicTest(DynamoDBTestMixin, TestModelMixin, TestBaseTransaction):
class CreateRevisionAtomicTest(TestModelMixin, TestBaseTransaction):

def testCreateRevisionAtomic(self):
self.assertFalse(get_connection().in_atomic_block)
Expand Down
20 changes: 9 additions & 11 deletions tests/test_app/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from test_app.tests.base import TestBase, TestModelMixin, TestModelParentMixin, TestModelParentWithoutFollowMixin
import json

from pydjamodb.tests import DynamoDBTestMixin


class GetForModelTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetForModelTest(TestModelMixin, TestBase):

def testGetForModel(self):
with reversion.create_revision():
Expand Down Expand Up @@ -41,7 +40,7 @@ def testGetForModelDbMySql(self):
self.assertEqual(Version.objects.using("mysql").get_for_model(obj.__class__).count(), 1)


class GetForObjectTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetForObjectTest(TestModelMixin, TestBase):

def testGetForObject(self):
with reversion.create_revision():
Expand Down Expand Up @@ -81,7 +80,7 @@ def testGetForObjectEmptyDynamoDB(self):
self.assertEqual(DynamoDBVersion.objects.get_for_object(obj).count(), 0)


class GetForObjectDbTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetForObjectDbTest(TestModelMixin, TestBase):
databases = {"default", "mysql", "postgres"}

def testGetForObjectDb(self):
Expand All @@ -97,7 +96,7 @@ def testGetForObjectDbMySql(self):
self.assertEqual(Version.objects.using("mysql").get_for_object(obj).count(), 1)


class GetForObjectModelDbTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetForObjectModelDbTest(TestModelMixin, TestBase):
databases = {"default", "postgres"}

def testGetForObjectModelDb(self):
Expand Down Expand Up @@ -132,7 +131,7 @@ def testGetForObjectUniqueMiss(self):
self.assertEqual(len(list(Version.objects.get_for_object(obj).get_unique())), 2)


class GetForObjectReferenceTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetForObjectReferenceTest(TestModelMixin, TestBase):

def testGetForObjectReference(self):
with reversion.create_revision():
Expand Down Expand Up @@ -198,7 +197,7 @@ def testGetForObjectReferenceModelDbMySql(self):
self.assertEqual(Version.objects.get_for_object_reference(TestModel, obj.pk, model_db="mysql").count(), 1)


class GetDeletedTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class GetDeletedTest(TestModelMixin, TestBase):
databases = {"default", "mysql", "postgres"}

def testGetDeleted(self):
Expand Down Expand Up @@ -250,7 +249,6 @@ def testGetDeletedDynamoDB(self):
obj.save()
with reversion.create_revision():
obj.delete()

self.assertEqual(DynamoDBVersion.objects.get_deleted(TestModel).count(), 1)

@override_settings(REVERSION_BACKEND='dynamodb')
Expand Down Expand Up @@ -289,7 +287,7 @@ def testGetDeletedModelDb(self):
self.assertEqual(Version.objects.get_deleted(TestModel, model_db="postgres").count(), 1)


class FieldDictTest(DynamoDBTestMixin, TestModelMixin, TestBase):
class FieldDictTest(TestModelMixin, TestBase):

def testFieldDict(self):
with reversion.create_revision():
Expand Down Expand Up @@ -367,7 +365,7 @@ def testFieldDictFieldExclude(self):
})


class FieldDictInheritanceTest(DynamoDBTestMixin, TestModelParentMixin, TestBase):
class FieldDictInheritanceTest(TestModelParentMixin, TestBase):

def testRawFieldDictnheritance(self):
with reversion.create_revision():
Expand Down Expand Up @@ -441,7 +439,7 @@ def testFieldDictInheritanceUpdateDynamoDB(self):
})


class FieldDictInheritanceWithoutFollowTest(DynamoDBTestMixin, TestModelParentWithoutFollowMixin, TestBase):
class FieldDictInheritanceWithoutFollowTest(TestModelParentWithoutFollowMixin, TestBase):

def testFieldDictInheritanceWithoutParentFollow(self):
with reversion.create_revision():
Expand Down
2 changes: 2 additions & 0 deletions tests/test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,5 @@
}

TEST_RUNNER = 'pydjamodb.test_runner.DynamoDBTestDiscoverRunner'

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

0 comments on commit 1e4ab05

Please sign in to comment.