Skip to content

Commit db51a90

Browse files
committed
fixing tests and signals
1 parent ce4abaf commit db51a90

File tree

7 files changed

+6
-8
lines changed

7 files changed

+6
-8
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import pytest
3+
from django.conf import settings
34
from rest_framework.test import APIClient
45

56
try:
@@ -46,7 +47,6 @@ def pytest_configure(config):
4647
def settings_modification(settings):
4748
settings.CELERY_ALWAYS_EAGER = True
4849

49-
5050
@pytest.fixture
5151
def api_client():
5252
return APIClient()

readthedocs/projects/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ def _manage_imported_files(version, path, commit):
10171017
obj.commit = commit
10181018
obj.save()
10191019

1020-
if isinstance(obj, HTMLFile):
1020+
if model_class == HTMLFile:
10211021
# the `obj` is HTMLFile, so add it to the list
10221022
created_html_files.append(obj)
10231023

readthedocs/search/documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PageDocument(RTDDocTypeMixin, DocType):
5252
class Meta(object):
5353
model = HTMLFile
5454
fields = ('commit',)
55-
ignore_signals = True
55+
ignore_signals = settings.ES_PAGE_IGNORE_SIGNALS
5656

5757
project = fields.KeywordField(attr='project.slug')
5858
version = fields.KeywordField(attr='version.slug')

readthedocs/search/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def index_html_file(instance_list, **_):
2424
'objects_id': [obj.id for obj in instance_list],
2525
}
2626

27-
index_objects_to_es_task.delay(**kwargs)
27+
index_objects_to_es_task(**kwargs)
2828

2929

3030
@receiver(bulk_post_delete, sender=HTMLFile)

readthedocs/search/tests/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,5 @@ def get_dummy_processed_json(instance):
5858

5959
@pytest.fixture(autouse=True)
6060
def mock_processed_json(mocker):
61-
62-
# patch the function from `projects.tasks` because it has been point to there
63-
# http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch
6461
mocked_function = mocker.patch.object(HTMLFile, 'get_processed_json', autospec=True)
6562
mocked_function.side_effect = get_dummy_processed_json
66-

readthedocs/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def USE_PROMOS(self): # noqa
326326
}
327327
# Chunk size for elasticsearch reindex celery tasks
328328
ES_TASK_CHUNK_SIZE = 100
329+
ES_PAGE_IGNORE_SIGNALS = True
329330

330331
# ANALYZER = 'analysis': {
331332
# 'analyzer': {

readthedocs/settings/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class CommunityTestSettings(CommunityDevSettings):
1616

1717
DEBUG = False
1818
TEMPLATE_DEBUG = False
19+
ES_PAGE_IGNORE_SIGNALS = False
1920

2021
@property
2122
def ES_INDEXES(self): # noqa - avoid pep8 N802

0 commit comments

Comments
 (0)