repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
readthedocs.org | readthedocs/oauth/urls.py | .py | from django.urls import path
from readthedocs.oauth.views import GitHubAppWebhookView
urlpatterns = [
path("githubapp/", GitHubAppWebhookView.as_view(), name="github_app_webhook"),
]
| 9 | 190 |
readthedocs.org | readthedocs/oauth/migrate.py | .py | """This module contains the logic to help users migrate from the GitHub OAuth App to the GitHub App."""
from dataclasses import dataclass
from functools import cached_property
from typing import Iterator
from urllib.parse import urlencode
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccou... | 412 | 14,912 |
readthedocs.org | readthedocs/oauth/tasks.py | .py | """Tasks for OAuth services."""
import datetime
from functools import cached_property
import structlog
from django.contrib.auth.models import User
from django.db.models.functions import ExtractIsoWeekDay
from django.urls import reverse
from django.utils import timezone
from readthedocs.api.v2.views.integrations impo... | 985 | 38,426 |
readthedocs.org | readthedocs/oauth/validators.py | .py | """Validators for the OAuth app."""
import re
from django.core.validators import URLValidator
from django.utils.deconstruct import deconstructible
# Pattern for ``git@github.com:user/repo`` SSH format used by GitHub, GitLab, and Bitbucket
_RE_GIT_USER_SSH = re.compile(r"^[\w.+-]+@[^:]+:[^/][^:]*$")
@deconstructib... | 48 | 1,319 |
readthedocs.org | readthedocs/oauth/management/commands/sync_vcs_data.py | .py | import datetime
import json
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.utils import timezone
from readthedocs.oauth.tasks import sync_remote_repositories
class Command(BaseCommand):
help = "Sync OAuth RemoteRepository and RemoteOrganization"
... | 129 | 4,585 |
readthedocs.org | readthedocs/oauth/management/commands/reconnect_remoterepositories.py | .py | import json
from django.core.management.base import BaseCommand
from django.db.models import Q
from django.db.models import Subquery
from readthedocs.oauth.models import RemoteRepository
from readthedocs.oauth.services import registry
from readthedocs.oauth.services.base import SyncServiceError
from readthedocs.organ... | 116 | 4,853 |
readthedocs.org | readthedocs/oauth/services/githubapp.py | .py | from functools import cached_property
from functools import lru_cache
from itertools import groupby
import structlog
from allauth.socialaccount.models import SocialAccount
from django.conf import settings
from github import Github
from github import GithubException
from github.Installation import Installation as GHIns... | 532 | 23,260 |
readthedocs.org | readthedocs/oauth/services/__init__.py | .py | """Conditional classes for OAuth services."""
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.oauth.services import bitbucket
from readthedocs.oauth.services import github
from readthedocs.oauth.services import gitlab
from readthedocs.oauth.services.githubapp import GitHubAppService
... | 35 | 941 |
readthedocs.org | readthedocs/oauth/services/base.py | .py | """OAuth utility functions."""
import re
from functools import cached_property
from typing import Iterator
import structlog
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
from django.conf import settings
from django.urls import reverse... | 337 | 11,814 |
readthedocs.org | readthedocs/oauth/services/bitbucket.py | .py | """OAuth utility functions."""
import json
import re
import structlog
from allauth.socialaccount.providers.bitbucket_oauth2.provider import BitbucketOAuth2Provider
from django.conf import settings
from requests.exceptions import RequestException
from readthedocs.builds import utils as build_utils
from readthedocs.in... | 453 | 17,442 |
readthedocs.org | readthedocs/oauth/services/github.py | .py | """OAuth utility functions."""
import json
import re
import structlog
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django.conf import settings
from oauthlib.oauth2.rfc6749.errors import InvalidGrantError
from oauthlib.oauth2.rfc6749.errors import TokenExpiredError
from requests.exce... | 555 | 21,338 |
readthedocs.org | readthedocs/oauth/services/gitlab.py | .py | """OAuth utility functions."""
import json
import re
from urllib.parse import quote_plus
from urllib.parse import urlparse
import structlog
from allauth.socialaccount.providers.gitlab.provider import GitLabProvider
from django.conf import settings
from oauthlib.oauth2.rfc6749.errors import InvalidGrantError
from oaut... | 575 | 20,052 |
readthedocs.org | readthedocs/oauth/tests/test_tasks.py | .py | from unittest import mock
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.models import SocialToken
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture impor... | 186 | 7,148 |
readthedocs.org | readthedocs/oauth/tests/test_querysets.py | .py | from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.oauth.models import RemoteRepository, RemoteRepositoryRelation
from readthedocs.projects.models import Project
class TestRemoteRepositoryQuerysets(TestCase):
def setUp(self):
... | 87 | 2,779 |
readthedocs.org | readthedocs/oauth/tests/test_models.py | .py | from django.core.exceptions import ValidationError
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.oauth.models import RemoteRepository
from readthedocs.oauth.validators import CloneURLValidator
from readthedocs.oauth.validators import SshURLValidator
from readthedocs.projects.... | 127 | 4,683 |
readthedocs.org | readthedocs/oauth/tests/test_githubapp_webhook.py | .py | import json
from unittest import mock
from readthedocs.builds.constants import ALL_VERSIONS
from readthedocs.projects.models import AutomationRule
import requests_mock
from allauth.socialaccount.models import SocialAccount
from django.conf import settings
from django.contrib.auth.models import User
from django.test im... | 1,838 | 66,915 |
readthedocs.org | readthedocs/oauth/tests/test_signals.py | .py | from unittest.mock import patch
from allauth.account.models import EmailAddress
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.allauth.providers.... | 118 | 4,708 |
readthedocs.org | readthedocs/profiles/views.py | .py | """Views for creating, editing and viewing site-specific user profiles."""
from enum import StrEnum
from enum import auto
import structlog
from allauth.account.views import LoginView as AllAuthLoginView
from allauth.account.views import LogoutView as AllAuthLogoutView
from allauth.socialaccount import providers
from ... | 478 | 17,794 |
readthedocs.org | readthedocs/profiles/urls/public.py | .py | """URL patterns to view user profiles."""
from django.urls import re_path
from readthedocs.profiles import views
urlpatterns = [
re_path(
r"^(?P<username>[+\w@.-]+)/$",
views.ProfileDetail.as_view(),
name="profiles_profile_detail",
),
]
| 15 | 273 |
readthedocs.org | readthedocs/profiles/urls/private.py | .py | """URL patterns for views to modify user profiles."""
from django.urls import path
from readthedocs.profiles import views
# Split URLs into different lists to be able to selectively import them from a
# another application (like Read the Docs Corporate), where we may don't need to
# define Token URLs, for example.
... | 77 | 1,745 |
readthedocs.org | readthedocs/profiles/tests/test_views.py | .py | from unittest import mock
import requests_mock
from allauth.socialaccount.models import SocialAccount, SocialToken
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
... | 978 | 40,157 |
readthedocs.org | readthedocs/telemetry/admin.py | .py | """Telemetry admin."""
from django.contrib import admin
from readthedocs.core.utils.admin import pretty_json_field
from readthedocs.telemetry.models import BuildData
@admin.register(BuildData)
class BuildDataAdmin(admin.ModelAdmin):
"""Admin class for BuildData model."""
fields = ("created", "modified", "p... | 39 | 1,112 |
readthedocs.org | readthedocs/telemetry/models.py | .py | """Telemetry models."""
from django.db import models
from django_extensions.db.models import TimeStampedModel
class BuildDataManager(models.Manager):
"""Manager for the BuildData model."""
def collect(self, build, data):
"""
Save the collected information from a build.
We fill other... | 121 | 3,726 |
readthedocs.org | readthedocs/telemetry/apps.py | .py | """
Telemetry application.
Collect relevant data to be analyzed later.
"""
from django.apps import AppConfig
class TelemetryConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "readthedocs.telemetry"
def ready(self):
import readthedocs.telemetry.tasks # noqa
| 16 | 312 |
readthedocs.org | readthedocs/telemetry/tasks.py | .py | """Tasks related to telemetry."""
from django.conf import settings
from django.utils import timezone
from readthedocs.builds.models import Build
from readthedocs.telemetry.models import BuildData
from readthedocs.worker import app
@app.task(queue="web")
def save_build_data(build_id, data):
"""
Save the buil... | 43 | 1,434 |
readthedocs.org | readthedocs/telemetry/collectors.py | .py | """Data collectors."""
import json
import os
import dparse
import structlog
from readthedocs.config.models import PythonInstallRequirements
from readthedocs.core.utils.filesystem import safe_open
log = structlog.get_logger(__name__)
class BuildDataCollector:
"""
Build data collector.
Collect data fr... | 371 | 12,354 |
readthedocs.org | readthedocs/telemetry/tests/test_collectors.py | .py | from textwrap import dedent
from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.config.tests.test_config import get_build_config
from readthedocs.doc_builder.environments import DockerBuildEnvironment
from readt... | 207 | 6,645 |
readthedocs.org | readthedocs/acl/utils.py | .py | from django.contrib.auth import BACKEND_SESSION_KEY
from readthedocs.acl.constants import BACKEND_REQUEST_KEY
def get_auth_backend(request):
"""
Get the current auth_backend used on this request.
By default the full qualified name of the backend class
is stored on the request session, but our intern... | 17 | 555 |
readthedocs.org | readthedocs/search/admin.py | .py | """SearchQuery Admin classes."""
from django.contrib import admin
from .models import SearchQuery
@admin.register(SearchQuery)
class SearchQueryAdmin(admin.ModelAdmin):
raw_id_fields = ("project", "version")
list_filter = ("created",)
list_display = ("__str__", "created")
search_fields = ("project__... | 16 | 468 |
readthedocs.org | readthedocs/search/utils.py | .py | """Utilities related to reading and generating indexable search content."""
import structlog
from django.utils import timezone
from django_elasticsearch_dsl.apps import DEDConfig
from django_elasticsearch_dsl.registries import registry
from readthedocs.notifications.models import Notification
from readthedocs.project... | 141 | 4,568 |
readthedocs.org | readthedocs/search/models.py | .py | """Search Queries."""
from django.db import models
from django.db.models import Count
from django.db.models.functions import TruncDate
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django_extensions.db.models import TimeStampedModel
from readthedocs.builds.models import... | 97 | 3,031 |
readthedocs.org | readthedocs/search/apps.py | .py | from django.apps import AppConfig
class SearchConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "readthedocs.search"
def ready(self):
import readthedocs.search.signals # noqa
| 10 | 228 |
readthedocs.org | readthedocs/search/faceted_search.py | .py | import re
import structlog
from elasticsearch.dsl import FacetedSearch
from elasticsearch.dsl import TermsFacet
from elasticsearch.dsl.query import Bool
from elasticsearch.dsl.query import FunctionScore
from elasticsearch.dsl.query import MultiMatch
from elasticsearch.dsl.query import Nested
from elasticsearch.dsl.que... | 411 | 13,766 |
readthedocs.org | readthedocs/search/views.py | .py | """Search views."""
import collections
from urllib.parse import urlencode
import structlog
from django.conf import settings
from django.http.response import HttpResponseRedirect
from django.urls import reverse
from django.views import View
from django.views.generic import TemplateView
from readthedocs.projects.model... | 175 | 5,734 |
readthedocs.org | readthedocs/search/signals.py | .py | """We define custom Django signals to trigger before executing searches."""
import structlog
from django.db.models.signals import post_save
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from django_elasticsearch_dsl.apps import DEDConfig
from readthedocs.projects.models import P... | 57 | 1,724 |
readthedocs.org | readthedocs/search/parsers.py | .py | """JSON/HTML parsers for search indexing."""
import hashlib
import itertools
import re
import structlog
from selectolax.parser import HTMLParser
from readthedocs.projects.constants import MEDIA_TYPE_HTML
from readthedocs.storage import build_media_storage
log = structlog.get_logger(__name__)
class GenericParser:... | 497 | 17,061 |
readthedocs.org | readthedocs/search/tasks.py | .py | import datetime
import structlog
from dateutil.parser import parse
from django.apps import apps
from django.conf import settings
from django.utils import timezone
from django_elasticsearch_dsl.registries import registry
from readthedocs.builds.models import Version
from readthedocs.projects.models import Project
from... | 228 | 8,306 |
readthedocs.org | readthedocs/search/documents.py | .py | import structlog
from django.conf import settings
from django_elasticsearch_dsl import Document
from django_elasticsearch_dsl import Index
from django_elasticsearch_dsl import fields
from elasticsearch import Elasticsearch
from readthedocs.projects.models import HTMLFile
from readthedocs.projects.models import Project... | 138 | 4,439 |
readthedocs.org | readthedocs/search/management/commands/reindex_elasticsearch.py | .py | import itertools
import sys
import textwrap
from datetime import datetime
from datetime import timedelta
import structlog
from django.apps import apps
from django.conf import settings
from django.core.management import BaseCommand
from django_elasticsearch_dsl.registries import registry
from readthedocs.builds.models... | 307 | 10,940 |
readthedocs.org | readthedocs/search/tests/test_api.py | .py | import re
from unittest import mock
import pytest
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.models import Version
from readthedocs.projects.constants import (
MKDOCS,
MKDOCS_HTML,
PUBLIC,
SPHINX,
SPHINX_HTMLDIR,
SPHINX_SINGLEHTML,
)
from rea... | 742 | 27,296 |
readthedocs.org | readthedocs/search/tests/test_views.py | .py | import re
import pytest
from django.contrib.auth.models import User
from django.test import override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Version
from readthedocs.projects.models import Pro... | 382 | 14,042 |
readthedocs.org | readthedocs/search/tests/utils.py | .py | import random
from readthedocs.projects.models import HTMLFile
SECTION_FIELDS = ["section.title", "section.content"]
DATA_TYPES_VALUES = ["title"] + SECTION_FIELDS
def get_search_query_from_project_file(
project_slug, page_num=0, field="title", type=None
):
"""
Return search query from the project's pag... | 55 | 1,539 |
readthedocs.org | readthedocs/search/tests/dummy_data.py | .py | PROJECT_DATA_FILES = {
"pipeline": ["installation", "signals"],
"kuma": ["documentation", "docker"],
"docs": ["support", "wiping", "index", "guides/index"],
}
ALL_PROJECTS = PROJECT_DATA_FILES.keys()
| 8 | 213 |
readthedocs.org | readthedocs/search/tests/test_parsers.py | .py | import json
from contextlib import contextmanager
from pathlib import Path
from unittest import mock
import pytest
from django_dynamic_fixture import get
from readthedocs.builds.storage import BuildMediaFileSystemStorage
from readthedocs.projects.constants import GENERIC, MKDOCS, SPHINX
from readthedocs.projects.mode... | 385 | 14,255 |
readthedocs.org | readthedocs/search/tests/test_xss.py | .py | import pytest
from readthedocs.search.faceted_search import PageSearch
@pytest.mark.django_db
@pytest.mark.search
class TestXSS:
def test_facted_page_xss(self, all_projects):
query = '"XSS"'
page_search = PageSearch(query=query, projects={"docs": "latest"})
results = page_search.execute()... | 30 | 883 |
readthedocs.org | readthedocs/search/tests/test_search_tasks.py | .py | """Tests for search tasks."""
from unittest import mock
import pytest
from django.urls import reverse
from django.utils import timezone
from readthedocs.search.models import SearchQuery
from readthedocs.search import tasks
@pytest.mark.django_db
@pytest.mark.search
@pytest.mark.usefixtures("all_projects")
class Te... | 113 | 4,327 |
readthedocs.org | readthedocs/search/tests/test_faceted_search.py | .py | import pytest
from readthedocs.search.faceted_search import PageSearch
@pytest.mark.django_db
@pytest.mark.search
class TestPageSearch:
@pytest.mark.parametrize("case", ["upper", "lower", "title"])
def test_search_exact_match(self, client, project, case):
"""Check quoted query match exact phrase with... | 58 | 2,290 |
readthedocs.org | readthedocs/search/tests/test_proxied_api.py | .py | import pytest
from corsheaders.middleware import ACCESS_CONTROL_ALLOW_ORIGIN
from readthedocs.search.tests.test_api import BaseTestDocumentSearch
@pytest.mark.proxito
@pytest.mark.search
class TestProxiedSearchAPI(BaseTestDocumentSearch):
# This project slug needs to exist in the ``all_projects`` fixture.
ho... | 30 | 1,037 |
readthedocs.org | readthedocs/search/tests/test_signals.py | .py | import pytest
from django.core.management import call_command
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from elasticsearch.exceptions import NotFoundError
from readthedocs.projects.models import Project
from readthedocs.search.documents import ProjectDocument
@pytest.... | 53 | 1,750 |
readthedocs.org | readthedocs/search/tests/test_utils.py | .py | import time
from unittest import mock
import pytest
from django.urls import reverse
from readthedocs.builds.constants import LATEST, STABLE
from readthedocs.projects.models import Project
from readthedocs.projects.tasks.search import index_project
from readthedocs.search import utils
from readthedocs.search.documents... | 95 | 3,512 |
readthedocs.org | readthedocs/search/tests/conftest.py | .py | import json
import os
from random import shuffle
import pytest
from django.core.management import call_command
from django_dynamic_fixture import get
from readthedocs.builds.constants import STABLE
from readthedocs.builds.models import Version
from readthedocs.projects.constants import PUBLIC
from readthedocs.project... | 100 | 2,816 |
readthedocs.org | readthedocs/search/api/pagination.py | .py | from collections import namedtuple
from math import ceil
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError
from rest_framework.pagination import PageNumberPagination
class PaginatorPage:
"""
Mimics the result from a paginator.
By using this class, we... | 107 | 3,577 |
readthedocs.org | readthedocs/search/api/v2/serializers.py | .py | """
Serializers for the ES's search result object.
.. note::
Some fields are re-named to make their meaning more clear.
They should be renamed in the ES index too.
"""
import re
from functools import namedtuple
from urllib.parse import urlparse
from rest_framework import serializers
from readthedocs.builds.mo... | 188 | 6,682 |
readthedocs.org | readthedocs/search/api/v2/views.py | .py | from functools import lru_cache
import structlog
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError
from rest_framework.generics import GenericAPIView
from readthedocs.api.mixins impor... | 213 | 7,112 |
readthedocs.org | readthedocs/search/api/v2/urls.py | .py | from django.urls import path
from readthedocs.search.api.v2.views import PageSearchAPIView
urlpatterns = [
path("", PageSearchAPIView.as_view(), name="search_api"),
]
| 9 | 174 |
readthedocs.org | readthedocs/search/api/v3/utils.py | .py | from readthedocs.projects.models import Feature
def should_use_advanced_query(projects):
# TODO: we should make this a parameter in the API,
# we are checking if the first project has this feature for now.
if projects:
project = projects[0][0]
return not project.has_feature(Feature.DEFAULT... | 11 | 354 |
readthedocs.org | readthedocs/search/api/v3/serializers.py | .py | from rest_framework import serializers
from readthedocs.search.api.v2.serializers import PageSearchSerializer as PageSearchSerializerBase
class PageSearchSerializer(PageSearchSerializerBase):
"""
Serializer for API V3.
This is very similar to the serializer from V2,
with the following changes:
... | 36 | 966 |
readthedocs.org | readthedocs/search/api/v3/executor.py | .py | from functools import cached_property
from itertools import islice
from readthedocs.builds.constants import INTERNAL
from readthedocs.projects.models import Project
from readthedocs.search.api.v3.queryparser import SearchQueryParser
from readthedocs.search.faceted_search import PageSearch
class SearchExecutor:
"... | 241 | 8,988 |
readthedocs.org | readthedocs/search/api/v3/views.py | .py | from functools import cached_property
import structlog
from django.utils import timezone
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError
from rest_framework.generics import GenericAPIView
from rest_framework.permissions import AllowAny
from rest_framework.throttl... | 179 | 5,806 |
readthedocs.org | readthedocs/search/api/v3/urls.py | .py | from django.urls import path
from readthedocs.search.api.v3.views import SearchAPI
urlpatterns = [
path("", SearchAPI.as_view(), name="search_api_v3"),
]
| 9 | 161 |
readthedocs.org | readthedocs/search/api/v3/queryparser.py | .py | class TextToken:
def __init__(self, text):
self.text = text
class ArgumentToken:
def __init__(self, *, name, value, type):
self.name = name
self.value = value
self.type = type
class SearchQueryParser:
"""Simplified and minimal parser for ``name:value`` expressions."""
... | 77 | 2,370 |
readthedocs.org | readthedocs/search/api/v3/tests/test_api.py | .py | import itertools
from unittest import mock
import pytest
from django.contrib.auth.models import User
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.models import Version
... | 951 | 36,314 |
readthedocs.org | readthedocs/search/api/v3/tests/test_queryparser.py | .py | from django.test import TestCase
from readthedocs.search.api.v3.queryparser import SearchQueryParser
class TestQueryParser(TestCase):
def test_no_arguments(self):
parser = SearchQueryParser("search query")
parser.parse()
arguments = parser.arguments
self.assertEqual(arguments["pro... | 87 | 3,530 |
readthedocs.org | readthedocs/rtd_tests/utils.py | .py | """Utility functions for use in tests."""
import subprocess
import textwrap
from os import chdir, environ, mkdir
from os.path import abspath
from os.path import join as pjoin
from shutil import copytree
from tempfile import mkdtemp
import structlog
from django.contrib.auth.models import User
from django_dynamic_fixtu... | 248 | 6,825 |
readthedocs.org | readthedocs/rtd_tests/storage.py | .py | from readthedocs.builds.storage import BuildMediaFileSystemStorage
class BuildMediaFileSystemStorageTest(BuildMediaFileSystemStorage):
internal_redirect_root_path = "proxito"
def exists(self, *args, **kargs):
return True
class StaticFileSystemStorageTest(BuildMediaFileSystemStorageTest):
intern... | 13 | 361 |
readthedocs.org | readthedocs/rtd_tests/base.py | .py | """Base classes and mixins for unit tests."""
import structlog
from collections import OrderedDict
from unittest.mock import patch
from django.contrib.auth.models import AnonymousUser
from django.contrib.messages.storage.fallback import FallbackStorage
from django.contrib.sessions.middleware import SessionMiddleware
f... | 143 | 4,790 |
readthedocs.org | readthedocs/rtd_tests/files/conf.py | .py | # -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
from datetime import datetime
from recommonmark.parser import CommonMarkParser
extensions = []
templates_path = ["templates", "_templates", ".templates"]
source_suffix = [".rst", ".md"]
source_parsers = {
".md": CommonMark... | 28 | 668 |
readthedocs.org | readthedocs/rtd_tests/tests/test_api_permissions.py | .py | from functools import partial
from unittest import TestCase
from unittest.mock import Mock
from readthedocs.api.v2.permissions import ReadOnlyPermission
class APIRestrictedPermissionTests(TestCase):
def get_request(self, method, is_admin):
request = Mock()
request.method = method
request... | 71 | 2,337 |
readthedocs.org | readthedocs/rtd_tests/tests/test_api.py | .py | import datetime
import json
from unittest import mock
import dateutil
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django_dynamic_fixture impo... | 3,677 | 135,872 |
readthedocs.org | readthedocs/rtd_tests/tests/test_views.py | .py | import csv
from unittest import mock
from urllib.parse import urlsplit
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django_dynamic_fixture import get, new
from readthedocs.builds.constants import ... | 303 | 10,919 |
readthedocs.org | readthedocs/rtd_tests/tests/test_version_slug.py | .py | import re
from django.test import TestCase
from readthedocs.builds.models import Version
from readthedocs.builds.version_slug import VERSION_SLUG_REGEX, _uniquifying_suffix
from readthedocs.projects.models import Project
class VersionSlugPatternTests(TestCase):
pattern = re.compile("^{pattern}$".format(pattern=... | 118 | 3,602 |
readthedocs.org | readthedocs/rtd_tests/tests/test_version_commit_name.py | .py | from django.test import TestCase
from django_dynamic_fixture import get, new
from readthedocs.builds.constants import BRANCH, EXTERNAL, LATEST, STABLE, TAG
from readthedocs.builds.models import Version
from readthedocs.projects.constants import REPO_TYPE_GIT
from readthedocs.projects.models import Project
class Vers... | 138 | 4,320 |
readthedocs.org | readthedocs/rtd_tests/tests/test_notifications.py | .py | """Notification tests."""
from unittest import mock
import django_dynamic_fixture as fixture
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.builds.models import Build
from readthedocs.noti... | 104 | 3,427 |
readthedocs.org | readthedocs/rtd_tests/tests/test_backend.py | .py | import os
import textwrap
from readthedocs.core.utils.filesystem import safe_rmtree
from os.path import exists
from unittest import mock
from unittest.mock import Mock, patch
import django_dynamic_fixture as fixture
from django_dynamic_fixture import get
from django.contrib.auth.models import User
from django.test imp... | 447 | 15,260 |
readthedocs.org | readthedocs/rtd_tests/tests/test_automation_rule_views.py | .py | import pytest
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.constants import (
ALL_VERSIONS,
BRANCH,
CUSTOM_MATCH,
TAG,
)
from readthedocs.organizations.models import Organization
from readthedocs.projects.models import AutomationRule, Project
@pytest.... | 471 | 16,211 |
readthedocs.org | readthedocs/rtd_tests/tests/test_single_version.py | .py | import django_dynamic_fixture as fixture
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.projects.constants import (
MULTIPLE_VERSIONS_WITH_TRANSLATIONS,
SINGLE_VERSION_WITHOUT_TRANSLATIONS,
)
from readthedocs.projects.models import Project
@override_settings... | 37 | 1,050 |
readthedocs.org | readthedocs/rtd_tests/tests/test_imported_file.py | .py | import os
from unittest import mock
import pytest
from django.core.files.storage import storages
from django.test import TestCase
from django.test.utils import override_settings
from django_dynamic_fixture import get
from readthedocs.builds.constants import BUILD_STATE_FINISHED, EXTERNAL, LATEST
from readthedocs.buil... | 404 | 13,772 |
readthedocs.org | readthedocs/rtd_tests/tests/test_managers.py | .py | from django.contrib.auth import get_user_model
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.builds.constants import EXTERNAL
from readthedocs.builds.models import Build, Version
from readthedocs.projects.constants import PRIVATE, PUBLIC
from readthedocs.projects.models impor... | 332 | 10,761 |
readthedocs.org | readthedocs/rtd_tests/tests/test_project_forms.py | .py | from unittest import mock
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django.contrib.auth.models import User
from django.core.exceptions import NON_FIELD_ERRORS
from django.test import TestCase
from django.test.utils import over... | 1,546 | 57,647 |
readthedocs.org | readthedocs/rtd_tests/tests/test_builds.py | .py | import datetime
from django.contrib.auth.models import User
from django.test import TestCase
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.builds.constants import (
BRANCH,
EXTERNAL,
GENERIC_EXTERNAL_VERSION_NAME,
GITHUB_EXTERNAL_VERSION_NAME,
GITLAB_EXT... | 314 | 9,281 |
readthedocs.org | readthedocs/rtd_tests/tests/test_oauth.py | .py | import copy
import json
from unittest import mock
from allauth.socialaccount.providers.bitbucket_oauth2.provider import BitbucketOAuth2Provider
from allauth.socialaccount.providers.gitlab.provider import GitLabProvider
import requests_mock
from allauth.socialaccount.models import SocialAccount, SocialToken
from allaut... | 3,562 | 142,578 |
readthedocs.org | readthedocs/rtd_tests/tests/test_projects_tasks.py | .py | import datetime
from unittest.mock import patch
from django.test import TestCase
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.builds.constants import (
BUILD_STATUS_SUCCESS,
BUILD_STATE_CLONING,
BUILD_STATE_CANCELLED,
BUILD_STATE_TRIGGERED,
EXTERNAL,
)... | 108 | 3,735 |
readthedocs.org | readthedocs/rtd_tests/tests/test_restapi_client.py | .py | from django.test import TestCase
from readthedocs.api.v2.client import DrfJsonSerializer
class TestDrfJsonSerializer(TestCase):
data = {
"proper": "json",
}
serialized_data = '{"proper":"json"}'
def test_serializer_loads_json(self):
serializer = DrfJsonSerializer()
data = ser... | 21 | 608 |
readthedocs.org | readthedocs/rtd_tests/tests/test_project_views.py | .py | from unittest import mock
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.http.response import HttpResponseRedirect
from django.test import TestCase, override_settings
from django.urls import reverse
from django.views.generic.base import ContextMixin
from ... | 833 | 30,820 |
readthedocs.org | readthedocs/rtd_tests/tests/test_build_forms.py | .py | from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.forms import VersionForm
from readthedocs.builds.models import Version
from readthedocs.projects.cons... | 368 | 11,116 |
readthedocs.org | readthedocs/rtd_tests/tests/test_celery.py | .py | from unittest.mock import patch
import pytest
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider
from readthedocs.build... | 317 | 12,442 |
readthedocs.org | readthedocs/rtd_tests/tests/test_automation_rules.py | .py | from unittest import mock
import pytest
from django_dynamic_fixture import get
from readthedocs.api.v2.utils import run_version_automation_rules
from readthedocs.builds.constants import (
ALL_VERSIONS,
BRANCH,
CUSTOM_MATCH,
EXTERNAL,
LATEST,
SEMVER_VERSIONS,
TAG,
)
from readthedocs.builds.... | 996 | 32,372 |
readthedocs.org | readthedocs/rtd_tests/tests/test_privacy_urls.py | .py | import re
from unittest import mock
from allauth.socialaccount.models import SocialAccount
from django.contrib.admindocs.views import extract_views_from_urlpatterns
from django.test import TestCase
from django.urls import reverse
from django_dynamic_fixture import get
from taggit.models import Tag
from readthedocs.bu... | 588 | 20,597 |
readthedocs.org | readthedocs/rtd_tests/tests/test_core_tags.py | .py | from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.builds.constants import LATEST
from readthedocs.core.templatetags import core_tags
from readthedocs.projects.models import Project
@override_settings(PRODUCTION_DOMAIN="readthedocs.org",... | 109 | 4,752 |
readthedocs.org | readthedocs/rtd_tests/tests/test_oauth_tasks.py | .py | from unittest.mock import patch
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.providers.bitbucket_oauth2.views import (
BitbucketOAuth2Adapter,
)
from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
from allauth.socialaccount.providers.gitlab.views import... | 195 | 7,849 |
readthedocs.org | readthedocs/rtd_tests/tests/test_middleware.py | .py | from corsheaders.middleware import (
ACCESS_CONTROL_ALLOW_CREDENTIALS,
ACCESS_CONTROL_ALLOW_ORIGIN,
)
from django.test import TestCase, override_settings
from django.test.client import RequestFactory
from django_dynamic_fixture import get
from readthedocs.builds.constants import LATEST
from readthedocs.core.mi... | 254 | 9,655 |
readthedocs.org | readthedocs/rtd_tests/tests/test_core_utils.py | .py | """Test core util functions."""
from unittest import mock
import pytest
from django.conf import settings
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from readthedocs.builds.constants import BUILD_STATE_BUILDING, LATEST
from readthedocs.builds.models import Build, Version... | 243 | 8,540 |
readthedocs.org | readthedocs/rtd_tests/tests/test_project.py | .py | import datetime
import json
from unittest import mock
from unittest.mock import patch
import pytest
from django.contrib.auth.models import User
from django.forms.models import model_to_dict
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from django_dynamic_fixture im... | 589 | 20,870 |
readthedocs.org | readthedocs/rtd_tests/tests/test_version.py | .py | from django.test import TestCase
from django.test.utils import override_settings
from django_dynamic_fixture import get
from readthedocs.builds.constants import BRANCH, EXTERNAL, LATEST, STABLE, TAG
from readthedocs.builds.models import Version
from readthedocs.projects.models import Project
class VersionMixin:
... | 158 | 5,657 |
readthedocs.org | readthedocs/rtd_tests/tests/test_build_notifications.py | .py | """Notifications sent after build is completed."""
import hashlib
import hmac
import json
from unittest import mock
import requests_mock
from django.core import mail
from django.test import TestCase, override_settings
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.builds.con... | 364 | 13,887 |
readthedocs.org | readthedocs/rtd_tests/tests/test_urls.py | .py | from django.test import TestCase
from django.urls import reverse
class TestProfileDetailURLs(TestCase):
def test_profile_detail_url(self):
url = reverse(
"profiles_profile_detail",
kwargs={"username": "foo+bar"},
)
self.assertEqual(url, "/profiles/foo+bar/")
... | 24 | 675 |
readthedocs.org | readthedocs/rtd_tests/tests/test_privacy.py | .py | from unittest import mock
import structlog
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Build, Version
from readthedocs.projects.models import Project
... | 400 | 14,987 |
readthedocs.org | readthedocs/rtd_tests/tests/test_version_querysets.py | .py | from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.builds.constants import EXTERNAL, INTERNAL, LATEST
from readthedocs.builds.models import Version
from readthedocs.projects.constants import PRIVATE, PUBLIC
from readthedocs.projects.mode... | 364 | 11,868 |
readthedocs.org | readthedocs/rtd_tests/tests/test_project_querysets.py | .py | from datetime import timedelta
import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from readthedocs.organizations.models import Organization
from readthedocs.projects.constants import PRIVATE, P... | 290 | 10,044 |
readthedocs.org | readthedocs/rtd_tests/tests/test_subprojects.py | .py | import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase
from readthedocs.projects.forms import ProjectRelationshipForm
from readthedocs.projects.models import Project, ProjectRelationship
class SubprojectFormTests(TestCase):
def setUp(self):
s... | 307 | 10,346 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.