mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-06-26 21:33:19 +03:00
Convert to use CircleCI and run tests against Django 2.1/Python 3.7
This commit is contained in:
parent
acf8867974
commit
b2f50ec82b
92
.circleci/config.yml
Normal file
92
.circleci/config.yml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
test-python35:
|
||||||
|
docker:
|
||||||
|
- image: python:3.5-alpine
|
||||||
|
- image: postgres:11.0
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: 'localizedfields'
|
||||||
|
POSTGRES_USER: 'localizedfields'
|
||||||
|
POSTGRES_PASSWORD: 'localizedfields'
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install packages
|
||||||
|
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
|
||||||
|
- run:
|
||||||
|
name: Install Python packages
|
||||||
|
command: pip install -r requirements/test.txt
|
||||||
|
- run:
|
||||||
|
name: Run tests
|
||||||
|
command: tox -e 'py35-dj{111,20,21}'
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
|
||||||
|
|
||||||
|
test-python36:
|
||||||
|
docker:
|
||||||
|
- image: python:3.6-alpine
|
||||||
|
- image: postgres:11.0
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: 'localizedfields'
|
||||||
|
POSTGRES_USER: 'localizedfields'
|
||||||
|
POSTGRES_PASSWORD: 'localizedfields'
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install packages
|
||||||
|
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
|
||||||
|
- run:
|
||||||
|
name: Install Python packages
|
||||||
|
command: pip install -r requirements/test.txt
|
||||||
|
- run:
|
||||||
|
name: Run tests
|
||||||
|
command: tox -e 'py36-dj{111,20,21}'
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
|
||||||
|
|
||||||
|
test-python37:
|
||||||
|
docker:
|
||||||
|
- image: python:3.7-alpine
|
||||||
|
- image: postgres:11.0
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: 'localizedfields'
|
||||||
|
POSTGRES_USER: 'localizedfields'
|
||||||
|
POSTGRES_PASSWORD: 'localizedfields'
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install packages
|
||||||
|
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
|
||||||
|
- run:
|
||||||
|
name: Install Python packages
|
||||||
|
command: pip install -r requirements/test.txt
|
||||||
|
- run:
|
||||||
|
name: Run tests
|
||||||
|
command: tox -e 'py37-dj{111,20,21}'
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
docker:
|
||||||
|
- image: python:3.5-alpine
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install packages
|
||||||
|
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
|
||||||
|
- run:
|
||||||
|
name: Install Python packages
|
||||||
|
command: pip install -r requirements/test.txt
|
||||||
|
- run:
|
||||||
|
name: Lint code
|
||||||
|
command: python setup.py lint
|
||||||
|
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build:
|
||||||
|
jobs:
|
||||||
|
- test-python35
|
||||||
|
- test-python36
|
||||||
|
- test-python37
|
||||||
|
- lint
|
@ -1,5 +1,3 @@
|
|||||||
[run]
|
[run]
|
||||||
include = localized_fields/*
|
include = localized_fields/*
|
||||||
omit = *migrations*, *tests*
|
omit = *migrations*, *tests*
|
||||||
plugins =
|
|
||||||
django_coverage_plugin
|
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
# Ignore virtual environments
|
# Ignore virtual environments
|
||||||
env/
|
env/
|
||||||
|
.env/
|
||||||
|
|
||||||
# Ignore Python byte code cache
|
# Ignore Python byte code cache
|
||||||
*.pyc
|
*.pyc
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
checks:
|
|
||||||
python:
|
|
||||||
code_rating: true
|
|
||||||
duplicate_code: true
|
|
||||||
tools:
|
|
||||||
pylint:
|
|
||||||
python_version: '3'
|
|
||||||
config_file: .pylintrc
|
|
||||||
filter:
|
|
||||||
excluded_paths:
|
|
||||||
- '*/tests/*'
|
|
||||||
- '*/migrations/*'
|
|
||||||
build:
|
|
||||||
environment:
|
|
||||||
python: '3.5.0'
|
|
||||||
variables:
|
|
||||||
DJANGO_SETTINGS_MODULES: settings
|
|
||||||
DATABASE_URL: postgres://scrutinizer:scrutinizer@localhost:5434/localized_fields
|
|
||||||
postgresql: true
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
override:
|
|
||||||
- 'pip install -r requirements/test.txt'
|
|
||||||
tests:
|
|
||||||
override:
|
|
||||||
-
|
|
||||||
command: pep8 ./localized_fields/
|
|
||||||
-
|
|
||||||
command: flake8 ./localized_fields/
|
|
||||||
-
|
|
||||||
command: tox
|
|
||||||
coverage:
|
|
||||||
file: '.coverage'
|
|
||||||
format: 'py-cc'
|
|
@ -2,15 +2,13 @@
|
|||||||
|
|
||||||
django-autoslug==1.9.3
|
django-autoslug==1.9.3
|
||||||
django-bleach==0.3.0
|
django-bleach==0.3.0
|
||||||
django-coverage-plugin==1.3.1
|
|
||||||
psycopg2==2.7.3.2
|
psycopg2==2.7.3.2
|
||||||
pylint==1.8.1
|
pylint==1.8.1
|
||||||
pylint-common==0.2.5
|
pylint-common==0.2.5
|
||||||
pylint-django==0.8.0
|
pylint-django==0.8.0
|
||||||
pylint-plugin-utils==0.2.6
|
pylint-plugin-utils==0.2.6
|
||||||
coverage==4.4.2
|
coverage==4.4.2
|
||||||
django-coverage-plugin==1.3.1
|
flake8==3.6.0
|
||||||
flake8==3.5.0
|
|
||||||
pep8==1.7.1
|
pep8==1.7.1
|
||||||
dj-database-url==0.4.2
|
dj-database-url==0.4.2
|
||||||
tox==2.9.1
|
tox==2.9.1
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
|
ignore = E252, W605
|
||||||
exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
|
exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
|
||||||
|
|
||||||
[pep8]
|
[pep8]
|
||||||
|
38
setup.py
38
setup.py
@ -1,13 +1,39 @@
|
|||||||
import os
|
import os
|
||||||
|
import distutils.cmd
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCommand(distutils.cmd.Command):
|
||||||
|
user_options = []
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def create_command(text, commands):
|
||||||
|
"""Creates a custom setup.py command."""
|
||||||
|
|
||||||
|
class CustomCommand(BaseCommand):
|
||||||
|
description = text
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
for cmd in commands:
|
||||||
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
return CustomCommand
|
||||||
|
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8') as readme:
|
with open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8') as readme:
|
||||||
README = readme.read()
|
README = readme.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='django-localized-fields',
|
name='django-localized-fields',
|
||||||
version='5.0a3',
|
version='5.0a5',
|
||||||
packages=find_packages(exclude=['tests']),
|
packages=find_packages(exclude=['tests']),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
license='MIT License',
|
license='MIT License',
|
||||||
@ -18,7 +44,7 @@ setup(
|
|||||||
author_email='open-source@sectorlabs.ro',
|
author_email='open-source@sectorlabs.ro',
|
||||||
keywords=['django', 'localized', 'language', 'models', 'fields'],
|
keywords=['django', 'localized', 'language', 'models', 'fields'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'django-postgres-extra>=1.21a11',
|
'django-postgres-extra>=1.21a14',
|
||||||
'Django>=1.11',
|
'Django>=1.11',
|
||||||
'deprecation==2.0.3'
|
'deprecation==2.0.3'
|
||||||
],
|
],
|
||||||
@ -32,5 +58,11 @@ setup(
|
|||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
'Topic :: Internet :: WWW/HTTP',
|
'Topic :: Internet :: WWW/HTTP',
|
||||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||||
]
|
],
|
||||||
|
cmdclass={
|
||||||
|
'lint': create_command(
|
||||||
|
'Lints the code',
|
||||||
|
[['flake8', 'setup.py', 'localized_fields', 'tests']],
|
||||||
|
),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
@ -33,7 +33,6 @@ class LocalizedFieldTestCase(TestCase):
|
|||||||
field = LocalizedField(required=False)
|
field = LocalizedField(required=False)
|
||||||
assert field.required == []
|
assert field.required == []
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_from_db_value():
|
def test_from_db_value():
|
||||||
"""Tests whether the :see:from_db_value function
|
"""Tests whether the :see:from_db_value function
|
||||||
|
@ -40,7 +40,6 @@ class LocalizedFieldFormTestCase(TestCase):
|
|||||||
for field in form.fields:
|
for field in form.fields:
|
||||||
assert not field.required
|
assert not field.required
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_compress():
|
def test_compress():
|
||||||
"""Tests whether the :see:compress function
|
"""Tests whether the :see:compress function
|
||||||
|
@ -4,7 +4,6 @@ from django.conf import settings
|
|||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
|
||||||
from localized_fields.value import LocalizedIntegerValue
|
|
||||||
from localized_fields.fields import LocalizedIntegerField
|
from localized_fields.fields import LocalizedIntegerField
|
||||||
|
|
||||||
from .fake_model import get_fake_model
|
from .fake_model import get_fake_model
|
||||||
@ -149,7 +148,7 @@ class LocalizedIntegerFieldTestCase(TestCase):
|
|||||||
|
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
table_name = self.TestModel._meta.db_table
|
table_name = self.TestModel._meta.db_table
|
||||||
cursor.execute("update %s set score = 'en=>haha'" % table_name);
|
cursor.execute("update %s set score = 'en=>haha'" % table_name)
|
||||||
|
|
||||||
obj.refresh_from_db()
|
obj.refresh_from_db()
|
||||||
assert obj.score.get(settings.LANGUAGE_CODE) is None
|
assert obj.score.get(settings.LANGUAGE_CODE) is None
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from django.conf import settings
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import translation
|
|
||||||
|
|
||||||
from localized_fields.fields import LocalizedField
|
from localized_fields.fields import LocalizedField
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class LocalizedValueTestCase(TestCase):
|
|||||||
|
|
||||||
# with no value, we always expect it to return None
|
# with no value, we always expect it to return None
|
||||||
localized_value = LocalizedValue()
|
localized_value = LocalizedValue()
|
||||||
assert localized_value.translate() == None
|
assert localized_value.translate() is None
|
||||||
assert str(localized_value) == ''
|
assert str(localized_value) == ''
|
||||||
|
|
||||||
# with no value for the default language, the default
|
# with no value for the default language, the default
|
||||||
@ -164,7 +164,7 @@ class LocalizedValueTestCase(TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
translation.activate(settings.LANGUAGE_CODE)
|
translation.activate(settings.LANGUAGE_CODE)
|
||||||
assert localized_value.translate() == None
|
assert localized_value.translate() is None
|
||||||
assert str(localized_value) == ''
|
assert str(localized_value) == ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
3
tox.ini
3
tox.ini
@ -1,10 +1,11 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py35-dj{111,20}
|
envlist = py35-dj{111,20,21}, py36-dj{111,20,21}, py37-dj{111,20,21}
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
dj111: Django>=1.11,<1.12
|
dj111: Django>=1.11,<1.12
|
||||||
dj20: Django>=2.0,<2.1
|
dj20: Django>=2.0,<2.1
|
||||||
|
dj21: Django>=2.1,<2.2
|
||||||
-rrequirements/test.txt
|
-rrequirements/test.txt
|
||||||
setenv =
|
setenv =
|
||||||
DJANGO_SETTINGS_MODULE=settings
|
DJANGO_SETTINGS_MODULE=settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user