Merge branch 'dev' into small-improvements

This commit is contained in:
David-Wobrock committed 2018-01-13 00:11:53 +01:00
commit 61cd48dc8c
16 files changed
+104 -33

No files matched your search

+1
View File
@@ -11,3 +11,4 @@ dist/
.cache/ .cache/
env/ env/
tests/test_project_fixtures/*/.git/ tests/test_project_fixtures/*/.git/
.tox/
+35 -9
View File
@@ -1,11 +1,37 @@
sudo: false
language: python language: python
python:
- "2.7" matrix:
- "3.4" include:
- "3.5" - python: 2.7
- "3.6" env: TOXENV=py27-django110
script: - python: 2.7
- flake8 django_migration_linter env: TOXENV=py27-django111
- py.test
- python: 3.4
env: TOXENV=py34-django110
- python: 3.4
env: TOXENV=py34-django111
- python: 3.4
env: TOXENV=py34-django20
- python: 3.5
env: TOXENV=py35-django110
- python: 3.5
env: TOXENV=py35-django111
- python: 3.5
env: TOXENV=py35-django20
- python: 3.6
env: TOXENV=py36-django111
- python: 3.6
env: TOXENV=py36-django20
- python: 3.6
env: TOXENV=lint
install: install:
- pip install -e ".[test]" - pip install tox
script:
- tox
+2
View File
@@ -0,0 +1,2 @@
include README.md
include LICENSE
+1 -1
View File
@@ -49,7 +49,7 @@ The linter will try to detect if the project is a django project and is versione
## Tests ## Tests
The easiest way to run the tests is to invoke [py.test](https://docs.pytest.org/en/latest/). The easiest way to run the tests is to invoke [tox](https://pypi.python.org/pypi/tox).
## License ## License
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+8 -4
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -43,6 +43,8 @@ class MigrationLinter(object):
self.include_apps = kwargs.get('include_apps', None) self.include_apps = kwargs.get('include_apps', None)
self.exclude_apps = kwargs.get('exclude_apps', None) self.exclude_apps = kwargs.get('exclude_apps', None)
self.database = kwargs.get('database', None) or 'default' self.database = kwargs.get('database', None) or 'default'
self.python_exe = '{0}/bin/{1}'.format(sys.prefix, 'python') if \
hasattr(sys, 'real_prefix') else 'python'
# Initialise counters # Initialise counters
self.nb_valid = 0 self.nb_valid = 0
@@ -125,9 +127,11 @@ class MigrationLinter(object):
""" """
git_diff_command = ( git_diff_command = (
'cd {0} && ' 'cd {0} && '
'python manage.py sqlmigrate {1} {2} ' '{1} manage.py sqlmigrate {2} {3} '
'--database {3}').format( '--database {4}').format(
self.django_path, app_name, migration_name, self.database) self.django_path,
self.python_exe, app_name, migration_name,
self.database)
log.info('Executing {0}'.format(git_diff_command)) log.info('Executing {0}'.format(git_diff_command))
sqlmigrate_process = Popen( sqlmigrate_process = Popen(
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE) git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+6 -3
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -30,9 +30,9 @@ install_requirements = [
test_requirements = [ test_requirements = [
'pytest', 'pytest',
'django', 'tox',
'django>=1.10',
'django-fake-database-backends', 'django-fake-database-backends',
'flake8'
] ]
setup( setup(
@@ -62,6 +62,9 @@ setup(
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'Environment :: Web Environment', 'Environment :: Web Environment',
'Framework :: Django', 'Framework :: Django',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+21 -8
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -16,11 +16,18 @@ import unittest
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from django_migration_linter import utils from django_migration_linter import utils
from tests import fixtures from tests import fixtures
import sys
class CallLinterFromCommandLineTest(unittest.TestCase): class CallLinterFromCommandLineTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
super(CallLinterFromCommandLineTest, cls).setUpClass()
linter_name = 'django-migration-linter'
cls.linter_exec = '{0}/bin/{1}'.format(sys.prefix, linter_name) if hasattr(sys, 'real_prefix') else linter_name
def test_call_linter_cmd_line_working(self): def test_call_linter_cmd_line_working(self):
cmd = 'django-migration-linter {0}'.format(fixtures.CORRECT_PROJECT) cmd = '{0} {1}'.format(self.linter_exec, fixtures.CORRECT_PROJECT)
process = Popen( process = Popen(
cmd, shell=True, stdout=PIPE, stderr=PIPE) cmd, shell=True, stdout=PIPE, stderr=PIPE)
@@ -33,7 +40,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue(lines[2].endswith('OK')) self.assertTrue(lines[2].endswith('OK'))
def test_call_linter_cmd_line_errors(self): def test_call_linter_cmd_line_errors(self):
cmd = 'django-migration-linter {0}'.format( cmd = '{0} {1}'.format(
self.linter_exec,
fixtures.ADD_NOT_NULL_COLUMN_PROJECT) fixtures.ADD_NOT_NULL_COLUMN_PROJECT)
process = Popen( process = Popen(
@@ -48,7 +56,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue('RENAMING tables' in lines[2]) self.assertTrue('RENAMING tables' in lines[2])
def test_call_linter_cmd_line_exclude_apps(self): def test_call_linter_cmd_line_exclude_apps(self):
cmd = 'django-migration-linter {0} --exclude-apps test_app2'.format( cmd = '{0} {1} --exclude-apps test_app2'.format(
self.linter_exec,
fixtures.CORRECT_PROJECT) fixtures.CORRECT_PROJECT)
process = Popen( process = Popen(
@@ -62,7 +71,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue(lines[2].endswith('IGNORE')) self.assertTrue(lines[2].endswith('IGNORE'))
def test_call_linter_cmd_line_include_apps(self): def test_call_linter_cmd_line_include_apps(self):
cmd = 'django-migration-linter {0} --include-apps test_app2'.format( cmd = '{0} {1} --include-apps test_app2'.format(
self.linter_exec,
fixtures.CORRECT_PROJECT) fixtures.CORRECT_PROJECT)
process = Popen( process = Popen(
@@ -76,7 +86,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue(lines[2].endswith('OK')) self.assertTrue(lines[2].endswith('OK'))
def test_call_linter_cmd_line_ignore_name(self): def test_call_linter_cmd_line_ignore_name(self):
cmd = 'django-migration-linter {0} --ignore-name 0001_initial'.format( cmd = '{0} {1} --ignore-name 0001_initial'.format(
self.linter_exec,
fixtures.CORRECT_PROJECT) fixtures.CORRECT_PROJECT)
process = Popen( process = Popen(
@@ -90,7 +101,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue(lines[2].endswith('OK')) self.assertTrue(lines[2].endswith('OK'))
def test_call_linter_cmd_line_ignore_name_contains(self): def test_call_linter_cmd_line_ignore_name_contains(self):
cmd = 'django-migration-linter {0} --ignore-name-contains 0001'.format( cmd = '{0} {1} --ignore-name-contains 0001'.format(
self.linter_exec,
fixtures.CORRECT_PROJECT) fixtures.CORRECT_PROJECT)
process = Popen( process = Popen(
@@ -104,7 +116,8 @@ class CallLinterFromCommandLineTest(unittest.TestCase):
self.assertTrue(lines[2].endswith('IGNORE')) self.assertTrue(lines[2].endswith('IGNORE'))
def test_call_linter_cmd_line_git_id(self): def test_call_linter_cmd_line_git_id(self):
cmd = 'django-migration-linter {0} d7125d5f4f0cc9623f670a66c54f131acc50032d'.format( cmd = '{0} {1} d7125d5f4f0cc9623f670a66c54f131acc50032d'.format(
self.linter_exec,
fixtures.MULTI_COMMIT_PROJECT) fixtures.MULTI_COMMIT_PROJECT)
fixtures.prepare_git_project(fixtures.MULTI_COMMIT_PROJECT) fixtures.prepare_git_project(fixtures.MULTI_COMMIT_PROJECT)
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright 2017 3YOURMIND GmbH # Copyright 2018 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
+22
View File
@@ -0,0 +1,22 @@
[tox]
envlist =
py{27,34,35}-django110
py{27,34,35,36}-django111
py{34,35,36}-django20
lint
[testenv]
commands = py.test {posargs}
extras = test
pip_pre = true
deps =
django110: django>=1.10,<1.11
django111: django>=1.11,<2.0
django20: django>=2.0
[testenv:lint]
basepython = python3.6
deps =
flake8
commands =
flake8 django_migration_linter