Skip to content

Commit

Permalink
Merge pull request #171 from barseghyanartur/feature/155-Django-3x-su…
Browse files Browse the repository at this point in the history
…pport

Feature/155 django 3x support
  • Loading branch information
barseghyanartur authored Dec 25, 2019
2 parents d5877e2 + a2214fd commit 6a06b97
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 137 deletions.
2 changes: 2 additions & 0 deletions .matyan.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ exact: more
more on
wip
commit
prefix: more on
continue on
25 changes: 24 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ matrix:
include:
- env: TOX_ENV=py27-django111
python: 2.7

- env: TOX_ENV=py35-django20
python: 3.5

- env: TOX_ENV=py36-django111
python: 3.6
- env: TOX_ENV=py36-django20
Expand All @@ -20,15 +22,36 @@ matrix:
python: 3.6
- env: TOX_ENV=py36-django22
python: 3.6
- env: TOX_ENV=py36-django30
python: 3.6

- env: TOX_ENV=py37-django20
python: 3.7
- env: TOX_ENV=py37-django21
python: 3.7
- env: TOX_ENV=py37-django22
python: 3.7
- env: TOX_ENV=py37-django30
python: 3.7

- env: TOX_ENV=py38-django111
python: 3.8
- env: TOX_ENV=py38-django22
python: 3.8
- env: TOX_ENV=py38-django30
python: 3.8

env:
global:
- ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt

before_install:
- curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.deb && sudo dpkg -i --force-confnew elasticsearch-6.5.4.deb && sudo service elasticsearch restart
# - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.deb && sudo dpkg -i --force-confnew elasticsearch-6.5.4.deb && sudo service elasticsearch restart
- wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- echo "deb $ES_APT_URL stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list
- sudo apt-get remove --purge elasticsearch -y
- sudo apt-get update && sudo apt-get install elasticsearch -y
- sudo -i service elasticsearch restart

install: pip install -r examples/requirements/test.txt

Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ are used for versioning (schema follows below):

0.20.4
------
2019-09-20 (not yet released)
2019-12-25

- Tested against Django 3.0.
- Tested against Python 3.8.
- Tested against Django REST Framework 3.11.
- Minor fixes.
- Test optimisations.

Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Make sure to read `FAQ <https://github.com/barseghyanartur/django-elasticsearch-

Prerequisites
=============
- Django 1.11, 2.0, 2.1 and 2.2.
- Python 2.7, 3.5, 3.6, 3.7.
- Django 1.11, 2.0, 2.1, 2.2 and 3.0.
- Python 2.7, 3.5, 3.6, 3.7, 3.8.
- Elasticsearch 6.x, 7.x. For older versions use
``django-elasticsearch-dsl-drf`` version 0.18.

Expand Down Expand Up @@ -162,7 +162,7 @@ To test against specific environment, type:

.. code-block:: sh
tox -e py37-django21
tox -e py38-django30
To test just your working environment type:

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
build:
context: .
dockerfile: ./docker/elasticsearch/Dockerfile
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1
# image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
# image: docker.elastic.co/elasticsearch/elasticsearch:5.5.3
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6.7-slim-jessie
FROM docker.io/python:3.6.7-slim-jessie
ENV PYTHONUNBUFFERED 1

RUN apt-get update
Expand Down
2 changes: 1 addition & 1 deletion docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM docker.io/node:8-alpine3.9

RUN apt-get update
RUN apt-get install -y mc
Expand Down
5 changes: 4 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ are used for versioning (schema follows below):

0.20.4
------
2019-09-20 (not yet released)
2019-12-25

- Tested against Django 3.0.
- Tested against Python 3.8.
- Tested against Django REST Framework 3.11.
- Minor fixes.
- Test optimisations.

Expand Down
8 changes: 5 additions & 3 deletions docs/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Current compatibility matrix is:
+--------------+---------------+
| This package | Elasticsearch |
+--------------+---------------+
| 0.20 | 6.x, 7.x |
| 0.20.x | 6.x, 7.x |
+--------------+---------------+
| 0.19 | 6.x |
| 0.19.x | 6.x |
+--------------+---------------+
| 0.18 | 2.x, 5.x, 6.x |
| 0.18.x | 2.x, 5.x, 6.x |
+--------------+---------------+

**django-elasticsearch-dsl**
Expand Down Expand Up @@ -64,6 +64,8 @@ Current compatibility matrix is:
+--------+-----------------------+
| 2.2 | 3.9.3 |
+--------+-----------------------+
| 3.0 | 3.11.0 |
+--------+-----------------------+

The version 0.17.7 has been tested with the following versions of
Django and Django REST Framework:
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Make sure to read `FAQ <https://github.com/barseghyanartur/django-elasticsearch-

Prerequisites
=============
- Django 1.11, 2.0, 2.1 and 2.2.
- Python 2.7, 3.5, 3.6, 3.7.
- Django 1.11, 2.0, 2.1, 2.2 and 3.0.
- Python 2.7, 3.5, 3.6, 3.7, 3.8.
- Elasticsearch 6.x, 7.x. For older versions use
``django-elasticsearch-dsl-drf`` version 0.18.

Expand Down Expand Up @@ -162,7 +162,7 @@ To test against specific environment, type:

.. code-block:: sh
tox -e py37-django21
tox -e py38-django30
To test just your working environment type:

Expand Down
2 changes: 1 addition & 1 deletion examples/requirements/django_1_11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ django-cors-headers==2.4.0
django-debug-toolbar==1.5
django-debug-toolbar-force==0.1.3
django-elasticsearch-debug-toolbar==1.2.0
django-ormex==0.2
django-ormex>=0.2.1
djangorestframework==3.9.3
sqlparse==0.2.2
2 changes: 1 addition & 1 deletion examples/requirements/django_2_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ django-cors-headers==2.4.0
django-debug-toolbar>=1.6
django-debug-toolbar-force>=0.1.3
django-elasticsearch-debug-toolbar>=1.2.0
django-ormex>=0.2
django-ormex>=0.2.1
djangorestframework==3.9.3
sqlparse>=0.2.2
2 changes: 1 addition & 1 deletion examples/requirements/django_2_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ django-cors-headers==2.4.0
django-debug-toolbar>=1.9.1
django-debug-toolbar-force>=0.1.3
django-elasticsearch-debug-toolbar>=1.2.0
django-ormex>=0.2
django-ormex>=0.2.1
djangorestframework==3.9.3
sqlparse>=0.2.2
2 changes: 1 addition & 1 deletion examples/requirements/django_2_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ django-cors-headers==2.5.2
django-debug-toolbar==1.9.1
django-debug-toolbar-force>=0.1.3
django-elasticsearch-debug-toolbar>=1.2.0
django-ormex>=0.2
django-ormex>=0.2.1
djangorestframework==3.9.3
sqlparse>=0.2.2
10 changes: 10 additions & 0 deletions examples/requirements/django_3_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-r common.txt
-r test.txt

Django>=3.0,<3.1
django-cors-headers==3.2.0
django-debug-toolbar>=2.1
django-debug-toolbar-force>=0.1.7
django-elasticsearch-debug-toolbar>=2.0
django-ormex>=0.2.1
djangorestframework>=3.11.0,<3.12
2 changes: 1 addition & 1 deletion examples/requirements/elastic.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-r elastic_6x.txt
-r elastic_7x.txt
3 changes: 2 additions & 1 deletion examples/requirements/elastic_7x.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
elasticsearch==7.0.2
elasticsearch-dsl==7.0.0
django-elasticsearch-dsl==7.0.0
#django-elasticsearch-dsl==7.1.0
https://github.com/sabricot/django-elasticsearch-dsl/archive/3f6cf53d9a2a5da5c7fca7e444b772d3c72f2594.zip
2 changes: 1 addition & 1 deletion examples/simple/books/models/order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from six import python_2_unicode_compatible

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/books/models/tag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

__all__ = ('Tag',)

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/books/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.views.generic import ListView, TemplateView
from django.db.models import Avg, Count, DecimalField, F, Max, Min, Sum
from django.views.generic import ListView, TemplateView

from ormex.aggregations import GroupConcat

Expand Down
4 changes: 2 additions & 2 deletions examples/simple/factories/auth_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class AbstractUserFactory(DjangoModelFactory):

password = PostGenerationMethodCall('set_password', TEST_PASSWORD)
username = Sequence(lambda n: 'user%d' % n)
first_name = Faker('first_name')
last_name = Faker('last_name')
first_name = Faker('first_name_django')
last_name = Faker('last_name_django')
email = Faker('email')

is_active = False
Expand Down
58 changes: 38 additions & 20 deletions examples/simple/factories/factory_faker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

from __future__ import unicode_literals

from django.core.files.base import File

from factory import Faker as OriginalFaker

from faker import Faker as FakerFaker
from faker.providers import BaseProvider

from .files import get_temporary_file

__all__ = (
'DjangoFileProvider',
'DjangoUserProvider',
'EnGbFaker',
'Faker',
'NlNlFaker',
Expand All @@ -34,36 +30,58 @@ class EnGbFaker(OriginalFaker):
_DEFAULT_LOCALE = 'en_GB'


class DjangoFileProvider(BaseProvider):
"""Django file provider."""
class DjangoUserProvider(BaseProvider):
"""Django user provider."""

@classmethod
def first_name_django(cls, max_length=30):
"""Generates first name compatible with django.
Example:
>>> from factory import DjangoModelFactory
>>>
>>> class UserFactory(DjangoModelFactory):
>>> "User factory."
>>>
>>> # ...
>>>
>>> image_file = Faker('first_name_django')
>>>
>>> # ...
:param max_length: Max length.
:type max_length: int
:return: str.
"""

fake = FakerFaker()
return fake.first_name()[:max_length]

@classmethod
def django_file(cls, extension=None):
"""Generates a random file.
def last_name_django(cls, max_length=30):
"""Generates last name compatible with django.
Example:
>>> from factory import DjangoModelFactory
>>>
>>> class ProductFactory(DjangoModelFactory):
>>> "Product factory."
>>> class UserFactory(DjangoModelFactory):
>>> "User factory."
>>>
>>> # ...
>>>
>>> image_file = Faker('django_file', extension='image')
>>> video_file = Faker('django_file', extension='video')
>>> text_file = Faker('django_file', extension='text')
>>> image_file = Faker('last_name_django')
>>>
>>> # ...
:param extension: File extension.
:type extension: str
:return: File object.
:param max_length: Max length.
:type max_length: int
:return: str.
"""

fake = FakerFaker()
django_file = get_temporary_file(fake.file_name(extension=extension))
return File(django_file)
return fake.last_name()[:max_length]


Faker.add_provider(DjangoFileProvider)
Faker.add_provider(DjangoUserProvider)
Loading

0 comments on commit 6a06b97

Please sign in to comment.