Skip to content

Commit

Permalink
Pylint | implemented consider-using-f-string fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Sep 20, 2021
1 parent 0a9885e commit d97c58a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions core/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def delete_duplicate_locales(start_from=None): # pragma: no cover

for start in range(start_from, total, batch_size):
end = min(start + batch_size, total)
logger.info(f'Iterating concepts {start + 1:d} - {end:d}...') # pylint: disable=logging-not-lazy
logger.info('Iterating concepts %d - %d...' % (start + 1, end)) # pylint: disable=logging-not-lazy,consider-using-f-string
concepts = queryset.order_by('id')[start:end]
for concept in concepts:
logger.info('Cleaning up %s', concept.mnemonic)
Expand All @@ -417,12 +417,12 @@ def delete_dormant_locales(): # pragma: no cover
from core.concepts.models import LocalizedText
queryset = LocalizedText.get_dormant_queryset()
total = queryset.count()
logger.info(f'{total} Dormant locales found. Deleting in batches...') # pylint: disable=logging-not-lazy
logger.info('%s Dormant locales found. Deleting in batches...' % total) # pylint: disable=logging-not-lazy,consider-using-f-string

batch_size = 1000
for start in range(0, total, batch_size):
end = min(start + batch_size, total)
logger.info(f'Iterating locales {start + 1:d} - {end:d} to delete...') # pylint: disable=logging-not-lazy
logger.info('Iterating locales %d - %d to delete...' % (start + 1, end)) # pylint: disable=logging-not-lazy,consider-using-f-string
LocalizedText.objects.filter(id__in=queryset.order_by('id')[start:end].values('id')).delete()

return 1
Expand Down
18 changes: 9 additions & 9 deletions core/importers/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ def setUp(self):

@patch('core.importers.views.flower_get')
def test_get_without_task_id(self, flower_get_mock):
task_id1 = f"{str(uuid.uuid4())}-{'ocladmin'}~{'priority'}"
task_id2 = f"{str(uuid.uuid4())}-{'foobar'}~{'normal'}"
task_id1 = f"{str(uuid.uuid4())}-ocladmin~priority"
task_id2 = f"{str(uuid.uuid4())}-foobar~normal"
flower_tasks = {
task_id1: dict(name='core.common.tasks.bulk_import', state='success'),
task_id2: dict(name='core.common.tasks.bulk_import', state='failed'),
Expand Down Expand Up @@ -620,8 +620,8 @@ def test_get_without_task_id(self, flower_get_mock):

@patch('core.importers.views.AsyncResult')
def test_get_with_task_id_success(self, async_result_klass_mock):
task_id1 = f"{str(uuid.uuid4())}-{'ocladmin'}~{'priority'}"
task_id2 = f"{str(uuid.uuid4())}-{'foobar'}~{'normal'}"
task_id1 = f"{str(uuid.uuid4())}-ocladmin'~priority"
task_id2 = f"{str(uuid.uuid4())}-foobar~normal"
foobar_user = UserProfileFactory(username='foobar')

response = self.client.get(
Expand All @@ -636,7 +636,7 @@ def test_get_with_task_id_success(self, async_result_klass_mock):
async_result_klass_mock.return_value = async_result_instance_mock

response = self.client.get(
'/importers/bulk-import/?task={}'.format(task_id2),
f'/importers/bulk-import/?task={task_id2}',
HTTP_AUTHORIZATION='Token ' + foobar_user.get_token(),
format='json'
)
Expand All @@ -652,7 +652,7 @@ def test_get_with_task_id_success(self, async_result_klass_mock):
self.assertEqual(response.data, 'json-format')

response = self.client.get(
'/importers/bulk-import/?task={}&result=report'.format(task_id2),
f'/importers/bulk-import/?task={task_id2}&result=report',
HTTP_AUTHORIZATION='Token ' + foobar_user.get_token(),
format='json'
)
Expand All @@ -663,7 +663,7 @@ def test_get_with_task_id_success(self, async_result_klass_mock):

@patch('core.importers.views.AsyncResult')
def test_get_with_task_id_failed(self, async_result_klass_mock):
task_id = "{}-{}~{}".format(str(uuid.uuid4()), 'foobar', 'normal')
task_id = f"{str(uuid.uuid4())}-foobar~normal"
foobar_user = UserProfileFactory(username='foobar')

async_result_instance_mock = Mock(
Expand All @@ -685,7 +685,7 @@ def test_get_with_task_id_failed(self, async_result_klass_mock):
@patch('core.importers.views.AsyncResult')
def test_get_task_pending(self, async_result_klass_mock, task_exists_mock):
task_exists_mock.return_value = False
task_id = "{}-{}~{}".format(str(uuid.uuid4()), 'foobar', 'normal')
task_id = f"{str(uuid.uuid4())}-foobar~normal"
foobar_user = UserProfileFactory(username='foobar')

async_result_instance_mock = Mock(
Expand All @@ -700,7 +700,7 @@ def test_get_task_pending(self, async_result_klass_mock, task_exists_mock):
)

self.assertEqual(response.status_code, 404)
self.assertEqual(response.data, dict(exception="task {} not found".format(task_id)))
self.assertEqual(response.data, dict(exception=f"task {task_id} not found"))

async_result_instance_mock.successful.assert_called_once()
async_result_instance_mock.failed.assert_called_once()
Expand Down
3 changes: 2 additions & 1 deletion core/integration_tests/tests_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ def test_delete(self):
self.assertTrue(self.collection.versions.first().is_latest_version)

response = self.client.delete(
f'/users/{self.collection.parent.mnemonic}/collections/{self.collection.mnemonic}/{self.collection.version}/',
f'/users/{self.collection.parent.mnemonic}/collections/'
f'{self.collection.mnemonic}/{self.collection.version}/',
HTTP_AUTHORIZATION='Token ' + self.token,
format='json'
)
Expand Down

0 comments on commit d97c58a

Please sign in to comment.