Fix test : do not consider deleted migrations
* Change way to detect deleted migrations (diff-filter of 'git diff' command)
This commit is contained in:
1 parent
fffdf5714e
commit
698e658faa
15 files changed
+45
-13
No files matched your search
@@ -152,7 +152,9 @@ class MigrationLinter(object):
|
|||||||
def _gather_migrations_git(self, git_commit_id):
|
def _gather_migrations_git(self, git_commit_id):
|
||||||
migrations = []
|
migrations = []
|
||||||
# Get changes since specified commit
|
# Get changes since specified commit
|
||||||
git_diff_command = 'cd {0} && git diff --name-status {1}'.format(
|
git_diff_command = (
|
||||||
|
'cd {0} && '
|
||||||
|
'git diff --name-only --diff-filter=A {1}').format(
|
||||||
self.django_path, git_commit_id)
|
self.django_path, git_commit_id)
|
||||||
log.info('Executing {0}'.format(git_diff_command))
|
log.info('Executing {0}'.format(git_diff_command))
|
||||||
diff_process = Popen(
|
diff_process = Popen(
|
||||||
@@ -161,10 +163,9 @@ class MigrationLinter(object):
|
|||||||
utils.clean_bytes_to_str, diff_process.stdout.readlines()):
|
utils.clean_bytes_to_str, diff_process.stdout.readlines()):
|
||||||
# Only gather lines that include added migrations
|
# Only gather lines that include added migrations
|
||||||
if re.search(
|
if re.search(
|
||||||
'^A.*\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME),
|
'\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME),
|
||||||
line) and \
|
line) and \
|
||||||
'__init__' not in line:
|
'__init__' not in line:
|
||||||
line = line.split()[-1] # Remove the status letter
|
|
||||||
app_name, migration_name = self._split_migration_path(line)
|
app_name, migration_name = self._split_migration_path(line)
|
||||||
migrations.append((app_name, migration_name))
|
migrations.append((app_name, migration_name))
|
||||||
diff_process.wait()
|
diff_process.wait()
|
||||||
|
|||||||
@@ -116,6 +116,21 @@ 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 = '{0} {1} d7125d5f4f0cc9623f670a66c54f131acc50032d'.format(
|
||||||
|
self.linter_exec,
|
||||||
|
fixtures.MULTI_COMMIT_PROJECT)
|
||||||
|
fixtures.prepare_git_project(fixtures.MULTI_COMMIT_PROJECT)
|
||||||
|
|
||||||
|
process = Popen(
|
||||||
|
cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||||
|
process.wait()
|
||||||
|
self.assertEqual(process.returncode, 0)
|
||||||
|
lines = list(map(utils.clean_bytes_to_str, process.stdout.readlines()))
|
||||||
|
self.assertEqual(len(lines), 3)
|
||||||
|
self.assertTrue(lines[0].endswith('OK'))
|
||||||
|
self.assertTrue(lines[1].startswith('*** Summary'))
|
||||||
|
|
||||||
|
def test_call_linter_with_deleted_migrations(self):
|
||||||
cmd = '{0} {1} 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba'.format(
|
cmd = '{0} {1} 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba'.format(
|
||||||
self.linter_exec,
|
self.linter_exec,
|
||||||
fixtures.DELETED_MIGRATION_PROJECT)
|
fixtures.DELETED_MIGRATION_PROJECT)
|
||||||
|
|||||||
@@ -1 +1,16 @@
|
|||||||
Delete file and insert new
|
Delete file and insert new
|
||||||
|
|
||||||
|
# Please enter the commit message for your changes. Lines starting
|
||||||
|
# with '#' will be ignored, and an empty message aborts the commit.
|
||||||
|
#
|
||||||
|
# Date: Thu Jan 18 23:27:37 2018 +0100
|
||||||
|
#
|
||||||
|
# On branch master
|
||||||
|
# Changes to be committed:
|
||||||
|
# deleted: test_app/migrations/0002_new_not_null_field.py
|
||||||
|
# new file: test_app/migrations/0003_new_nullable_field.py
|
||||||
|
# modified: test_app/models.py
|
||||||
|
#
|
||||||
|
# Untracked files:
|
||||||
|
# git/
|
||||||
|
#
|
||||||
Binary file not shown.
@@ -1,3 +1,4 @@
|
|||||||
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
||||||
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
||||||
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
||||||
|
be2fae887ee7ecd2d1e6371af1a865c17414bde9 4bdc4ba9e7695893423be1b54f3101d6ccbd11c7 David-Wobrock <david.wobrock@gmail.com> 1516459290 +0100 commit (amend): Delete file and insert new
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
0000000000000000000000000000000000000000 0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e David-Wobrock <david.wobrock@gmail.com> 1516314144 +0100 commit (initial): Project init
|
||||||
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
0395cbee60f2ea1b97f42ebdd43991c8f5d8d76e 154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba David-Wobrock <david.wobrock@gmail.com> 1516314322 +0100 commit: Add backward incompatible migration
|
||||||
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
154ecf6119325cc3b1f3f5a4e709bfbd61a4a4ba be2fae887ee7ecd2d1e6371af1a865c17414bde9 David-Wobrock <david.wobrock@gmail.com> 1516314457 +0100 commit: Delete file and insert new
|
||||||
|
be2fae887ee7ecd2d1e6371af1a865c17414bde9 4bdc4ba9e7695893423be1b54f3101d6ccbd11c7 David-Wobrock <david.wobrock@gmail.com> 1516459290 +0100 commit (amend): Delete file and insert new
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x�ޱ
|
||||||
|
Â0E]íW¼± RAÈ …‚ƒ›{Hš×´ò’H’¢ŸocÄÉñ^Îá^E^A]ïW}ðôU:ã™V0Ú› ¬×H±(:’1±\2;çº:k7‰~DÒÀß0;¹„C›Û2ü&¬fïÂù$þ“ZIñcuƒ/M*B‘0¦ßÑf&–E+‚Й4ðÝv_ž<4Si
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -1 +1 @@
|
|||||||
be2fae887ee7ecd2d1e6371af1a865c17414bde9
|
4bdc4ba9e7695893423be1b54f3101d6ccbd11c7
|
||||||
+5
-8
@@ -1,18 +1,15 @@
|
|||||||
# Generated by Django 2.0.1 on 2018-01-18 22:26
|
from django.db import migrations
|
||||||
|
from django.db import models
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [('test_app', '0001_initial'),]
|
||||||
('test_app', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='a',
|
model_name='a',
|
||||||
name='new_nullable_field',
|
name='new_char_nullable_test_field',
|
||||||
field=models.IntegerField(null=True),
|
field=models.CharField(max_length=30, null=True),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -3,4 +3,4 @@ from django.db import models
|
|||||||
class A(models.Model):
|
class A(models.Model):
|
||||||
null_field = models.IntegerField(null=True)
|
null_field = models.IntegerField(null=True)
|
||||||
new_not_null_field = models.IntegerField(null=False)
|
new_not_null_field = models.IntegerField(null=False)
|
||||||
new_nullable_field = models.IntegerField(null=True)
|
new_char_nullable_test_field = models.CharField(max_length=30, null=True)
|
||||||
Reference in new issue
Block a user