Skip to content

Commit

Permalink
Merge 57055e2 into 8868011
Browse files Browse the repository at this point in the history
  • Loading branch information
devkapilbansal committed Sep 20, 2020
2 parents 8868011 + 57055e2 commit 8c056f4
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 55 deletions.
7 changes: 2 additions & 5 deletions openwisp_utils/admin.py
Expand Up @@ -10,10 +10,7 @@ class TimeReadonlyAdminMixin(object):
"""

def __init__(self, *args, **kwargs):
self.readonly_fields += (
'created',
'modified',
)
self.readonly_fields += ('created', 'modified')
super().__init__(*args, **kwargs)


Expand Down Expand Up @@ -147,7 +144,7 @@ def receive_url(self, obj):
)
baseurl = self.receive_url_baseurl
if not baseurl:
baseurl = '{0}://{1}'.format(self.request.scheme, self.request.get_host(),)
baseurl = '{0}://{1}'.format(self.request.scheme, self.request.get_host())
if self.receive_url_querystring_arg:
url = '{0}{1}?{2}={3}'.format(
baseurl,
Expand Down
10 changes: 2 additions & 8 deletions openwisp_utils/qa.py
Expand Up @@ -10,7 +10,6 @@

import docutils
import readme_renderer.rst as readme_rst
from rstcheck import ignore_sphinx


def _parse_migration_check_args():
Expand Down Expand Up @@ -193,9 +192,7 @@ def check_rst_files():
settings_overrides.update(readme_rst.SETTINGS)
settings_overrides['report_level'] = 2
settings_overrides['warning_stream'] = string_io
files = [_ for _ in iglob('./**/*.rst', recursive=True)]
# Added to register sphinx directives with docutils
ignore_sphinx()
files = [_ for _ in iglob('*.rst', recursive=True)]
for file in files:
data = read_rst_file(file)
try:
Expand Down Expand Up @@ -249,10 +246,7 @@ def _find_issue_mentions(message):
preceding_2words = '{} {}'.format(
words[issue_location - 2], words[issue_location - 1]
)
allowed_refs = [
'related to',
'refers to',
]
allowed_refs = ['related to', 'refers to']
if preceding_2words.lower() in allowed_refs:
good_mentions += 1
continue
Expand Down
3 changes: 1 addition & 2 deletions openwisp_utils/tests.py
Expand Up @@ -45,8 +45,7 @@ def addSuccess(self, test):

def display_slow_tests(self):
print_color(
f'\nSummary of slow tests (>{self.slow_test_threshold[0]}s)\n',
'white_bold',
f'\nSummary of slow tests (>{self.slow_test_threshold[0]}s)\n', 'white_bold'
)
self._module = None
slow_tests_counter = 0
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Expand Up @@ -37,9 +37,9 @@
'checkmigrations = openwisp_utils.qa:check_migration_name',
'checkcommit = openwisp_utils.qa:check_commit_message',
'checkrst = openwisp_utils.qa:check_rst_files',
],
]
},
scripts=['openwisp-qa-check', 'openwisp-qa-format',],
scripts=['openwisp-qa-check', 'openwisp-qa-format'],
zip_safe=False,
install_requires=['django-model-utils>=4.0.0,<4.1.0'],
extras_require={
Expand All @@ -48,7 +48,6 @@
'flake8<=3.9',
'isort~=5.0',
'readme-renderer~=26.0',
'rstcheck',
'coveralls', # depends on coverage as well
],
'rest': [
Expand Down
4 changes: 2 additions & 2 deletions tests/settings.py
Expand Up @@ -71,7 +71,7 @@
'openwisp_utils.admin_theme.context_processor.admin_theme_settings',
],
},
},
}
]

DATABASES = {
Expand All @@ -96,7 +96,7 @@
'DEFAULT_THROTTLE_RATES': {'anon': '20/hour'},
}

CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache',}}
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}

# local settings must be imported before test runner otherwise they'll be ignored
try:
Expand Down
12 changes: 2 additions & 10 deletions tests/test_project/admin.py
Expand Up @@ -36,16 +36,8 @@ class OperatorInline(admin.StackedInline):
class ProjectAdmin(UUIDAdmin, ReceiveUrlAdmin):
inlines = [OperatorInline]
list_display = ('name',)
fields = (
'uuid',
'name',
'key',
'receive_url',
)
readonly_fields = (
'uuid',
'receive_url',
)
fields = ('uuid', 'name', 'key', 'receive_url')
readonly_fields = ('uuid', 'receive_url')
receive_url_name = 'receive_project'


Expand Down
2 changes: 1 addition & 1 deletion tests/test_project/api/urls.py
Expand Up @@ -7,5 +7,5 @@
r'^receive_project/(?P<pk>[^/\?]+)/$',
views.receive_project,
name='receive_project',
),
)
]
4 changes: 1 addition & 3 deletions tests/test_project/apps.py
Expand Up @@ -18,7 +18,5 @@ def ready(self, *args, **kwargs):

def add_default_menu_items(self):
menu_setting = 'OPENWISP_DEFAULT_ADMIN_MENU_ITEMS'
items = [
{'model': 'test_project.Shelf'},
]
items = [{'model': 'test_project.Shelf'}]
setattr(settings, menu_setting, items)
4 changes: 2 additions & 2 deletions tests/test_project/migrations/0001_initial.py
Expand Up @@ -89,7 +89,7 @@ class Migration(migrations.Migration):
),
('name', models.CharField(max_length=64, verbose_name='name')),
],
options={'abstract': False,},
options={'abstract': False},
),
migrations.CreateModel(
name='Operator',
Expand Down Expand Up @@ -153,6 +153,6 @@ class Migration(migrations.Migration):
),
),
],
options={'abstract': False,},
options={'abstract': False},
),
]
4 changes: 1 addition & 3 deletions tests/test_project/migrations/0002_add_key_id_project.py
Expand Up @@ -10,9 +10,7 @@

class Migration(migrations.Migration):

dependencies = [
('test_project', '0001_initial'),
]
dependencies = [('test_project', '0001_initial')]

operations = [
migrations.AddField(
Expand Down
4 changes: 1 addition & 3 deletions tests/test_project/tests/test_api.py
Expand Up @@ -9,9 +9,7 @@

class TestApi(CreateMixin, TestCase):
shelf_model = Shelf
operator_permission_filter = [
{'codename__endswith': 'shelf'},
]
operator_permission_filter = [{'codename__endswith': 'shelf'}]

def test_validator_pass(self):
s1 = self._create_shelf(name='shelf1')
Expand Down
13 changes: 2 additions & 11 deletions tests/test_project/tests/test_qa.py
Expand Up @@ -69,11 +69,7 @@ def test_qa_call_check_migration_name_failure(self):
self.fail('SystemExit not raised')

def test_migration_failure_message(self):
bad_migration = [
'checkmigrations',
'--migration-path',
MIGRATIONS_DIR,
]
bad_migration = ['checkmigrations', '--migration-path', MIGRATIONS_DIR]
with patch('argparse._sys.argv', bad_migration):
captured_output = io.StringIO()
sys.stdout = captured_output # redirect stdout
Expand Down Expand Up @@ -169,12 +165,7 @@ def test_qa_call_check_commit_message_failure(self):
'--message',
'[qa] Updated file and fixed problem\n\nAdded more files. Fixes #20',
],
[
'commitcheck',
'--quiet',
'--message',
'[qa] Improved Y\n\nRelated to #2',
],
['commitcheck', '--quiet', '--message', '[qa] Improved Y\n\nRelated to #2'],
[
'commitcheck',
'--quiet',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_project/tests/test_test_utils.py
Expand Up @@ -16,7 +16,7 @@ def test_status_signal_emitted(self):
with catch_signal(status_signal) as handler:
self._generate_signal()
handler.assert_called_once_with(
status='working', sender=self, signal=status_signal,
status='working', sender=self, signal=status_signal
)

def test_deep_merge_dicts(self):
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_deep_merge_dicts(self):
def test_time_logging_runner(self):
runner = TimeLoggingTestRunner()
suite = runner.build_suite(
['test_project.tests.test_test_utils.TestUtils.test_status_signal_emitted'],
['test_project.tests.test_test_utils.TestUtils.test_status_signal_emitted']
)
with captured_stdout() as stdout, captured_stderr() as stderr:
runner.run_suite(suite)
Expand Down

0 comments on commit 8c056f4

Please sign in to comment.