Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be explicit on privacy level for search tests #6713

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions readthedocs/search/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from django.core.management import call_command
from django_dynamic_fixture import G

from readthedocs.projects.models import Project, HTMLFile
from readthedocs.projects.constants import PUBLIC
from readthedocs.projects.models import HTMLFile, Project
from readthedocs.search.documents import PageDocument
from readthedocs.sphinx_domains.models import SphinxDomain

Expand All @@ -27,7 +28,14 @@ def all_projects(es_index, mock_processed_json, db, settings):
settings.ELASTICSEARCH_DSL_AUTOSYNC = True
projects_list = []
for project_slug in ALL_PROJECTS:
project = G(Project, slug=project_slug, name=project_slug)
project = G(
Project,
slug=project_slug,
name=project_slug,
main_language_project=None,
privacy_level=PUBLIC,
)
project.versions.update(privacy_level=PUBLIC)

for file_basename in PROJECT_DATA_FILES[project.slug]:
# file_basename in config are without extension so add html extension
Expand Down
8 changes: 7 additions & 1 deletion readthedocs/search/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django_dynamic_fixture import G

from readthedocs.builds.models import Version
from readthedocs.projects.constants import PUBLIC
from readthedocs.projects.models import HTMLFile, Project
from readthedocs.search.documents import PageDocument
from readthedocs.search.tests.utils import (
Expand Down Expand Up @@ -139,7 +140,12 @@ def test_doc_search_filter_by_version(self, api_client, project):
query = get_search_query_from_project_file(project_slug=project.slug)
latest_version = project.versions.all()[0]
# Create another version
dummy_version = G(Version, project=project, active=True)
dummy_version = G(
Version,
project=project,
active=True,
privacy_level=PUBLIC,
)
# Create HTMLFile same as the latest version
latest_version_files = HTMLFile.objects.all().filter(version=latest_version)
for f in latest_version_files:
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/search/tests/test_faceted_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@pytest.mark.django_db
@pytest.mark.search
class TestPageSearch(object):
class TestPageSearch:

@pytest.mark.parametrize('case', ['upper', 'lower', 'title'])
def test_search_exact_match(self, client, project, case):
Expand Down
6 changes: 2 additions & 4 deletions readthedocs/search/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import re

import pytest
Expand All @@ -10,8 +8,8 @@
from readthedocs.builds.models import Version
from readthedocs.projects.models import HTMLFile, Project
from readthedocs.search.tests.utils import (
get_search_query_from_project_file,
DATA_TYPES_VALUES,
get_search_query_from_project_file,
)


Expand Down Expand Up @@ -85,7 +83,7 @@ def test_search_project_filter_language(self, client, project):

@pytest.mark.django_db
@pytest.mark.search
class TestPageSearch(object):
class TestPageSearch:
url = reverse('search')

def _get_search_result(self, url, client, search_params):
Expand Down