Rename method name and add comments
This commit is contained in:
1 parent
a68ff7c306
commit
601e02e024
2 files changed
+15
-13
No files matched your search
@@ -407,6 +407,7 @@ class MigrationLinter(object):
|
|||||||
ignored = []
|
ignored = []
|
||||||
warning = []
|
warning = []
|
||||||
|
|
||||||
|
# Detect warning on missing reverse operation
|
||||||
if not runpython.reversible:
|
if not runpython.reversible:
|
||||||
issue = {
|
issue = {
|
||||||
"code": "REVERSIBLE_DATA_MIGRATION",
|
"code": "REVERSIBLE_DATA_MIGRATION",
|
||||||
@@ -419,11 +420,12 @@ class MigrationLinter(object):
|
|||||||
else:
|
else:
|
||||||
warning.append(issue)
|
warning.append(issue)
|
||||||
|
|
||||||
if PY2:
|
# Detect warning for argument naming convention
|
||||||
args_spec = inspect.getargspec(runpython.code)
|
args_spec = (
|
||||||
else:
|
inspect.getargspec(runpython.code)
|
||||||
args_spec = inspect.getfullargspec(runpython.code)
|
if PY2
|
||||||
|
else inspect.getfullargspec(runpython.code)
|
||||||
|
)
|
||||||
if tuple(args_spec.args) != EXPECTED_DATA_MIGRATION_ARGS:
|
if tuple(args_spec.args) != EXPECTED_DATA_MIGRATION_ARGS:
|
||||||
issue = {
|
issue = {
|
||||||
"code": "NAMING_CONVENTION_RUNPYTHON_ARGS",
|
"code": "NAMING_CONVENTION_RUNPYTHON_ARGS",
|
||||||
@@ -439,7 +441,7 @@ class MigrationLinter(object):
|
|||||||
|
|
||||||
# Detect wrong model imports
|
# Detect wrong model imports
|
||||||
# Forward
|
# Forward
|
||||||
issues = self.get_data_migration_model_import_issues(runpython.code)
|
issues = self.get_runpython_model_import_issues(runpython.code)
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
if issue["code"] in self.exclude_migration_tests:
|
if issue["code"] in self.exclude_migration_tests:
|
||||||
ignored.append(issue)
|
ignored.append(issue)
|
||||||
@@ -448,7 +450,7 @@ class MigrationLinter(object):
|
|||||||
|
|
||||||
# Backward
|
# Backward
|
||||||
if runpython.reversible:
|
if runpython.reversible:
|
||||||
issues = self.get_data_migration_model_import_issues(runpython.reverse_code)
|
issues = self.get_runpython_model_import_issues(runpython.reverse_code)
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
if issue and issue["code"] in self.exclude_migration_tests:
|
if issue and issue["code"] in self.exclude_migration_tests:
|
||||||
ignored.append(issue)
|
ignored.append(issue)
|
||||||
@@ -457,7 +459,7 @@ class MigrationLinter(object):
|
|||||||
return error, ignored, warning
|
return error, ignored, warning
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_data_migration_model_import_issues(code):
|
def get_runpython_model_import_issues(code):
|
||||||
model_object_regex = re.compile(r"[^a-zA-Z]?([a-zA-Z0-9]+?)\.objects")
|
model_object_regex = re.compile(r"[^a-zA-Z]?([a-zA-Z0-9]+?)\.objects")
|
||||||
|
|
||||||
function_name = code.__name__
|
function_name = code.__name__
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class DataMigrationModelImportTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
MyModel.objects.filter(id=1).first()
|
MyModel.objects.filter(id=1).first()
|
||||||
|
|
||||||
issues = MigrationLinter.get_data_migration_model_import_issues(
|
issues = MigrationLinter.get_runpython_model_import_issues(
|
||||||
incorrect_importing_model_forward
|
incorrect_importing_model_forward
|
||||||
)
|
)
|
||||||
self.assertEqual(1, len(issues))
|
self.assertEqual(1, len(issues))
|
||||||
@@ -94,7 +94,7 @@ class DataMigrationModelImportTestCase(unittest.TestCase):
|
|||||||
MyVeryLongLongLongModel.objects.filter(id=1).first()
|
MyVeryLongLongLongModel.objects.filter(id=1).first()
|
||||||
MultiLineModel.objects.all()
|
MultiLineModel.objects.all()
|
||||||
|
|
||||||
issues = MigrationLinter.get_data_migration_model_import_issues(
|
issues = MigrationLinter.get_runpython_model_import_issues(
|
||||||
correct_importing_model_forward
|
correct_importing_model_forward
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(issues))
|
self.assertEqual(0, len(issues))
|
||||||
@@ -109,7 +109,7 @@ class DataMigrationModelImportTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
User.objects.filter(id=1).first()
|
User.objects.filter(id=1).first()
|
||||||
|
|
||||||
issues = MigrationLinter.get_data_migration_model_import_issues(forward_method)
|
issues = MigrationLinter.get_runpython_model_import_issues(forward_method)
|
||||||
self.assertEqual(0, len(issues))
|
self.assertEqual(0, len(issues))
|
||||||
|
|
||||||
def test_correct_one_param_get_model_import(self):
|
def test_correct_one_param_get_model_import(self):
|
||||||
@@ -118,7 +118,7 @@ class DataMigrationModelImportTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
User.objects.filter(id=1).first()
|
User.objects.filter(id=1).first()
|
||||||
|
|
||||||
issues = MigrationLinter.get_data_migration_model_import_issues(forward_method)
|
issues = MigrationLinter.get_runpython_model_import_issues(forward_method)
|
||||||
self.assertEqual(0, len(issues))
|
self.assertEqual(0, len(issues))
|
||||||
|
|
||||||
def test_not_overlapping_one_param(self):
|
def test_not_overlapping_one_param(self):
|
||||||
@@ -131,5 +131,5 @@ class DataMigrationModelImportTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
User.objects.filter(id=1).first()
|
User.objects.filter(id=1).first()
|
||||||
|
|
||||||
issues = MigrationLinter.get_data_migration_model_import_issues(forward_method)
|
issues = MigrationLinter.get_runpython_model_import_issues(forward_method)
|
||||||
self.assertEqual(0, len(issues))
|
self.assertEqual(0, len(issues))
|
||||||
Reference in new issue
Block a user