Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
urlsafe_b64decode | (data) | urlsafe_b64decode without padding | urlsafe_b64decode without padding | def urlsafe_b64decode(data):
"""urlsafe_b64decode without padding"""
pad = b'=' * (4 - (len(data) & 3))
return base64.urlsafe_b64decode(data + pad) | [
"def",
"urlsafe_b64decode",
"(",
"data",
")",
":",
"pad",
"=",
"b'='",
"*",
"(",
"4",
"-",
"(",
"len",
"(",
"data",
")",
"&",
"3",
")",
")",
"return",
"base64",
".",
"urlsafe_b64decode",
"(",
"data",
"+",
"pad",
")"
] | [
30,
0
] | [
33,
47
] | python | en | ['en', 'jv', 'en'] | True |
DatabaseOperations.adapt_datefield_value | (self, value) |
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
The default implementation transforms the date to text, but that is not
necessary for Oracle.
|
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
The default implementation transforms the date to text, but that is not
necessary for Oracle.
| def adapt_datefield_value(self, value):
"""
Transform a date value to an object compatible with what is expected
by the backend driver for date columns.
The default implementation transforms the date to text, but that is not
necessary for Oracle.
"""
return value | [
"def",
"adapt_datefield_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
498,
4
] | [
505,
20
] | python | en | ['en', 'error', 'th'] | False |
DatabaseOperations.adapt_datetimefield_value | (self, value) |
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
If naive datetime is passed assumes that is in UTC. Normally Django
models.DateTimeField makes sure that if USE_TZ is True passed datetime
is timezone aware.
... |
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns. | def adapt_datetimefield_value(self, value):
"""
Transform a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
If naive datetime is passed assumes that is in UTC. Normally Django
models.DateTimeField makes sure that if USE_TZ... | [
"def",
"adapt_datetimefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"# Expression values are adapted by the database.",
"if",
"hasattr",
"(",
"value",
",",
"'resolve_expression'",
")",
":",
"return",
"value",
... | [
507,
4
] | [
531,
51
] | python | en | ['en', 'error', 'th'] | False |
DatabaseOperations._get_no_autofield_sequence_name | (self, table) |
Manually created sequence name to keep backward compatibility for
AutoFields that aren't Oracle identity columns.
|
Manually created sequence name to keep backward compatibility for
AutoFields that aren't Oracle identity columns.
| def _get_no_autofield_sequence_name(self, table):
"""
Manually created sequence name to keep backward compatibility for
AutoFields that aren't Oracle identity columns.
"""
name_length = self.max_name_length() - 3
return '%s_SQ' % truncate_name(strip_quotes(table), name_le... | [
"def",
"_get_no_autofield_sequence_name",
"(",
"self",
",",
"table",
")",
":",
"name_length",
"=",
"self",
".",
"max_name_length",
"(",
")",
"-",
"3",
"return",
"'%s_SQ'",
"%",
"truncate_name",
"(",
"strip_quotes",
"(",
"table",
")",
",",
"name_length",
")",
... | [
567,
4
] | [
573,
80
] | python | en | ['en', 'error', 'th'] | False |
DatabaseOperations.bulk_batch_size | (self, fields, objs) | Oracle restricts the number of parameters in a query. | Oracle restricts the number of parameters in a query. | def bulk_batch_size(self, fields, objs):
"""Oracle restricts the number of parameters in a query."""
if fields:
return self.connection.features.max_query_params // len(fields)
return len(objs) | [
"def",
"bulk_batch_size",
"(",
"self",
",",
"fields",
",",
"objs",
")",
":",
"if",
"fields",
":",
"return",
"self",
".",
"connection",
".",
"features",
".",
"max_query_params",
"//",
"len",
"(",
"fields",
")",
"return",
"len",
"(",
"objs",
")"
] | [
613,
4
] | [
617,
24
] | python | en | ['en', 'en', 'en'] | True |
DatabaseOperations.conditional_expression_supported_in_where_clause | (self, expression) |
Oracle supports only EXISTS(...) or filters in the WHERE clause, others
must be compared with True.
|
Oracle supports only EXISTS(...) or filters in the WHERE clause, others
must be compared with True.
| def conditional_expression_supported_in_where_clause(self, expression):
"""
Oracle supports only EXISTS(...) or filters in the WHERE clause, others
must be compared with True.
"""
if isinstance(expression, Exists):
return True
if isinstance(expression, Express... | [
"def",
"conditional_expression_supported_in_where_clause",
"(",
"self",
",",
"expression",
")",
":",
"if",
"isinstance",
"(",
"expression",
",",
"Exists",
")",
":",
"return",
"True",
"if",
"isinstance",
"(",
"expression",
",",
"ExpressionWrapper",
")",
"and",
"isi... | [
619,
4
] | [
630,
20
] | python | en | ['en', 'error', 'th'] | False |
url_params_from_lookup_dict | (lookups) |
Converts the type of lookups specified in a ForeignKey limit_choices_to
attribute to a dictionary of query parameters
|
Converts the type of lookups specified in a ForeignKey limit_choices_to
attribute to a dictionary of query parameters
| def url_params_from_lookup_dict(lookups):
"""
Converts the type of lookups specified in a ForeignKey limit_choices_to
attribute to a dictionary of query parameters
"""
params = {}
if lookups and hasattr(lookups, 'items'):
items = []
for k, v in lookups.items():
if cal... | [
"def",
"url_params_from_lookup_dict",
"(",
"lookups",
")",
":",
"params",
"=",
"{",
"}",
"if",
"lookups",
"and",
"hasattr",
"(",
"lookups",
",",
"'items'",
")",
":",
"items",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"lookups",
".",
"items",
"(",
")... | [
114,
0
] | [
134,
17
] | python | en | ['en', 'error', 'th'] | False |
AdminRadioFieldRenderer.render | (self) | Outputs a <ul> for this set of radio fields. | Outputs a <ul> for this set of radio fields. | def render(self):
"""Outputs a <ul> for this set of radio fields."""
return format_html('<ul{0}>\n{1}\n</ul>',
flatatt(self.attrs),
format_html_join('\n', '<li>{0}</li>',
((force_text(w),) for w in self))) | [
"def",
"render",
"(",
"self",
")",
":",
"return",
"format_html",
"(",
"'<ul{0}>\\n{1}\\n</ul>'",
",",
"flatatt",
"(",
"self",
".",
"attrs",
")",
",",
"format_html_join",
"(",
"'\\n'",
",",
"'<li>{0}</li>'",
",",
"(",
"(",
"force_text",
"(",
"w",
")",
",",
... | [
95,
4
] | [
100,
78
] | python | en | ['en', 'en', 'en'] | True |
RelatedFieldWidgetWrapper.build_attrs | (self, extra_attrs=None, **kwargs) | Helper function for building an attribute dictionary. | Helper function for building an attribute dictionary. | def build_attrs(self, extra_attrs=None, **kwargs):
"Helper function for building an attribute dictionary."
self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs)
return self.attrs | [
"def",
"build_attrs",
"(",
"self",
",",
"extra_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"attrs",
"=",
"self",
".",
"widget",
".",
"build_attrs",
"(",
"extra_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"return",
"sel... | [
278,
4
] | [
281,
25
] | python | en | ['en', 'en', 'en'] | True |
_get_dist | (metadata_directory) | Return a pkg_resources.Distribution for the provided
metadata directory.
| Return a pkg_resources.Distribution for the provided
metadata directory.
| def _get_dist(metadata_directory):
# type: (str) -> Distribution
"""Return a pkg_resources.Distribution for the provided
metadata directory.
"""
dist_dir = metadata_directory.rstrip(os.sep)
# Build a PathMetadata object, from path to metadata. :wink:
base_dir, dist_dir_name = os.path.split(... | [
"def",
"_get_dist",
"(",
"metadata_directory",
")",
":",
"# type: (str) -> Distribution",
"dist_dir",
"=",
"metadata_directory",
".",
"rstrip",
"(",
"os",
".",
"sep",
")",
"# Build a PathMetadata object, from path to metadata. :wink:",
"base_dir",
",",
"dist_dir_name",
"=",... | [
65,
0
] | [
89,
5
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.format_debug | (self) | An un-tested helper for getting state, for debugging.
| An un-tested helper for getting state, for debugging.
| def format_debug(self):
# type: () -> str
"""An un-tested helper for getting state, for debugging.
"""
attributes = vars(self)
names = sorted(attributes)
state = (
"{}={!r}".format(attr, attributes[attr]) for attr in sorted(names)
)
return '<{... | [
"def",
"format_debug",
"(",
"self",
")",
":",
"# type: () -> str",
"attributes",
"=",
"vars",
"(",
"self",
")",
"names",
"=",
"sorted",
"(",
"attributes",
")",
"state",
"=",
"(",
"\"{}={!r}\"",
".",
"format",
"(",
"attr",
",",
"attributes",
"[",
"attr",
... | [
235,
4
] | [
248,
9
] | python | en | ['da', 'en', 'en'] | True |
InstallRequirement.is_pinned | (self) | Return whether I am pinned to an exact version.
For example, some-package==1.2 is pinned; some-package>1.2 is not.
| Return whether I am pinned to an exact version. | def is_pinned(self):
# type: () -> bool
"""Return whether I am pinned to an exact version.
For example, some-package==1.2 is pinned; some-package>1.2 is not.
"""
specifiers = self.specifier
return (len(specifiers) == 1 and
next(iter(specifiers)).operator ... | [
"def",
"is_pinned",
"(",
"self",
")",
":",
"# type: () -> bool",
"specifiers",
"=",
"self",
".",
"specifier",
"return",
"(",
"len",
"(",
"specifiers",
")",
"==",
"1",
"and",
"next",
"(",
"iter",
"(",
"specifiers",
")",
")",
".",
"operator",
"in",
"{",
... | [
264,
4
] | [
272,
65
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.has_hash_options | (self) | Return whether any known-good hashes are specified as options.
These activate --require-hashes mode; hashes specified as part of a
URL do not.
| Return whether any known-good hashes are specified as options. | def has_hash_options(self):
# type: () -> bool
"""Return whether any known-good hashes are specified as options.
These activate --require-hashes mode; hashes specified as part of a
URL do not.
"""
return bool(self.hash_options) | [
"def",
"has_hash_options",
"(",
"self",
")",
":",
"# type: () -> bool",
"return",
"bool",
"(",
"self",
".",
"hash_options",
")"
] | [
293,
4
] | [
301,
38
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.hashes | (self, trust_internet=True) | Return a hash-comparer that considers my option- and URL-based
hashes to be known-good.
Hashes in URLs--ones embedded in the requirements file, not ones
downloaded from an index server--are almost peers with ones from
flags. They satisfy --require-hashes (whether it was implicitly or
... | Return a hash-comparer that considers my option- and URL-based
hashes to be known-good. | def hashes(self, trust_internet=True):
# type: (bool) -> Hashes
"""Return a hash-comparer that considers my option- and URL-based
hashes to be known-good.
Hashes in URLs--ones embedded in the requirements file, not ones
downloaded from an index server--are almost peers with ones... | [
"def",
"hashes",
"(",
"self",
",",
"trust_internet",
"=",
"True",
")",
":",
"# type: (bool) -> Hashes",
"good_hashes",
"=",
"self",
".",
"hash_options",
".",
"copy",
"(",
")",
"link",
"=",
"self",
".",
"link",
"if",
"trust_internet",
"else",
"self",
".",
"... | [
303,
4
] | [
323,
34
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.from_path | (self) | Format a nice indicator to show where this "comes from"
| Format a nice indicator to show where this "comes from"
| def from_path(self):
# type: () -> Optional[str]
"""Format a nice indicator to show where this "comes from"
"""
if self.req is None:
return None
s = str(self.req)
if self.comes_from:
if isinstance(self.comes_from, six.string_types):
... | [
"def",
"from_path",
"(",
"self",
")",
":",
"# type: () -> Optional[str]",
"if",
"self",
".",
"req",
"is",
"None",
":",
"return",
"None",
"s",
"=",
"str",
"(",
"self",
".",
"req",
")",
"if",
"self",
".",
"comes_from",
":",
"if",
"isinstance",
"(",
"self... | [
325,
4
] | [
339,
16
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement._set_requirement | (self) | Set requirement after generating metadata.
| Set requirement after generating metadata.
| def _set_requirement(self):
# type: () -> None
"""Set requirement after generating metadata.
"""
assert self.req is None
assert self.metadata is not None
assert self.source_dir is not None
# Construct a Requirement object from the generated metadata
if is... | [
"def",
"_set_requirement",
"(",
"self",
")",
":",
"# type: () -> None",
"assert",
"self",
".",
"req",
"is",
"None",
"assert",
"self",
".",
"metadata",
"is",
"not",
"None",
"assert",
"self",
".",
"source_dir",
"is",
"not",
"None",
"# Construct a Requirement objec... | [
376,
4
] | [
396,
9
] | python | en | ['da', 'en', 'en'] | True |
InstallRequirement.check_if_exists | (self, use_user_site) | Find an installed distribution that satisfies or conflicts
with this requirement, and set self.satisfied_by or
self.should_reinstall appropriately.
| Find an installed distribution that satisfies or conflicts
with this requirement, and set self.satisfied_by or
self.should_reinstall appropriately.
| def check_if_exists(self, use_user_site):
# type: (bool) -> None
"""Find an installed distribution that satisfies or conflicts
with this requirement, and set self.satisfied_by or
self.should_reinstall appropriately.
"""
if self.req is None:
return
# ge... | [
"def",
"check_if_exists",
"(",
"self",
",",
"use_user_site",
")",
":",
"# type: (bool) -> None",
"if",
"self",
".",
"req",
"is",
"None",
":",
"return",
"# get_distribution() will resolve the entire list of requirements",
"# anyway, and we've already determined that we need the re... | [
414,
4
] | [
453,
40
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.load_pyproject_toml | (self) | Load the pyproject.toml file.
After calling this routine, all of the attributes related to PEP 517
processing for this requirement have been set. In particular, the
use_pep517 attribute can be used to determine whether we should
follow the PEP 517 or legacy (setup.py) code path.
... | Load the pyproject.toml file. | def load_pyproject_toml(self):
# type: () -> None
"""Load the pyproject.toml file.
After calling this routine, all of the attributes related to PEP 517
processing for this requirement have been set. In particular, the
use_pep517 attribute can be used to determine whether we shou... | [
"def",
"load_pyproject_toml",
"(",
"self",
")",
":",
"# type: () -> None",
"pyproject_toml_data",
"=",
"load_pyproject_toml",
"(",
"self",
".",
"use_pep517",
",",
"self",
".",
"pyproject_toml_path",
",",
"self",
".",
"setup_py_path",
",",
"str",
"(",
"self",
")",
... | [
489,
4
] | [
515,
9
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement._generate_metadata | (self) | Invokes metadata generator functions, with the required arguments.
| Invokes metadata generator functions, with the required arguments.
| def _generate_metadata(self):
# type: () -> str
"""Invokes metadata generator functions, with the required arguments.
"""
if not self.use_pep517:
assert self.unpacked_source_directory
return generate_metadata_legacy(
build_env=self.build_env,
... | [
"def",
"_generate_metadata",
"(",
"self",
")",
":",
"# type: () -> str",
"if",
"not",
"self",
".",
"use_pep517",
":",
"assert",
"self",
".",
"unpacked_source_directory",
"return",
"generate_metadata_legacy",
"(",
"build_env",
"=",
"self",
".",
"build_env",
",",
"s... | [
517,
4
] | [
537,
9
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.prepare_metadata | (self) | Ensure that project metadata is available.
Under PEP 517, call the backend hook to prepare the metadata.
Under legacy processing, call setup.py egg-info.
| Ensure that project metadata is available. | def prepare_metadata(self):
# type: () -> None
"""Ensure that project metadata is available.
Under PEP 517, call the backend hook to prepare the metadata.
Under legacy processing, call setup.py egg-info.
"""
assert self.source_dir
with indent_log():
... | [
"def",
"prepare_metadata",
"(",
"self",
")",
":",
"# type: () -> None",
"assert",
"self",
".",
"source_dir",
"with",
"indent_log",
"(",
")",
":",
"self",
".",
"metadata_directory",
"=",
"self",
".",
"_generate_metadata",
"(",
")",
"# Act on the newly generated metad... | [
539,
4
] | [
557,
44
] | python | en | ['en', 'en', 'en'] | True |
InstallRequirement.ensure_has_source_dir | (self, parent_dir, autodelete=False) | Ensure that a source_dir is set.
This will create a temporary build dir if the name of the requirement
isn't known yet.
:param parent_dir: The ideal pip parent_dir for the source_dir.
Generally src_dir for editables and build_dir for sdists.
:return: self.source_dir
... | Ensure that a source_dir is set. | def ensure_has_source_dir(self, parent_dir, autodelete=False):
# type: (str, bool) -> None
"""Ensure that a source_dir is set.
This will create a temporary build dir if the name of the requirement
isn't known yet.
:param parent_dir: The ideal pip parent_dir for the source_dir.
... | [
"def",
"ensure_has_source_dir",
"(",
"self",
",",
"parent_dir",
",",
"autodelete",
"=",
"False",
")",
":",
"# type: (str, bool) -> None",
"if",
"self",
".",
"source_dir",
"is",
"None",
":",
"self",
".",
"source_dir",
"=",
"self",
".",
"ensure_build_location",
"(... | [
590,
4
] | [
604,
13
] | python | en | ['en', 'fr', 'en'] | True |
InstallRequirement.uninstall | (self, auto_confirm=False, verbose=False) |
Uninstall the distribution currently satisfying this requirement.
Prompts before removing or modifying files unless
``auto_confirm`` is True.
Refuses to delete or modify files outside of ``sys.prefix`` -
thus uninstallation within a virtual environment can only
modify ... |
Uninstall the distribution currently satisfying this requirement. | def uninstall(self, auto_confirm=False, verbose=False):
# type: (bool, bool) -> Optional[UninstallPathSet]
"""
Uninstall the distribution currently satisfying this requirement.
Prompts before removing or modifying files unless
``auto_confirm`` is True.
Refuses to delete... | [
"def",
"uninstall",
"(",
"self",
",",
"auto_confirm",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"# type: (bool, bool) -> Optional[UninstallPathSet]",
"assert",
"self",
".",
"req",
"try",
":",
"dist",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
... | [
651,
4
] | [
676,
34
] | python | en | ['en', 'error', 'th'] | False |
InstallRequirement.archive | (self, build_dir) | Saves archive to provided build_dir.
Used for saving downloaded VCS requirements as part of `pip download`.
| Saves archive to provided build_dir. | def archive(self, build_dir):
# type: (str) -> None
"""Saves archive to provided build_dir.
Used for saving downloaded VCS requirements as part of `pip download`.
"""
assert self.source_dir
create_archive = True
archive_name = '{}-{}.zip'.format(self.name, self.... | [
"def",
"archive",
"(",
"self",
",",
"build_dir",
")",
":",
"# type: (str) -> None",
"assert",
"self",
".",
"source_dir",
"create_archive",
"=",
"True",
"archive_name",
"=",
"'{}-{}.zip'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"metadata",
... | [
695,
4
] | [
754,
59
] | python | en | ['en', 'en', 'en'] | True |
participant_from_submission_path | (submission_path) | Parses type of participant based on submission filename.
Args:
submission_path: path to the submission in Google Cloud Storage
Returns:
dict with one element. Element key correspond to type of participant
(team, baseline), element value is ID of the participant.
Raises:
ValueError... | Parses type of participant based on submission filename. | def participant_from_submission_path(submission_path):
"""Parses type of participant based on submission filename.
Args:
submission_path: path to the submission in Google Cloud Storage
Returns:
dict with one element. Element key correspond to type of participant
(team, baseline), element... | [
"def",
"participant_from_submission_path",
"(",
"submission_path",
")",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"submission_path",
")",
"file_ext",
"=",
"None",
"for",
"e",
"in",
"ALLOWED_EXTENSIONS",
":",
"if",
"basename",
".",
"endswith"... | [
34,
0
] | [
60,
67
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.__init__ | (self, datastore_client, storage_client, round_name) | Initializes CompetitionSubmissions.
Args:
datastore_client: instance of CompetitionDatastoreClient
storage_client: instance of CompetitionStorageClient
round_name: name of the round
| Initializes CompetitionSubmissions. | def __init__(self, datastore_client, storage_client, round_name):
"""Initializes CompetitionSubmissions.
Args:
datastore_client: instance of CompetitionDatastoreClient
storage_client: instance of CompetitionStorageClient
round_name: name of the round
"""
se... | [
"def",
"__init__",
"(",
"self",
",",
"datastore_client",
",",
"storage_client",
",",
"round_name",
")",
":",
"self",
".",
"_datastore_client",
"=",
"datastore_client",
"self",
".",
"_storage_client",
"=",
"storage_client",
"self",
".",
"_round_name",
"=",
"round_n... | [
79,
4
] | [
95,
29
] | python | en | ['en', 'en', 'en'] | False |
CompetitionSubmissions._load_submissions_from_datastore_dir | (self, dir_suffix, id_pattern) | Loads list of submissions from the directory.
Args:
dir_suffix: suffix of the directory where submissions are stored,
one of the folowing constants: ATTACK_SUBDIR, TARGETED_ATTACK_SUBDIR
or DEFENSE_SUBDIR.
id_pattern: pattern which is used to generate (internal) IDs
... | Loads list of submissions from the directory. | def _load_submissions_from_datastore_dir(self, dir_suffix, id_pattern):
"""Loads list of submissions from the directory.
Args:
dir_suffix: suffix of the directory where submissions are stored,
one of the folowing constants: ATTACK_SUBDIR, TARGETED_ATTACK_SUBDIR
or DEFE... | [
"def",
"_load_submissions_from_datastore_dir",
"(",
"self",
",",
"dir_suffix",
",",
"id_pattern",
")",
":",
"submissions",
"=",
"self",
".",
"_storage_client",
".",
"list_blobs",
"(",
"prefix",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_round_nam... | [
97,
4
] | [
119,
9
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.init_from_storage_write_to_datastore | (self) | Init list of sumibssions from Storage and saves them to Datastore.
Should be called only once (typically by master) during evaluation of
the competition.
| Init list of sumibssions from Storage and saves them to Datastore. | def init_from_storage_write_to_datastore(self):
"""Init list of sumibssions from Storage and saves them to Datastore.
Should be called only once (typically by master) during evaluation of
the competition.
"""
# Load submissions
self._attacks = self._load_submissions_from... | [
"def",
"init_from_storage_write_to_datastore",
"(",
"self",
")",
":",
"# Load submissions",
"self",
".",
"_attacks",
"=",
"self",
".",
"_load_submissions_from_datastore_dir",
"(",
"ATTACK_SUBDIR",
",",
"ATTACK_ID_PATTERN",
")",
"self",
".",
"_targeted_attacks",
"=",
"se... | [
121,
4
] | [
137,
34
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions._write_to_datastore | (self) | Writes all submissions to datastore. | Writes all submissions to datastore. | def _write_to_datastore(self):
"""Writes all submissions to datastore."""
# Populate datastore
roots_and_submissions = zip(
[ATTACKS_ENTITY_KEY, TARGET_ATTACKS_ENTITY_KEY, DEFENSES_ENTITY_KEY],
[self._attacks, self._targeted_attacks, self._defenses],
)
cli... | [
"def",
"_write_to_datastore",
"(",
"self",
")",
":",
"# Populate datastore",
"roots_and_submissions",
"=",
"zip",
"(",
"[",
"ATTACKS_ENTITY_KEY",
",",
"TARGET_ATTACKS_ENTITY_KEY",
",",
"DEFENSES_ENTITY_KEY",
"]",
",",
"[",
"self",
".",
"_attacks",
",",
"self",
".",
... | [
139,
4
] | [
156,
37
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.init_from_datastore | (self) | Init list of submission from Datastore.
Should be called by each worker during initialization.
| Init list of submission from Datastore. | def init_from_datastore(self):
"""Init list of submission from Datastore.
Should be called by each worker during initialization.
"""
self._attacks = {}
self._targeted_attacks = {}
self._defenses = {}
for entity in self._datastore_client.query_fetch(kind=KIND_SUBM... | [
"def",
"init_from_datastore",
"(",
"self",
")",
":",
"self",
".",
"_attacks",
"=",
"{",
"}",
"self",
".",
"_targeted_attacks",
"=",
"{",
"}",
"self",
".",
"_defenses",
"=",
"{",
"}",
"for",
"entity",
"in",
"self",
".",
"_datastore_client",
".",
"query_fe... | [
158,
4
] | [
180,
64
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.attacks | (self) | Dictionary with all non-targeted attacks. | Dictionary with all non-targeted attacks. | def attacks(self):
"""Dictionary with all non-targeted attacks."""
return self._attacks | [
"def",
"attacks",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attacks"
] | [
183,
4
] | [
185,
28
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.targeted_attacks | (self) | Dictionary with all targeted attacks. | Dictionary with all targeted attacks. | def targeted_attacks(self):
"""Dictionary with all targeted attacks."""
return self._targeted_attacks | [
"def",
"targeted_attacks",
"(",
"self",
")",
":",
"return",
"self",
".",
"_targeted_attacks"
] | [
188,
4
] | [
190,
37
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.defenses | (self) | Dictionary with all defenses. | Dictionary with all defenses. | def defenses(self):
"""Dictionary with all defenses."""
return self._defenses | [
"def",
"defenses",
"(",
"self",
")",
":",
"return",
"self",
".",
"_defenses"
] | [
193,
4
] | [
195,
29
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.get_all_attack_ids | (self) | Returns IDs of all attacks (targeted and non-targeted). | Returns IDs of all attacks (targeted and non-targeted). | def get_all_attack_ids(self):
"""Returns IDs of all attacks (targeted and non-targeted)."""
return list(self.attacks.keys()) + list(self.targeted_attacks.keys()) | [
"def",
"get_all_attack_ids",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"attacks",
".",
"keys",
"(",
")",
")",
"+",
"list",
"(",
"self",
".",
"targeted_attacks",
".",
"keys",
"(",
")",
")"
] | [
197,
4
] | [
199,
77
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.find_by_id | (self, submission_id) | Finds submission by ID.
Args:
submission_id: ID of the submission
Returns:
SubmissionDescriptor with information about submission or None if
submission is not found.
| Finds submission by ID. | def find_by_id(self, submission_id):
"""Finds submission by ID.
Args:
submission_id: ID of the submission
Returns:
SubmissionDescriptor with information about submission or None if
submission is not found.
"""
return self._attacks.get(
... | [
"def",
"find_by_id",
"(",
"self",
",",
"submission_id",
")",
":",
"return",
"self",
".",
"_attacks",
".",
"get",
"(",
"submission_id",
",",
"self",
".",
"_defenses",
".",
"get",
"(",
"submission_id",
",",
"self",
".",
"_targeted_attacks",
".",
"get",
"(",
... | [
201,
4
] | [
216,
9
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.get_external_id | (self, submission_id) | Returns human readable submission external ID.
Args:
submission_id: internal submission ID.
Returns:
human readable ID.
| Returns human readable submission external ID. | def get_external_id(self, submission_id):
"""Returns human readable submission external ID.
Args:
submission_id: internal submission ID.
Returns:
human readable ID.
"""
submission = self.find_by_id(submission_id)
if not submission:
return... | [
"def",
"get_external_id",
"(",
"self",
",",
"submission_id",
")",
":",
"submission",
"=",
"self",
".",
"find_by_id",
"(",
"submission_id",
")",
"if",
"not",
"submission",
":",
"return",
"None",
"if",
"\"team_id\"",
"in",
"submission",
".",
"participant_id",
":... | [
218,
4
] | [
235,
21
] | python | en | ['en', 'en', 'en'] | True |
CompetitionSubmissions.__str__ | (self) | Returns human readable representation, useful for debugging purposes. | Returns human readable representation, useful for debugging purposes. | def __str__(self):
"""Returns human readable representation, useful for debugging purposes."""
buf = StringIO()
title_values = zip(
[u"Attacks", u"Targeted Attacks", u"Defenses"],
[self._attacks, self._targeted_attacks, self._defenses],
)
for idx, (title, ... | [
"def",
"__str__",
"(",
"self",
")",
":",
"buf",
"=",
"StringIO",
"(",
")",
"title_values",
"=",
"zip",
"(",
"[",
"u\"Attacks\"",
",",
"u\"Targeted Attacks\"",
",",
"u\"Defenses\"",
"]",
",",
"[",
"self",
".",
"_attacks",
",",
"self",
".",
"_targeted_attack... | [
237,
4
] | [
255,
29
] | python | en | ['en', 'id', 'en'] | True |
Serializer.prepare_response | (self, request, cached) | Verify our vary headers match and construct a real urllib3
HTTPResponse object.
| Verify our vary headers match and construct a real urllib3
HTTPResponse object.
| def prepare_response(self, request, cached):
"""Verify our vary headers match and construct a real urllib3
HTTPResponse object.
"""
# Special case the '*' Vary value as it means we cannot actually
# determine if the cached response is suitable for this request.
# This cas... | [
"def",
"prepare_response",
"(",
"self",
",",
"request",
",",
"cached",
")",
":",
"# Special case the '*' Vary value as it means we cannot actually",
"# determine if the cached response is suitable for this request.",
"# This case is also handled in the controller code when creating",
"# a ... | [
103,
4
] | [
139,
83
] | python | en | ['en', 'en', 'en'] | True |
Command.get_input_data | (self, field, message, default=None) |
Override this method if you want to customize data inputs or
validation exceptions.
|
Override this method if you want to customize data inputs or
validation exceptions.
| def get_input_data(self, field, message, default=None):
"""
Override this method if you want to customize data inputs or
validation exceptions.
"""
raw_value = input(message)
if default and raw_value == '':
raw_value = default
try:
val = fi... | [
"def",
"get_input_data",
"(",
"self",
",",
"field",
",",
"message",
",",
"default",
"=",
"None",
")",
":",
"raw_value",
"=",
"input",
"(",
"message",
")",
"if",
"default",
"and",
"raw_value",
"==",
"''",
":",
"raw_value",
"=",
"default",
"try",
":",
"v... | [
203,
4
] | [
217,
18
] | python | en | ['en', 'error', 'th'] | False |
Command._validate_username | (self, username, verbose_field_name, database) | Validate username. If invalid, return a string error message. | Validate username. If invalid, return a string error message. | def _validate_username(self, username, verbose_field_name, database):
"""Validate username. If invalid, return a string error message."""
if self.username_field.unique:
try:
self.UserModel._default_manager.db_manager(database).get_by_natural_key(username)
except s... | [
"def",
"_validate_username",
"(",
"self",
",",
"username",
",",
"verbose_field_name",
",",
"database",
")",
":",
"if",
"self",
".",
"username_field",
".",
"unique",
":",
"try",
":",
"self",
".",
"UserModel",
".",
"_default_manager",
".",
"db_manager",
"(",
"... | [
229,
4
] | [
243,
40
] | python | en | ['en', 'en', 'en'] | True |
_Enhance.enhance | (self, factor) |
Returns an enhanced image.
:param factor: A floating point value controlling the enhancement.
Factor 1.0 always returns a copy of the original image,
lower factors mean less color (brightness, contrast,
etc), and higher values more. ... |
Returns an enhanced image. | def enhance(self, factor):
"""
Returns an enhanced image.
:param factor: A floating point value controlling the enhancement.
Factor 1.0 always returns a copy of the original image,
lower factors mean less color (brightness, contrast,
... | [
"def",
"enhance",
"(",
"self",
",",
"factor",
")",
":",
"return",
"Image",
".",
"blend",
"(",
"self",
".",
"degenerate",
",",
"self",
".",
"image",
",",
"factor",
")"
] | [
24,
4
] | [
35,
63
] | python | en | ['en', 'error', 'th'] | False |
make_headers | (
keep_alive=None,
accept_encoding=None,
user_agent=None,
basic_auth=None,
proxy_basic_auth=None,
disable_cache=None,
) |
Shortcuts for generating request headers.
:param keep_alive:
If ``True``, adds 'connection: keep-alive' header.
:param accept_encoding:
Can be a boolean, list, or string.
``True`` translates to 'gzip,deflate'.
List will get joined by comma.
String will be used as p... |
Shortcuts for generating request headers. | def make_headers(
keep_alive=None,
accept_encoding=None,
user_agent=None,
basic_auth=None,
proxy_basic_auth=None,
disable_cache=None,
):
"""
Shortcuts for generating request headers.
:param keep_alive:
If ``True``, adds 'connection: keep-alive' header.
:param accept_enc... | [
"def",
"make_headers",
"(",
"keep_alive",
"=",
"None",
",",
"accept_encoding",
"=",
"None",
",",
"user_agent",
"=",
"None",
",",
"basic_auth",
"=",
"None",
",",
"proxy_basic_auth",
"=",
"None",
",",
"disable_cache",
"=",
"None",
",",
")",
":",
"headers",
"... | [
17,
0
] | [
86,
18
] | python | en | ['en', 'error', 'th'] | False |
set_file_position | (body, pos) |
If a position is provided, move file to that point.
Otherwise, we'll attempt to record a position for future use.
|
If a position is provided, move file to that point.
Otherwise, we'll attempt to record a position for future use.
| def set_file_position(body, pos):
"""
If a position is provided, move file to that point.
Otherwise, we'll attempt to record a position for future use.
"""
if pos is not None:
rewind_body(body, pos)
elif getattr(body, "tell", None) is not None:
try:
pos = body.tell()
... | [
"def",
"set_file_position",
"(",
"body",
",",
"pos",
")",
":",
"if",
"pos",
"is",
"not",
"None",
":",
"rewind_body",
"(",
"body",
",",
"pos",
")",
"elif",
"getattr",
"(",
"body",
",",
"\"tell\"",
",",
"None",
")",
"is",
"not",
"None",
":",
"try",
"... | [
89,
0
] | [
104,
14
] | python | en | ['en', 'error', 'th'] | False |
rewind_body | (body, body_pos) |
Attempt to rewind body to a certain position.
Primarily used for request redirects and retries.
:param body:
File-like object that supports seek.
:param int pos:
Position to seek to in file.
|
Attempt to rewind body to a certain position.
Primarily used for request redirects and retries. | def rewind_body(body, body_pos):
"""
Attempt to rewind body to a certain position.
Primarily used for request redirects and retries.
:param body:
File-like object that supports seek.
:param int pos:
Position to seek to in file.
"""
body_seek = getattr(body, "seek", None)
... | [
"def",
"rewind_body",
"(",
"body",
",",
"body_pos",
")",
":",
"body_seek",
"=",
"getattr",
"(",
"body",
",",
"\"seek\"",
",",
"None",
")",
"if",
"body_seek",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"body_pos",
",",
"integer_types",
")",
":",
"try"... | [
107,
0
] | [
134,
9
] | python | en | ['en', 'error', 'th'] | False |
_implementation | () | Return a dict with the Python implementation and version.
Provide both the name and the version of the Python implementation
currently running. For example, on CPython 2.7.5 it will return
{'name': 'CPython', 'version': '2.7.5'}.
This function works best on CPython and PyPy: in particular, it probably... | Return a dict with the Python implementation and version. | def _implementation():
"""Return a dict with the Python implementation and version.
Provide both the name and the version of the Python implementation
currently running. For example, on CPython 2.7.5 it will return
{'name': 'CPython', 'version': '2.7.5'}.
This function works best on CPython and Py... | [
"def",
"_implementation",
"(",
")",
":",
"implementation",
"=",
"platform",
".",
"python_implementation",
"(",
")",
"if",
"implementation",
"==",
"'CPython'",
":",
"implementation_version",
"=",
"platform",
".",
"python_version",
"(",
")",
"elif",
"implementation",
... | [
25,
0
] | [
55,
70
] | python | en | ['en', 'en', 'en'] | True |
info | () | Generate information for a bug report. | Generate information for a bug report. | def info():
"""Generate information for a bug report."""
try:
platform_info = {
'system': platform.system(),
'release': platform.release(),
}
except IOError:
platform_info = {
'system': 'Unknown',
'release': 'Unknown',
}
im... | [
"def",
"info",
"(",
")",
":",
"try",
":",
"platform_info",
"=",
"{",
"'system'",
":",
"platform",
".",
"system",
"(",
")",
",",
"'release'",
":",
"platform",
".",
"release",
"(",
")",
",",
"}",
"except",
"IOError",
":",
"platform_info",
"=",
"{",
"'s... | [
58,
0
] | [
109,
5
] | python | en | ['en', 'en', 'en'] | True |
main | () | Pretty-print the bug information as JSON. | Pretty-print the bug information as JSON. | def main():
"""Pretty-print the bug information as JSON."""
print(json.dumps(info(), sort_keys=True, indent=2)) | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"info",
"(",
")",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"2",
")",
")"
] | [
112,
0
] | [
114,
55
] | python | en | ['en', 'en', 'en'] | True |
_get_mro | (cls) |
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of cls.__bases__. See https:/... |
Returns the bases classes for cls sorted by the MRO. | def _get_mro(cls):
"""
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of ... | [
"def",
"_get_mro",
"(",
"cls",
")",
":",
"if",
"platform",
".",
"python_implementation",
"(",
")",
"==",
"\"Jython\"",
":",
"return",
"(",
"cls",
",",
")",
"+",
"cls",
".",
"__bases__",
"return",
"inspect",
".",
"getmro",
"(",
"cls",
")"
] | [
23,
0
] | [
34,
30
] | python | en | ['en', 'error', 'th'] | False |
get_unpatched_class | (cls) | Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
| Protect against re-patching the distutils if reloaded | def get_unpatched_class(cls):
"""Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
"""
external_bases = (
cls
for cls in _get_mro(cls)
if not cls.__module__.startswith('setuptools')
)
... | [
"def",
"get_unpatched_class",
"(",
"cls",
")",
":",
"external_bases",
"=",
"(",
"cls",
"for",
"cls",
"in",
"_get_mro",
"(",
"cls",
")",
"if",
"not",
"cls",
".",
"__module__",
".",
"startswith",
"(",
"'setuptools'",
")",
")",
"base",
"=",
"next",
"(",
"... | [
46,
0
] | [
61,
15
] | python | en | ['en', 'en', 'en'] | True |
_patch_distribution_metadata | () | Patch write_pkg_file and read_pkg_file for higher metadata standards | Patch write_pkg_file and read_pkg_file for higher metadata standards | def _patch_distribution_metadata():
"""Patch write_pkg_file and read_pkg_file for higher metadata standards"""
for attr in ('write_pkg_file', 'read_pkg_file', 'get_metadata_version'):
new_val = getattr(setuptools.dist, attr)
setattr(distutils.dist.DistributionMetadata, attr, new_val) | [
"def",
"_patch_distribution_metadata",
"(",
")",
":",
"for",
"attr",
"in",
"(",
"'write_pkg_file'",
",",
"'read_pkg_file'",
",",
"'get_metadata_version'",
")",
":",
"new_val",
"=",
"getattr",
"(",
"setuptools",
".",
"dist",
",",
"attr",
")",
"setattr",
"(",
"d... | [
103,
0
] | [
107,
67
] | python | en | ['en', 'en', 'en'] | True |
patch_func | (replacement, target_mod, func_name) |
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
|
Patch func_name in target_mod with replacement | def patch_func(replacement, target_mod, func_name):
"""
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
"""
original = getattr(target_mod, func_name)
# set the 'unpatched' attribute on the replaceme... | [
"def",
"patch_func",
"(",
"replacement",
",",
"target_mod",
",",
"func_name",
")",
":",
"original",
"=",
"getattr",
"(",
"target_mod",
",",
"func_name",
")",
"# set the 'unpatched' attribute on the replacement to",
"# point to the original.",
"vars",
"(",
"replacement",
... | [
110,
0
] | [
124,
47
] | python | en | ['en', 'error', 'th'] | False |
patch_for_msvc_specialized_compiler | () |
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
|
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
| def patch_for_msvc_specialized_compiler():
"""
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
"""
# import late to avoid circular imports on Python < 3.5
msvc = import_module('setuptools.msvc')
if platform.system() != 'Windows':
# Compilers only avail... | [
"def",
"patch_for_msvc_specialized_compiler",
"(",
")",
":",
"# import late to avoid circular imports on Python < 3.5",
"msvc",
"=",
"import_module",
"(",
"'setuptools.msvc'",
")",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Windows'",
":",
"# Compilers only availabl... | [
131,
0
] | [
178,
12
] | python | en | ['en', 'error', 'th'] | False |
FieldNamesTests.test_M2M_long_column_name | (self) |
#13711 -- Model check for long M2M column names when database has
column name length limits.
|
#13711 -- Model check for long M2M column names when database has
column name length limits.
| def test_M2M_long_column_name(self):
"""
#13711 -- Model check for long M2M column names when database has
column name length limits.
"""
allowed_len, db_alias = get_max_column_name_length()
# A model with very long name which will be used to set relations to.
cl... | [
"def",
"test_M2M_long_column_name",
"(",
"self",
")",
":",
"allowed_len",
",",
"db_alias",
"=",
"get_max_column_name_length",
"(",
")",
"# A model with very long name which will be used to set relations to.",
"class",
"VeryLongModelNamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... | [
281,
4
] | [
359,
42
] | python | en | ['en', 'error', 'th'] | False |
FieldNamesTests.test_local_field_long_column_name | (self) |
#13711 -- Model check for long column names
when database does not support long names.
|
#13711 -- Model check for long column names
when database does not support long names.
| def test_local_field_long_column_name(self):
"""
#13711 -- Model check for long column names
when database does not support long names.
"""
allowed_len, db_alias = get_max_column_name_length()
class ModelWithLongField(models.Model):
title = models.CharField(m... | [
"def",
"test_local_field_long_column_name",
"(",
"self",
")",
":",
"allowed_len",
",",
"db_alias",
"=",
"get_max_column_name_length",
"(",
")",
"class",
"ModelWithLongField",
"(",
"models",
".",
"Model",
")",
":",
"title",
"=",
"models",
".",
"CharField",
"(",
"... | [
363,
4
] | [
393,
42
] | python | en | ['en', 'error', 'th'] | False |
AddNewUserHistoryTest.test_add_new_user_history_race | (self) | Sends a message during user creation | Sends a message during user creation | def test_add_new_user_history_race(self) -> None:
"""Sends a message during user creation"""
# Create a user who hasn't had historical messages added
realm = get_realm("zulip")
stream = Stream.objects.get(realm=realm, name="Denmark")
DefaultStream.objects.create(stream=stream, re... | [
"def",
"test_add_new_user_history_race",
"(",
"self",
")",
"->",
"None",
":",
"# Create a user who hasn't had historical messages added",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"stream",
"=",
"Stream",
".",
"objects",
".",
"get",
"(",
"realm",
"=",
"realm... | [
233,
4
] | [
304,
50
] | python | en | ['fr', 'en', 'en'] | True |
AddNewUserHistoryTest.test_auto_subbed_to_personals | (self) |
Newly created users are auto-subbed to the ability to receive
personals.
|
Newly created users are auto-subbed to the ability to receive
personals.
| def test_auto_subbed_to_personals(self) -> None:
"""
Newly created users are auto-subbed to the ability to receive
personals.
"""
test_email = self.nonreg_email("test")
self.register(test_email, "test")
user_profile = self.nonreg_user("test")
old_messages_... | [
"def",
"test_auto_subbed_to_personals",
"(",
"self",
")",
"->",
"None",
":",
"test_email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"self",
".",
"register",
"(",
"test_email",
",",
"\"test\"",
")",
"user_profile",
"=",
"self",
".",
"nonreg_user"... | [
306,
4
] | [
334,
13
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetTest.test_ldap_auth_only | (self) | If the email auth backend is not enabled, password reset should do nothing | If the email auth backend is not enabled, password reset should do nothing | def test_ldap_auth_only(self) -> None:
"""If the email auth backend is not enabled, password reset should do nothing"""
email = self.example_email("hamlet")
with self.assertLogs(level="INFO") as m:
result = self.client_post("/accounts/password/reset/", {"email": email})
s... | [
"def",
"test_ldap_auth_only",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"example_email",
"(",
"\"hamlet\"",
")",
"with",
"self",
".",
"assertLogs",
"(",
"level",
"=",
"\"INFO\"",
")",
"as",
"m",
":",
"result",
"=",
"self",
".",
"c... | [
569,
4
] | [
590,
40
] | python | en | ['en', 'en', 'en'] | True |
PasswordResetTest.test_ldap_and_email_auth | (self) | If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain | If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain | def test_ldap_and_email_auth(self) -> None:
"""If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain"""
# If the domain matches, we don't generate an email
with self.settings(LDAP_APPEND_DOMAIN="zulip.com"):
email = self.examp... | [
"def",
"test_ldap_and_email_auth",
"(",
"self",
")",
"->",
"None",
":",
"# If the domain matches, we don't generate an email",
"with",
"self",
".",
"settings",
"(",
"LDAP_APPEND_DOMAIN",
"=",
"\"zulip.com\"",
")",
":",
"email",
"=",
"self",
".",
"example_email",
"(",
... | [
599,
4
] | [
623,
50
] | python | en | ['en', 'en', 'en'] | True |
PasswordResetTest.test_redirect_endpoints | (self) |
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
|
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
| def test_redirect_endpoints(self) -> None:
"""
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
"""
result = self.cli... | [
"def",
"test_redirect_endpoints",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"client_get",
"(",
"\"/accounts/password/reset/done/\"",
")",
"self",
".",
"assert_in_success_response",
"(",
"[",
"\"Check your email\"",
"]",
",",
"result",
")",
"... | [
625,
4
] | [
642,
58
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_deactivated | (self) |
If you try to register for a deactivated realm, you get a clear error
page.
|
If you try to register for a deactivated realm, you get a clear error
page.
| def test_register_deactivated(self) -> None:
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
realm = get_realm("zulip")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.client_post(
... | [
"def",
"test_register_deactivated",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"realm",
".",
"deactivated",
"=",
"True",
"realm",
".",
"save",
"(",
"update_fields",
"=",
"[",
"\"deactivated\"",
"]",
")",
"result",
... | [
760,
4
] | [
776,
36
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_with_invalid_email | (self) |
If you try to register with invalid email, you get an invalid email
page
|
If you try to register with invalid email, you get an invalid email
page
| def test_register_with_invalid_email(self) -> None:
"""
If you try to register with invalid email, you get an invalid email
page
"""
invalid_email = "foo\x00bar"
result = self.client_post("/accounts/home/", {"email": invalid_email}, subdomain="zulip")
self.assert... | [
"def",
"test_register_with_invalid_email",
"(",
"self",
")",
"->",
"None",
":",
"invalid_email",
"=",
"\"foo\\x00bar\"",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/accounts/home/\"",
",",
"{",
"\"email\"",
":",
"invalid_email",
"}",
",",
"subdomain",
"=",... | [
778,
4
] | [
787,
66
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_deactivated_partway_through | (self) |
If you try to register for a deactivated realm, you get a clear error
page.
|
If you try to register for a deactivated realm, you get a clear error
page.
| def test_register_deactivated_partway_through(self) -> None:
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
email = self.nonreg_email("test")
result = self.client_post("/accounts/home/", {"email": email}, subdomain="zulip")
sel... | [
"def",
"test_register_deactivated_partway_through",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/accounts/home/\"",
",",
"{",
"\"email\"",
":",
"email",
... | [
789,
4
] | [
808,
36
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_login_deactivated_realm | (self) |
If you try to log in to a deactivated realm, you get a clear error page.
|
If you try to log in to a deactivated realm, you get a clear error page.
| def test_login_deactivated_realm(self) -> None:
"""
If you try to log in to a deactivated realm, you get a clear error page.
"""
realm = get_realm("zulip")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.login_with_return(self.exa... | [
"def",
"test_login_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"realm",
".",
"deactivated",
"=",
"True",
"realm",
".",
"save",
"(",
"update_fields",
"=",
"[",
"\"deactivated\"",
"]",
")",
"result... | [
810,
4
] | [
820,
62
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_non_ascii_login | (self) |
You can log in even if your password contain non-ASCII characters.
|
You can log in even if your password contain non-ASCII characters.
| def test_non_ascii_login(self) -> None:
"""
You can log in even if your password contain non-ASCII characters.
"""
email = self.nonreg_email("test")
password = "hümbüǵ"
# Registering succeeds.
self.register(email, password)
user_profile = self.nonreg_u... | [
"def",
"test_non_ascii_login",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"password",
"=",
"\"hümbüǵ\"",
"# Registering succeeds.",
"self",
".",
"register",
"(",
"email",
",",
"password",
")",
"user... | [
829,
4
] | [
846,
54
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_login_page_redirects_logged_in_user | (self) | You will be redirected to the app's main page if you land on the
login page when already logged in.
| You will be redirected to the app's main page if you land on the
login page when already logged in.
| def test_login_page_redirects_logged_in_user(self) -> None:
"""You will be redirected to the app's main page if you land on the
login page when already logged in.
"""
self.login("cordelia")
response = self.client_get("/login/")
self.assertEqual(response["Location"], "http... | [
"def",
"test_login_page_redirects_logged_in_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"cordelia\"",
")",
"response",
"=",
"self",
".",
"client_get",
"(",
"\"/login/\"",
")",
"self",
".",
"assertEqual",
"(",
"response",
"[",
"\"Lo... | [
849,
4
] | [
855,
73
] | python | en | ['en', 'en', 'en'] | True |
LoginTest.test_login_page_redirects_logged_in_user_under_2fa | (self) | You will be redirected to the app's main page if you land on the
login page when already logged in.
| You will be redirected to the app's main page if you land on the
login page when already logged in.
| def test_login_page_redirects_logged_in_user_under_2fa(self) -> None:
"""You will be redirected to the app's main page if you land on the
login page when already logged in.
"""
user_profile = self.example_user("cordelia")
self.create_default_device(user_profile)
self.log... | [
"def",
"test_login_page_redirects_logged_in_user_under_2fa",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"self",
".",
"create_default_device",
"(",
"user_profile",
")",
"self",
".",
"login",
"(",
... | [
862,
4
] | [
873,
73
] | python | en | ['en', 'en', 'en'] | True |
InviteUserBase.invite | (
self,
invitee_emails: str,
stream_names: Sequence[str],
body: str = "",
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
) |
Invites the specified users to Zulip with the specified streams.
users should be a string containing the users to invite, comma or
newline separated.
streams should be a list of strings.
|
Invites the specified users to Zulip with the specified streams. | def invite(
self,
invitee_emails: str,
stream_names: Sequence[str],
body: str = "",
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
) -> HttpResponse:
"""
Invites the specified users to Zulip with the specified streams.
users should be a str... | [
"def",
"invite",
"(",
"self",
",",
"invitee_emails",
":",
"str",
",",
"stream_names",
":",
"Sequence",
"[",
"str",
"]",
",",
"body",
":",
"str",
"=",
"\"\"",
",",
"invite_as",
":",
"int",
"=",
"PreregistrationUser",
".",
"INVITE_AS",
"[",
"\"MEMBER\"",
"... | [
924,
4
] | [
949,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
invitee = "alice-test@zulip.com"
self.assert_json_success(self.invite(invitee, ["Denmark"]))
se... | [
"def",
"test_successful_invite_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"De... | [
953,
4
] | [
962,
68
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_mirror_dummy_user | (self) |
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC.
We want users to eventually just sign up or
register for Zulip, in which case we will just
fully "activate" the account.
Here we... |
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC. | def test_invite_mirror_dummy_user(self) -> None:
"""
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC.
We want users to eventually just sign up or
register for Zulip, in which case we will... | [
"def",
"test_invite_mirror_dummy_user",
"(",
"self",
")",
"->",
"None",
":",
"inviter",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"inviter",
")",
"mirror_user",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\... | [
1092,
4
] | [
1125,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_user_as_invalid_type | (self) |
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
|
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
| def test_invite_user_as_invalid_type(self) -> None:
"""
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
"""
self.login("iago")
invitee = self.nonreg_email("alice")
response = self.invite(invitee, ["Denmar... | [
"def",
"test_invite_user_as_invalid_type",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"self",
".",
"nonreg_email",
"(",
"\"alice\"",
")",
"response",
"=",
"self",
".",
"invite",
"(",
"invitee",
",",
"["... | [
1172,
4
] | [
1180,
84
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user_with_name | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user_with_name(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
email = "alice-test@zulip.com"
invitee = f"Alice Test <{email}>"
self.assert_json_suc... | [
"def",
"test_successful_invite_user_with_name",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"email",
"=",
"\"alice-test@zulip.com\"",
"invitee",
"=",
"f\"Alice Test <{email}>\"",
"self",
".",
"assert_json_success",
"(",
"self",
... | [
1208,
4
] | [
1218,
66
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user_with_name_and_normal_one | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user_with_name_and_normal_one(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
email = "alice-test@zulip.com"
email2 = "bob-test@zulip.com"
invitee =... | [
"def",
"test_successful_invite_user_with_name_and_normal_one",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"email",
"=",
"\"alice-test@zulip.com\"",
"email2",
"=",
"\"bob-test@zulip.com\"",
"invitee",
"=",
"f\"Alice Test <{email}>, {... | [
1220,
4
] | [
1232,
74
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_others_to_realm_setting | (self) |
The invite_to_realm_policy realm setting works properly.
|
The invite_to_realm_policy realm setting works properly.
| def test_invite_others_to_realm_setting(self) -> None:
"""
The invite_to_realm_policy realm setting works properly.
"""
realm = get_realm("zulip")
do_set_realm_property(
realm, "invite_to_realm_policy", Realm.POLICY_ADMINS_ONLY, acting_user=None
)
sel... | [
"def",
"test_invite_others_to_realm_setting",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_set_realm_property",
"(",
"realm",
",",
"\"invite_to_realm_policy\"",
",",
"Realm",
".",
"POLICY_ADMINS_ONLY",
",",
"acting_user",
... | [
1242,
4
] | [
1333,
47
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_user_signup_initial_history | (self) |
Test that a new user invited to a stream receives some initial
history but only from public streams.
|
Test that a new user invited to a stream receives some initial
history but only from public streams.
| def test_invite_user_signup_initial_history(self) -> None:
"""
Test that a new user invited to a stream receives some initial
history but only from public streams.
"""
self.login("hamlet")
user_profile = self.example_user("hamlet")
private_stream_name = "Secret"
... | [
"def",
"test_invite_user_signup_initial_history",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"private_stream_name",
"=",
"\"Secret\"",
"self",
".",
... | [
1335,
4
] | [
1386,
85
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_multi_user_invite | (self) |
Invites multiple users with a variety of delimiters.
|
Invites multiple users with a variety of delimiters.
| def test_multi_user_invite(self) -> None:
"""
Invites multiple users with a variety of delimiters.
"""
self.login("hamlet")
# Intentionally use a weird string.
self.assert_json_success(
self.invite(
"""bob-test@zulip.com, carol-test@zulip.c... | [
"def",
"test_multi_user_invite",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"# Intentionally use a weird string.",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"\"\"\"bob-test@zulip.com, carol-test@zuli... | [
1388,
4
] | [
1413,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_missing_or_invalid_params | (self) |
Tests inviting with various missing or invalid parameters.
|
Tests inviting with various missing or invalid parameters.
| def test_missing_or_invalid_params(self) -> None:
"""
Tests inviting with various missing or invalid parameters.
"""
realm = get_realm("zulip")
do_set_realm_property(realm, "emails_restricted_to_domains", True, acting_user=None)
self.login("hamlet")
invitee_email... | [
"def",
"test_missing_or_invalid_params",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_set_realm_property",
"(",
"realm",
",",
"\"emails_restricted_to_domains\"",
",",
"True",
",",
"acting_user",
"=",
"None",
")",
"self... | [
1438,
4
] | [
1462,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_guest_user_invitation | (self) |
Guest user can't invite new users
|
Guest user can't invite new users
| def test_guest_user_invitation(self) -> None:
"""
Guest user can't invite new users
"""
self.login("polonius")
invitee = "alice-test@zulip.com"
self.assert_json_error(self.invite(invitee, ["Denmark"]), "Not allowed for guest users")
self.assertEqual(find_key_by_em... | [
"def",
"test_guest_user_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"polonius\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"self",
".",
"assert_json_error",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"Den... | [
1464,
4
] | [
1472,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invalid_stream | (self) |
Tests inviting to a non-existent stream.
|
Tests inviting to a non-existent stream.
| def test_invalid_stream(self) -> None:
"""
Tests inviting to a non-existent stream.
"""
self.login("hamlet")
self.assert_json_error(
self.invite("iago-test@zulip.com", ["NotARealStream"]),
f"Stream does not exist with id: {self.INVALID_STREAM_ID}. No invit... | [
"def",
"test_invalid_stream",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"assert_json_error",
"(",
"self",
".",
"invite",
"(",
"\"iago-test@zulip.com\"",
",",
"[",
"\"NotARealStream\"",
"]",
")",
",",
"f\"... | [
1474,
4
] | [
1483,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_existing_user | (self) |
If you invite an address already using Zulip, no invitation is sent.
|
If you invite an address already using Zulip, no invitation is sent.
| def test_invite_existing_user(self) -> None:
"""
If you invite an address already using Zulip, no invitation is sent.
"""
self.login("hamlet")
hamlet_email = "hAmLeT@zUlIp.com"
result = self.invite(hamlet_email, ["Denmark"])
self.assert_json_error(result, "We wer... | [
"def",
"test_invite_existing_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"hamlet_email",
"=",
"\"hAmLeT@zUlIp.com\"",
"result",
"=",
"self",
".",
"invite",
"(",
"hamlet_email",
",",
"[",
"\"Denmark\"",
"]",
")",
... | [
1485,
4
] | [
1498,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_links_in_name | (self) |
If you invite an address already using Zulip, no invitation is sent.
|
If you invite an address already using Zulip, no invitation is sent.
| def test_invite_links_in_name(self) -> None:
"""
If you invite an address already using Zulip, no invitation is sent.
"""
hamlet = self.example_user("hamlet")
self.login_user(hamlet)
# Test we properly handle links in user full names
do_change_full_name(hamlet, "<... | [
"def",
"test_invite_links_in_name",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"hamlet",
")",
"# Test we properly handle links in user full names",
"do_change_full_name",
"("... | [
1504,
4
] | [
1527,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_some_existing_some_new | (self) |
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
|
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
| def test_invite_some_existing_some_new(self) -> None:
"""
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
"""
self.login("hamlet")
existing = [self.example_email("hamlet"), "othello@zulip.com"]
new = ["foo-test@zu... | [
"def",
"test_invite_some_existing_some_new",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"existing",
"=",
"[",
"self",
".",
"example_email",
"(",
"\"hamlet\"",
")",
",",
"\"othello@zulip.com\"",
"]",
"new",
"=",
"[",
"\... | [
1533,
4
] | [
1561,
65
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_in_closed_realm | (self) |
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
|
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
| def test_invite_outside_domain_in_closed_realm(self) -> None:
"""
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_... | [
"def",
"test_invite_outside_domain_in_closed_realm",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"True",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"l... | [
1563,
4
] | [
1578,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_using_disposable_email | (self) |
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
|
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
| def test_invite_using_disposable_email(self) -> None:
"""
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_restricted_to_domains = False
zulip_re... | [
"def",
"test_invite_using_disposable_email",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"disallow_disposable_email_addresses",
"=",
"T... | [
1580,
4
] | [
1596,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_in_open_realm | (self) |
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
|
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
| def test_invite_outside_domain_in_open_realm(self) -> None:
"""
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_res... | [
"def",
"test_invite_outside_domain_in_open_realm",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"lo... | [
1598,
4
] | [
1611,
50
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_before_closing | (self) |
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's signup
attempt should fail.
|
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's signup
attempt should fail.
| def test_invite_outside_domain_before_closing(self) -> None:
"""
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's sig... | [
"def",
"test_invite_outside_domain_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"l... | [
1613,
4
] | [
1635,
81
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_disposable_emails_before_closing | (self) |
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
|
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
| def test_disposable_emails_before_closing(self) -> None:
"""
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
"""
... | [
"def",
"test_disposable_emails_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"disallow_disposable_email_addresses",
"=",
... | [
1637,
4
] | [
1660,
85
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_with_email_containing_plus_before_closing | (self) |
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's signup attempt should fail as
users are not allowed to signup using email cont... |
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's signup attempt should fail as
users are not allowed to signup using email cont... | def test_invite_with_email_containing_plus_before_closing(self) -> None:
"""
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's si... | [
"def",
"test_invite_with_email_containing_plus_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",... | [
1662,
4
] | [
1688,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_with_non_ascii_streams | (self) |
Inviting someone to streams with non-ASCII characters succeeds.
|
Inviting someone to streams with non-ASCII characters succeeds.
| def test_invite_with_non_ascii_streams(self) -> None:
"""
Inviting someone to streams with non-ASCII characters succeeds.
"""
self.login("hamlet")
invitee = "alice-test@zulip.com"
stream_name = "hümbüǵ"
# Make sure we're subscribed before inviting someone.
... | [
"def",
"test_invite_with_non_ascii_streams",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"stream_name",
"=",
"\"hümbüǵ\"",
"# Make sure we're subscribed before inviting someone.",
"self",
... | [
1707,
4
] | [
1719,
69
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_confirmation_obj_not_exist_error | (self) | Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
the confirmation_link_expired_error page.
| Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
the confirmation_link_expired_error page.
| def test_confirmation_obj_not_exist_error(self) -> None:
"""Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
... | [
"def",
"test_confirmation_obj_not_exist_error",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"alice\"",
")",
"password",
"=",
"\"password\"",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"inviter",
"=",
"self",
".... | [
1893,
4
] | [
1924,
51
] | python | en | ['en', 'en', 'en'] | True |
InvitationsTestCase.test_successful_get_open_invitations | (self) |
A GET call to /json/invites returns all unexpired invitations.
|
A GET call to /json/invites returns all unexpired invitations.
| def test_successful_get_open_invitations(self) -> None:
"""
A GET call to /json/invites returns all unexpired invitations.
"""
realm = get_realm("zulip")
days_to_activate = getattr(settings, "INVITATION_LINK_VALIDITY_DAYS", "Wrong")
active_value = getattr(confirmation_set... | [
"def",
"test_successful_get_open_invitations",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"days_to_activate",
"=",
"getattr",
"(",
"settings",
",",
"\"INVITATION_LINK_VALIDITY_DAYS\"",
",",
"\"Wrong\"",
")",
"active_value",
... | [
1981,
4
] | [
2027,
69
] | python | en | ['en', 'error', 'th'] | False |
InvitationsTestCase.test_successful_delete_invitation | (self) |
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
|
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
| def test_successful_delete_invitation(self) -> None:
"""
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
"""
self.login("iago")
invitee = "DeleteMe@zulip.com"
self.assert_json_success(self.invite(invitee,... | [
"def",
"test_successful_delete_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"\"DeleteMe@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"... | [
2029,
4
] | [
2053,
9
] | python | en | ['en', 'error', 'th'] | False |
InvitationsTestCase.test_successful_member_delete_invitation | (self) |
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
|
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
| def test_successful_member_delete_invitation(self) -> None:
"""
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
... | [
"def",
"test_successful_member_delete_invitation",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"invitee",
"=",
"\"DeleteMe@zulip.com\"",
"self",
... | [
2055,
4
] | [
2091,
9
] | python | en | ['en', 'error', 'th'] | False |
InvitationsTestCase.test_delete_multiuse_invite | (self) |
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
|
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
| def test_delete_multiuse_invite(self) -> None:
"""
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
"""
self.login("iago")
zulip_realm = get_realm("zulip")
multiuse_invite = MultiuseInvite.objects.create(
referred_by=self... | [
"def",
"test_delete_multiuse_invite",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"multiuse_invite",
"=",
"MultiuseInvite",
".",
"objects",
".",
"create",
"(",
"referr... | [
2120,
4
] | [
2163,
66
] | python | en | ['en', 'error', 'th'] | False |
InvitationsTestCase.test_successful_resend_invitation | (self) |
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
|
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
| def test_successful_resend_invitation(self) -> None:
"""
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
"""
self.login("iago")
invitee = "resend_me@zulip.com"
self.assert_json_... | [
"def",
"test_successful_resend_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"\"resend_me@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\... | [
2165,
4
] | [
2208,
67
] | python | en | ['en', 'error', 'th'] | False |
InvitationsTestCase.test_successful_member_resend_invitation | (self) | A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
| A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
| def test_successful_member_resend_invitation(self) -> None:
"""A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
"""
self.login("hamlet")
user... | [
"def",
"test_successful_member_resend_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"resend_me@zulip.com\"",
"self",
".",
... | [
2210,
4
] | [
2265,
85
] | python | en | ['en', 'en', 'en'] | True |
assert_server_running | (server: "subprocess.Popen[bytes]", log_file: Optional[str]) | Get the exit code of the server, or None if it is still running. | Get the exit code of the server, or None if it is still running. | def assert_server_running(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> None:
"""Get the exit code of the server, or None if it is still running."""
if server.poll() is not None:
message = "Server died unexpectedly!"
if log_file:
message += f"\nSee {log_file}\n"
... | [
"def",
"assert_server_running",
"(",
"server",
":",
"\"subprocess.Popen[bytes]\"",
",",
"log_file",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"None",
":",
"if",
"server",
".",
"poll",
"(",
")",
"is",
"not",
"None",
":",
"message",
"=",
"\"Server died unex... | [
34,
0
] | [
40,
35
] | python | en | ['en', 'en', 'en'] | True |
connect | (dsn=None, connection_factory=None, cursor_factory=None, **kwargs) |
Create a new database connection.
The connection parameters can be specified as a string:
conn = psycopg2.connect("dbname=test user=postgres password=secret")
or using a set of keyword arguments:
conn = psycopg2.connect(database="test", user="postgres", password="secret")
Or as a m... |
Create a new database connection. | def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs):
"""
Create a new database connection.
The connection parameters can be specified as a string:
conn = psycopg2.connect("dbname=test user=postgres password=secret")
or using a set of keyword arguments:
conn ... | [
"def",
"connect",
"(",
"dsn",
"=",
"None",
",",
"connection_factory",
"=",
"None",
",",
"cursor_factory",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwasync",
"=",
"{",
"}",
"if",
"'async'",
"in",
"kwargs",
":",
"kwasync",
"[",
"'async'",
"]",
... | [
81,
0
] | [
130,
15
] | python | en | ['en', 'error', 'th'] | False |
Local._get_context_id | (self) |
Get the ID we should use for looking up variables
|
Get the ID we should use for looking up variables
| def _get_context_id(self):
"""
Get the ID we should use for looking up variables
"""
# Prevent a circular reference
from .sync import AsyncToSync, SyncToAsync
# First, pull the current task if we can
context_id = SyncToAsync.get_current_task()
context_is_... | [
"def",
"_get_context_id",
"(",
"self",
")",
":",
"# Prevent a circular reference",
"from",
".",
"sync",
"import",
"AsyncToSync",
",",
"SyncToAsync",
"# First, pull the current task if we can",
"context_id",
"=",
"SyncToAsync",
".",
"get_current_task",
"(",
")",
"context_i... | [
45,
4
] | [
79,
25
] | python | en | ['en', 'error', 'th'] | False |
double_output | (func, argtypes, errcheck=False, strarg=False) | Generates a ctypes function that returns a double value. | Generates a ctypes function that returns a double value. | def double_output(func, argtypes, errcheck=False, strarg=False):
"Generates a ctypes function that returns a double value."
func.argtypes = argtypes
func.restype = c_double
if errcheck:
func.errcheck = check_arg_errcode
if strarg:
func.errcheck = check_str_arg
return func | [
"def",
"double_output",
"(",
"func",
",",
"argtypes",
",",
"errcheck",
"=",
"False",
",",
"strarg",
"=",
"False",
")",
":",
"func",
".",
"argtypes",
"=",
"argtypes",
"func",
".",
"restype",
"=",
"c_double",
"if",
"errcheck",
":",
"func",
".",
"errcheck",... | [
15,
0
] | [
23,
15
] | python | en | ['en', 'en', 'en'] | True |
geom_output | (func, argtypes, offset=None) |
Generates a function that returns a Geometry either by reference
or directly (if the return_geom keyword is set to True).
|
Generates a function that returns a Geometry either by reference
or directly (if the return_geom keyword is set to True).
| def geom_output(func, argtypes, offset=None):
"""
Generates a function that returns a Geometry either by reference
or directly (if the return_geom keyword is set to True).
"""
# Setting the argument types
func.argtypes = argtypes
if not offset:
# When a geometry pointer is directly ... | [
"def",
"geom_output",
"(",
"func",
",",
"argtypes",
",",
"offset",
"=",
"None",
")",
":",
"# Setting the argument types",
"func",
".",
"argtypes",
"=",
"argtypes",
"if",
"not",
"offset",
":",
"# When a geometry pointer is directly returned.",
"func",
".",
"restype",... | [
26,
0
] | [
46,
15
] | python | en | ['en', 'error', 'th'] | False |
int_output | (func, argtypes) | Generates a ctypes function that returns an integer value. | Generates a ctypes function that returns an integer value. | def int_output(func, argtypes):
"Generates a ctypes function that returns an integer value."
func.argtypes = argtypes
func.restype = c_int
return func | [
"def",
"int_output",
"(",
"func",
",",
"argtypes",
")",
":",
"func",
".",
"argtypes",
"=",
"argtypes",
"func",
".",
"restype",
"=",
"c_int",
"return",
"func"
] | [
49,
0
] | [
53,
15
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.