Skip to content

Commit

Permalink
Merge pull request #298 from fugal-dy/chore-upgrade-django-3
Browse files Browse the repository at this point in the history
upgrade dependencies: django 3.2 and loosen dependency pinning
  • Loading branch information
fugal-dy authored Jan 31, 2022
2 parents 4f86fe5 + 29894c6 commit 96ffd25
Show file tree
Hide file tree
Showing 14 changed files with 528 additions and 478 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
stages: [commit]
name: isort
language: system
entry: isort -y
entry: isort --profile black
types: [python]
- id: flake8
stages: [commit]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.6-slim-buster
FROM python:3.9.7-slim-buster@sha256:76eaa9e5bd357d6983a88ddc9c4545ef4ad64c50f84f081ba952c7ed08e3bdd6
WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends libpq-dev wget build-essential \
Expand Down
8 changes: 0 additions & 8 deletions emeis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from pytest_factoryboy import register
from rest_framework.test import APIClient

from emeis.core.models import ACL, Role, Scope, User


@pytest.fixture(autouse=True)
def reset_config_classes(settings):
Expand Down Expand Up @@ -62,9 +60,3 @@ def client(db):
@pytest.fixture(scope="function", autouse=True)
def _autoclear_cache():
cache.clear()


@pytest.fixture(autouse=True)
def _remove_bootstrap_data(db):
for model in [User, Scope, Role, ACL]:
getattr(model, "objects").all().delete()
58 changes: 58 additions & 0 deletions emeis/core/migrations/0006_rename_field_meta_metainfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 2.2.26 on 2022-01-31 12:19

import django.contrib.postgres.fields.jsonb
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("emeis_core", "0005_manager_on_user_model"),
]

operations = [
migrations.RenameField(model_name="acl", old_name="meta", new_name="metainfo"),
migrations.RenameField(
model_name="permission", old_name="meta", new_name="metainfo"
),
migrations.RenameField(model_name="role", old_name="meta", new_name="metainfo"),
migrations.RenameField(
model_name="scope", old_name="meta", new_name="metainfo"
),
migrations.RenameField(model_name="user", old_name="meta", new_name="metainfo"),
migrations.AlterField(
model_name="acl",
name="metainfo",
field=django.contrib.postgres.fields.jsonb.JSONField(
default=dict, verbose_name="metainfo"
),
),
migrations.AlterField(
model_name="permission",
name="metainfo",
field=django.contrib.postgres.fields.jsonb.JSONField(
default=dict, verbose_name="metainfo"
),
),
migrations.AlterField(
model_name="role",
name="metainfo",
field=django.contrib.postgres.fields.jsonb.JSONField(
default=dict, verbose_name="metainfo"
),
),
migrations.AlterField(
model_name="scope",
name="metainfo",
field=django.contrib.postgres.fields.jsonb.JSONField(
default=dict, verbose_name="metainfo"
),
),
migrations.AlterField(
model_name="user",
name="metainfo",
field=django.contrib.postgres.fields.jsonb.JSONField(
default=dict, verbose_name="metainfo"
),
),
]
2 changes: 1 addition & 1 deletion emeis/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BaseModel(models.Model):
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
modified_at = models.DateTimeField(auto_now=True, db_index=True)
created_by_user = models.ForeignKey("User", null=True, on_delete=models.SET_NULL)
meta = JSONField(_("meta"), default=dict)
metainfo = JSONField(_("metainfo"), default=dict)

class Meta:
abstract = True
Expand Down
4 changes: 2 additions & 2 deletions emeis/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create(self, validated_data):
return super().create(validated_data)

class Meta:
fields = ("created_at", "modified_at", "created_by_user", "meta")
fields = ("created_at", "modified_at", "created_by_user", "metainfo")


class MeSerializer(BaseSerializer):
Expand Down Expand Up @@ -69,7 +69,7 @@ class Meta:
"modified_at",
"created_at",
"created_by_user",
"meta",
"metainfo",
]


Expand Down
861 changes: 430 additions & 431 deletions emeis/core/tests/snapshots/snap_test_api.py

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions emeis/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.test.utils import CaptureQueriesContext
from django.urls import reverse
from rest_framework_json_api.renderers import JSONRenderer
from rest_framework_json_api.utils import get_included_serializers

from ..views import (
ACLViewSet,
Expand Down Expand Up @@ -94,14 +93,13 @@ def fixture(
):
"""Get fixture and many to many relations of given viewset."""
fixture = request.getfixturevalue(viewset.factory_name)()

included = get_included_serializers(viewset.serializer_class)
for name in sorted(included.keys()):
relation_type = getattr(fixture.__class__, name)
# pytest factory boy doesn't have native ManyToMany support
# so needs to be handled manually
if isinstance(relation_type, ManyToManyDescriptor):
request.getfixturevalue("{0}_{1}".format(viewset.instance_name, name))
if hasattr(viewset.serializer_class, "included_serializers"):
for name in sorted(viewset.serializer_class.included_serializers.keys()):
relation_type = getattr(fixture.__class__, name)
# pytest factory boy doesn't have native ManyToMany support
# so needs to be handled manually
if isinstance(relation_type, ManyToManyDescriptor):
request.getfixturevalue("{0}_{1}".format(viewset.instance_name, name))

return fixture

Expand Down
1 change: 0 additions & 1 deletion emeis/core/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def test_search_users(
resp = admin_client.get(
reverse("user-list"), {"filter[search]": users_list[0].first_name}
)

returned_user_ids = [us["id"] for us in resp.json()["data"]]

assert str(users_list[0].pk) in returned_user_ids
Expand Down
2 changes: 1 addition & 1 deletion emeis/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_can_authenticate(db, user):
assert auth == user


def test_scope_hierarchical_name(scope_factory):
def test_scope_hierarchical_name(db, scope_factory):
root = scope_factory()
child = scope_factory(parent=root)
grandchild = scope_factory(parent=child)
Expand Down
1 change: 0 additions & 1 deletion emeis/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def default(default_dev=env.NOTSET, default_prod=env.NOTSET):
INSTALLED_APPS = [
"django.contrib.postgres",
"localized_fields",
"psqlextra",
"django.contrib.contenttypes",
"django.contrib.auth",
"mozilla_django_oidc",
Expand Down
13 changes: 6 additions & 7 deletions requirements-base.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
django==2.2.26
django-cors-headers==3.7.0
django~=3.2
django-cors-headers==3.11.0
django-environ==0.8.1
django-filter==21.1
django-generic-api-permissions==0.2.0
django-localized-fields==6.4
django_mptt==0.11.0
django-postgres-extra==2.0.3
djangorestframework==3.12.4
djangorestframework-jsonapi==4.1.0
django-localized-fields==6.6
django_mptt==0.13.4
djangorestframework==3.13.1
djangorestframework-jsonapi==5.0.0
mozilla-django-oidc==1.2.4
pyexcel==0.6.7
pyexcel-xlsx==0.6.0
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-r requirements-base.txt
black==21.5b1
django_extensions==3.0.8
black==21.12b0
django_extensions==3.1.5
factory-boy==3.2.0
flake8==3.9.2
flake8-blind-except==0.2.0
flake8-bugbear==21.4.3
flake8-bugbear==22.1.11
flake8-debugger==3.2.1
flake8-docstrings==1.6.0
flake8-isort==4.0.0
Expand Down
30 changes: 18 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@
long_description = f.read()


def deps_from_file(filename):
lines = [line.strip().split("#")[0] for line in open(filename).readlines()]
# filter out comment lines
return [line for line in lines if line and not line == "-r requirements-base.txt"]


dependencies = deps_from_file("requirements-base.txt") + deps_from_file(
"requirements-prod.txt"
)


setup(
name=version["__title__"],
version=version["__version__"],
Expand All @@ -41,5 +30,22 @@ def deps_from_file(filename):
"Programming Language :: Python :: 3.7",
],
packages=find_packages(),
install_requires=dependencies,
install_requires=[
"django~=3.2",
"django-cors-headers >=3.7.0, <=3.13.1",
"django-environ==0.8.1",
"django-filter==21.1",
"django-generic-api-permissions==0.2.0",
"django-localized-fields>=6.4,<=6.6",
"django_mptt>=0.11,<=0.13.4",
"django-postgres-extra==2.0.3",
"djangorestframework>=3.12.4,<=3.13.1",
"djangorestframework-jsonapi>=4.3.0,<=5.0.0",
"mozilla-django-oidc==1.2.4",
"pyexcel==0.6.7",
"pyexcel-xlsx==0.6.0",
"requests==2.26.0",
"uwsgi==2.0.19.1",
"openpyxl==3.0.9",
],
)

0 comments on commit 96ffd25

Please sign in to comment.