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
Storage.get_available_name
(self, name, max_length=None)
Return a filename that's free on the target storage system and available for new content to be written to.
Return a filename that's free on the target storage system and available for new content to be written to.
def get_available_name(self, name, max_length=None): """ Return a filename that's free on the target storage system and available for new content to be written to. """ dir_name, file_name = os.path.split(name) file_root, file_ext = os.path.splitext(file_name) # If...
[ "def", "get_available_name", "(", "self", ",", "name", ",", "max_length", "=", "None", ")", ":", "dir_name", ",", "file_name", "=", "os", ".", "path", ".", "split", "(", "name", ")", "file_root", ",", "file_ext", "=", "os", ".", "path", ".", "splitext"...
[ 70, 4 ]
[ 98, 19 ]
python
en
['en', 'error', 'th']
False
Storage.generate_filename
(self, filename)
Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method.
Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method.
def generate_filename(self, filename): """ Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method. """ # `filename` may include a path as returned by FileField.upload_to. dirname, filename = os.path.split(filename) ...
[ "def", "generate_filename", "(", "self", ",", "filename", ")", ":", "# `filename` may include a path as returned by FileField.upload_to.", "dirname", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "return", "os", ".", "path", ".", "no...
[ 100, 4 ]
[ 107, 85 ]
python
en
['en', 'error', 'th']
False
Storage.path
(self, name)
Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
def path(self, name): """ Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method. """ raise NotImplementedError("This backend doesn't su...
[ "def", "path", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "\"This backend doesn't support absolute paths.\"", ")" ]
[ 109, 4 ]
[ 115, 81 ]
python
en
['en', 'error', 'th']
False
Storage.delete
(self, name)
Delete the specified file from the storage system.
Delete the specified file from the storage system.
def delete(self, name): """ Delete the specified file from the storage system. """ raise NotImplementedError('subclasses of Storage must provide a delete() method')
[ "def", "delete", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a delete() method'", ")" ]
[ 120, 4 ]
[ 124, 89 ]
python
en
['en', 'error', 'th']
False
Storage.exists
(self, name)
Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
def exists(self, name): """ Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file. """ raise NotImplementedError('subclasses of Storage must provide an exists() method')
[ "def", "exists", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide an exists() method'", ")" ]
[ 126, 4 ]
[ 131, 90 ]
python
en
['en', 'error', 'th']
False
Storage.listdir
(self, path)
List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files.
List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files.
def listdir(self, path): """ List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files. """ raise NotImplementedError('subclasses of Storage must provide a listdir() method')
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a listdir() method'", ")" ]
[ 133, 4 ]
[ 138, 90 ]
python
en
['en', 'error', 'th']
False
Storage.size
(self, name)
Return the total size, in bytes, of the file specified by name.
Return the total size, in bytes, of the file specified by name.
def size(self, name): """ Return the total size, in bytes, of the file specified by name. """ raise NotImplementedError('subclasses of Storage must provide a size() method')
[ "def", "size", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a size() method'", ")" ]
[ 140, 4 ]
[ 144, 87 ]
python
en
['en', 'error', 'th']
False
Storage.url
(self, name)
Return an absolute URL where the file's contents can be accessed directly by a Web browser.
Return an absolute URL where the file's contents can be accessed directly by a Web browser.
def url(self, name): """ Return an absolute URL where the file's contents can be accessed directly by a Web browser. """ raise NotImplementedError('subclasses of Storage must provide a url() method')
[ "def", "url", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a url() method'", ")" ]
[ 146, 4 ]
[ 151, 86 ]
python
en
['en', 'error', 'th']
False
Storage.get_accessed_time
(self, name)
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_accessed_time(self, name): """ Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_accessed_time() method')
[ "def", "get_accessed_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_accessed_time() method'", ")" ]
[ 153, 4 ]
[ 158, 100 ]
python
en
['en', 'error', 'th']
False
Storage.get_created_time
(self, name)
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_created_time(self, name): """ Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_created_time() method')
[ "def", "get_created_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_created_time() method'", ")" ]
[ 160, 4 ]
[ 165, 99 ]
python
en
['en', 'error', 'th']
False
Storage.get_modified_time
(self, name)
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_modified_time(self, name): """ Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_modified_time() method')
[ "def", "get_modified_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_modified_time() method'", ")" ]
[ 167, 4 ]
[ 172, 100 ]
python
en
['en', 'error', 'th']
False
EmailBackend.open
(self)
Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False).
Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False).
def open(self): """ Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False). """ if self.connection: # Nothing to do if the connection is already open. return False connection_class = ...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "connection", ":", "# Nothing to do if the connection is already open.", "return", "False", "connection_class", "=", "smtplib", ".", "SMTP_SSL", "if", "self", ".", "use_ssl", "else", "smtplib", ".", "SMTP", ...
[ 36, 4 ]
[ 70, 21 ]
python
en
['en', 'error', 'th']
False
EmailBackend.close
(self)
Closes the connection to the email server.
Closes the connection to the email server.
def close(self): """Closes the connection to the email server.""" if self.connection is None: return try: try: self.connection.quit() except (ssl.SSLError, smtplib.SMTPServerDisconnected): # This happens when calling quit() on a...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "connection", "is", "None", ":", "return", "try", ":", "try", ":", "self", ".", "connection", ".", "quit", "(", ")", "except", "(", "ssl", ".", "SSLError", ",", "smtplib", ".", "SMTPServerDisc...
[ 72, 4 ]
[ 89, 34 ]
python
en
['en', 'en', 'en']
True
EmailBackend.send_messages
(self, email_messages)
Sends one or more EmailMessage objects and returns the number of email messages sent.
Sends one or more EmailMessage objects and returns the number of email messages sent.
def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return with self._lock: new_conn_created = self.open() if not self.connection:...
[ "def", "send_messages", "(", "self", ",", "email_messages", ")", ":", "if", "not", "email_messages", ":", "return", "with", "self", ".", "_lock", ":", "new_conn_created", "=", "self", ".", "open", "(", ")", "if", "not", "self", ".", "connection", ":", "#...
[ 91, 4 ]
[ 111, 23 ]
python
en
['en', 'error', 'th']
False
EmailBackend._send
(self, email_message)
A helper method that does the actual sending.
A helper method that does the actual sending.
def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False from_email = sanitize_address(email_message.from_email, email_message.encoding) recipients = [sanitize_address(addr, email_message.encoding) ...
[ "def", "_send", "(", "self", ",", "email_message", ")", ":", "if", "not", "email_message", ".", "recipients", "(", ")", ":", "return", "False", "from_email", "=", "sanitize_address", "(", "email_message", ".", "from_email", ",", "email_message", ".", "encoding...
[ 113, 4 ]
[ 127, 19 ]
python
en
['en', 'en', 'en']
True
get_fixed_timezone
(offset)
Return a tzinfo instance with a fixed offset from UTC.
Return a tzinfo instance with a fixed offset from UTC.
def get_fixed_timezone(offset): """Return a tzinfo instance with a fixed offset from UTC.""" if isinstance(offset, timedelta): offset = offset.total_seconds() // 60 sign = '-' if offset < 0 else '+' hhmm = '%02d%02d' % divmod(abs(offset), 60) name = sign + hhmm return timezone(timedelta(...
[ "def", "get_fixed_timezone", "(", "offset", ")", ":", "if", "isinstance", "(", "offset", ",", "timedelta", ")", ":", "offset", "=", "offset", ".", "total_seconds", "(", ")", "//", "60", "sign", "=", "'-'", "if", "offset", "<", "0", "else", "'+'", "hhmm...
[ 63, 0 ]
[ 70, 52 ]
python
en
['en', 'en', 'en']
True
get_default_timezone
()
Return the default time zone as a tzinfo instance. This is the time zone defined by settings.TIME_ZONE.
Return the default time zone as a tzinfo instance.
def get_default_timezone(): """ Return the default time zone as a tzinfo instance. This is the time zone defined by settings.TIME_ZONE. """ return pytz.timezone(settings.TIME_ZONE)
[ "def", "get_default_timezone", "(", ")", ":", "return", "pytz", ".", "timezone", "(", "settings", ".", "TIME_ZONE", ")" ]
[ 76, 0 ]
[ 82, 44 ]
python
en
['en', 'error', 'th']
False
get_default_timezone_name
()
Return the name of the default time zone.
Return the name of the default time zone.
def get_default_timezone_name(): """Return the name of the default time zone.""" return _get_timezone_name(get_default_timezone())
[ "def", "get_default_timezone_name", "(", ")", ":", "return", "_get_timezone_name", "(", "get_default_timezone", "(", ")", ")" ]
[ 86, 0 ]
[ 88, 53 ]
python
en
['en', 'en', 'en']
True
get_current_timezone
()
Return the currently active time zone as a tzinfo instance.
Return the currently active time zone as a tzinfo instance.
def get_current_timezone(): """Return the currently active time zone as a tzinfo instance.""" return getattr(_active, "value", get_default_timezone())
[ "def", "get_current_timezone", "(", ")", ":", "return", "getattr", "(", "_active", ",", "\"value\"", ",", "get_default_timezone", "(", ")", ")" ]
[ 94, 0 ]
[ 96, 60 ]
python
en
['en', 'en', 'en']
True
get_current_timezone_name
()
Return the name of the currently active time zone.
Return the name of the currently active time zone.
def get_current_timezone_name(): """Return the name of the currently active time zone.""" return _get_timezone_name(get_current_timezone())
[ "def", "get_current_timezone_name", "(", ")", ":", "return", "_get_timezone_name", "(", "get_current_timezone", "(", ")", ")" ]
[ 99, 0 ]
[ 101, 53 ]
python
en
['en', 'en', 'en']
True
_get_timezone_name
(timezone)
Return the name of ``timezone``.
Return the name of ``timezone``.
def _get_timezone_name(timezone): """Return the name of ``timezone``.""" return timezone.tzname(None)
[ "def", "_get_timezone_name", "(", "timezone", ")", ":", "return", "timezone", ".", "tzname", "(", "None", ")" ]
[ 104, 0 ]
[ 106, 32 ]
python
en
['en', 'en', 'en']
True
activate
(timezone)
Set the time zone for the current thread. The ``timezone`` argument must be an instance of a tzinfo subclass or a time zone name.
Set the time zone for the current thread.
def activate(timezone): """ Set the time zone for the current thread. The ``timezone`` argument must be an instance of a tzinfo subclass or a time zone name. """ if isinstance(timezone, tzinfo): _active.value = timezone elif isinstance(timezone, str): _active.value = pytz.ti...
[ "def", "activate", "(", "timezone", ")", ":", "if", "isinstance", "(", "timezone", ",", "tzinfo", ")", ":", "_active", ".", "value", "=", "timezone", "elif", "isinstance", "(", "timezone", ",", "str", ")", ":", "_active", ".", "value", "=", "pytz", "."...
[ 114, 0 ]
[ 126, 59 ]
python
en
['en', 'error', 'th']
False
deactivate
()
Unset the time zone for the current thread. Django will then use the time zone defined by settings.TIME_ZONE.
Unset the time zone for the current thread.
def deactivate(): """ Unset the time zone for the current thread. Django will then use the time zone defined by settings.TIME_ZONE. """ if hasattr(_active, "value"): del _active.value
[ "def", "deactivate", "(", ")", ":", "if", "hasattr", "(", "_active", ",", "\"value\"", ")", ":", "del", "_active", ".", "value" ]
[ 129, 0 ]
[ 136, 25 ]
python
en
['en', 'error', 'th']
False
template_localtime
(value, use_tz=None)
Check if value is a datetime and converts it to local time if necessary. If use_tz is provided and is not None, that will force the value to be converted (or not), overriding the value of settings.USE_TZ. This function is designed for use by the template engine.
Check if value is a datetime and converts it to local time if necessary.
def template_localtime(value, use_tz=None): """ Check if value is a datetime and converts it to local time if necessary. If use_tz is provided and is not None, that will force the value to be converted (or not), overriding the value of settings.USE_TZ. This function is designed for use by the temp...
[ "def", "template_localtime", "(", "value", ",", "use_tz", "=", "None", ")", ":", "should_convert", "=", "(", "isinstance", "(", "value", ",", "datetime", ")", "and", "(", "settings", ".", "USE_TZ", "if", "use_tz", "is", "None", "else", "use_tz", ")", "an...
[ 170, 0 ]
[ 185, 56 ]
python
en
['en', 'error', 'th']
False
localtime
(value=None, timezone=None)
Convert an aware datetime.datetime to local time. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified.
Convert an aware datetime.datetime to local time.
def localtime(value=None, timezone=None): """ Convert an aware datetime.datetime to local time. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified. """ if value is None: ...
[ "def", "localtime", "(", "value", "=", "None", ",", "timezone", "=", "None", ")", ":", "if", "value", "is", "None", ":", "value", "=", "now", "(", ")", "if", "timezone", "is", "None", ":", "timezone", "=", "get_current_timezone", "(", ")", "# Emulate t...
[ 190, 0 ]
[ 207, 37 ]
python
en
['en', 'error', 'th']
False
localdate
(value=None, timezone=None)
Convert an aware datetime to local time and return the value's date. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified.
Convert an aware datetime to local time and return the value's date.
def localdate(value=None, timezone=None): """ Convert an aware datetime to local time and return the value's date. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified. """ r...
[ "def", "localdate", "(", "value", "=", "None", ",", "timezone", "=", "None", ")", ":", "return", "localtime", "(", "value", ",", "timezone", ")", ".", "date", "(", ")" ]
[ 210, 0 ]
[ 220, 44 ]
python
en
['en', 'error', 'th']
False
now
()
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
def now(): """ Return an aware or naive datetime.datetime, depending on settings.USE_TZ. """ if settings.USE_TZ: # timeit shows that datetime.now(tz=utc) is 24% slower return datetime.utcnow().replace(tzinfo=utc) else: return datetime.now()
[ "def", "now", "(", ")", ":", "if", "settings", ".", "USE_TZ", ":", "# timeit shows that datetime.now(tz=utc) is 24% slower", "return", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "utc", ")", "else", ":", "return", "datetime", ".", ...
[ 223, 0 ]
[ 231, 29 ]
python
en
['en', 'error', 'th']
False
is_aware
(value)
Determine if a given datetime.datetime is aware. The concept is defined in Python's docs: https://docs.python.org/library/datetime.html#datetime.tzinfo Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic.
Determine if a given datetime.datetime is aware.
def is_aware(value): """ Determine if a given datetime.datetime is aware. The concept is defined in Python's docs: https://docs.python.org/library/datetime.html#datetime.tzinfo Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic....
[ "def", "is_aware", "(", "value", ")", ":", "return", "value", ".", "utcoffset", "(", ")", "is", "not", "None" ]
[ 237, 0 ]
[ 247, 40 ]
python
en
['en', 'error', 'th']
False
is_naive
(value)
Determine if a given datetime.datetime is naive. The concept is defined in Python's docs: https://docs.python.org/library/datetime.html#datetime.tzinfo Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic.
Determine if a given datetime.datetime is naive.
def is_naive(value): """ Determine if a given datetime.datetime is naive. The concept is defined in Python's docs: https://docs.python.org/library/datetime.html#datetime.tzinfo Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic....
[ "def", "is_naive", "(", "value", ")", ":", "return", "value", ".", "utcoffset", "(", ")", "is", "None" ]
[ 250, 0 ]
[ 260, 36 ]
python
en
['en', 'error', 'th']
False
make_aware
(value, timezone=None, is_dst=None)
Make a naive datetime.datetime in a given time zone aware.
Make a naive datetime.datetime in a given time zone aware.
def make_aware(value, timezone=None, is_dst=None): """Make a naive datetime.datetime in a given time zone aware.""" if timezone is None: timezone = get_current_timezone() if hasattr(timezone, 'localize'): # This method is available for pytz time zones. return timezone.localize(value,...
[ "def", "make_aware", "(", "value", ",", "timezone", "=", "None", ",", "is_dst", "=", "None", ")", ":", "if", "timezone", "is", "None", ":", "timezone", "=", "get_current_timezone", "(", ")", "if", "hasattr", "(", "timezone", ",", "'localize'", ")", ":", ...
[ 263, 0 ]
[ 276, 45 ]
python
en
['en', 'en', 'en']
True
make_naive
(value, timezone=None)
Make an aware datetime.datetime naive in a given time zone.
Make an aware datetime.datetime naive in a given time zone.
def make_naive(value, timezone=None): """Make an aware datetime.datetime naive in a given time zone.""" if timezone is None: timezone = get_current_timezone() # Emulate the behavior of astimezone() on Python < 3.6. if is_naive(value): raise ValueError("make_naive() cannot be applied to a...
[ "def", "make_naive", "(", "value", ",", "timezone", "=", "None", ")", ":", "if", "timezone", "is", "None", ":", "timezone", "=", "get_current_timezone", "(", ")", "# Emulate the behavior of astimezone() on Python < 3.6.", "if", "is_naive", "(", "value", ")", ":", ...
[ 279, 0 ]
[ 286, 58 ]
python
en
['en', 'en', 'en']
True
ResourceSerializer.get_max_price_per_hour
(self, obj)
Backwards compatibility for 'max_price_per_hour' field that is now deprecated
Backwards compatibility for 'max_price_per_hour' field that is now deprecated
def get_max_price_per_hour(self, obj): """Backwards compatibility for 'max_price_per_hour' field that is now deprecated""" return obj.max_price if obj.price_type == Resource.PRICE_TYPE_HOURLY else None
[ "def", "get_max_price_per_hour", "(", "self", ",", "obj", ")", ":", "return", "obj", ".", "max_price", "if", "obj", ".", "price_type", "==", "Resource", ".", "PRICE_TYPE_HOURLY", "else", "None" ]
[ 183, 4 ]
[ 185, 86 ]
python
en
['en', 'en', 'en']
True
ResourceSerializer.get_min_price_per_hour
(self, obj)
Backwards compatibility for 'min_price_per_hour' field that is now deprecated
Backwards compatibility for 'min_price_per_hour' field that is now deprecated
def get_min_price_per_hour(self, obj): """Backwards compatibility for 'min_price_per_hour' field that is now deprecated""" return obj.min_price if obj.price_type == Resource.PRICE_TYPE_HOURLY else None
[ "def", "get_min_price_per_hour", "(", "self", ",", "obj", ")", ":", "return", "obj", ".", "min_price", "if", "obj", ".", "price_type", "==", "Resource", ".", "PRICE_TYPE_HOURLY", "else", "None" ]
[ 187, 4 ]
[ 189, 86 ]
python
en
['en', 'en', 'en']
True
ResourceSerializer.get_extra_fields
(self, includes, context)
Define extra fields that can be included via query parameters. Method from ExtraDataMixin.
Define extra fields that can be included via query parameters. Method from ExtraDataMixin.
def get_extra_fields(self, includes, context): """ Define extra fields that can be included via query parameters. Method from ExtraDataMixin.""" extra_fields = {} if 'accessibility_summaries' in includes: extra_fields['accessibility_summaries'] = serializers.SerializerMethodField() ...
[ "def", "get_extra_fields", "(", "self", ",", "includes", ",", "context", ")", ":", "extra_fields", "=", "{", "}", "if", "'accessibility_summaries'", "in", "includes", ":", "extra_fields", "[", "'accessibility_summaries'", "]", "=", "serializers", ".", "SerializerM...
[ 191, 4 ]
[ 198, 27 ]
python
en
['en', 'en', 'en']
True
ResourceSerializer.get_accessibility_summaries
(self, obj)
Get accessibility summaries for the resource. If data is missing for any accessibility viewpoints, unknown values are returned for those.
Get accessibility summaries for the resource. If data is missing for any accessibility viewpoints, unknown values are returned for those.
def get_accessibility_summaries(self, obj): """ Get accessibility summaries for the resource. If data is missing for any accessibility viewpoints, unknown values are returned for those. """ if 'accessibility_viewpoint_cache' in self.context: accessibility_viewpoints = self.co...
[ "def", "get_accessibility_summaries", "(", "self", ",", "obj", ")", ":", "if", "'accessibility_viewpoint_cache'", "in", "self", ".", "context", ":", "accessibility_viewpoints", "=", "self", ".", "context", "[", "'accessibility_viewpoint_cache'", "]", "else", ":", "a...
[ 200, 4 ]
[ 221, 87 ]
python
en
['en', 'en', 'en']
True
ResourceSerializer.parse_parameters
(self)
Parses request time parameters for serializing available_hours, opening_hours and reservations
Parses request time parameters for serializing available_hours, opening_hours and reservations
def parse_parameters(self): """ Parses request time parameters for serializing available_hours, opening_hours and reservations """ params = self.context['request'].query_params times = parse_query_time_range(params) if 'duration' in params: try: ...
[ "def", "parse_parameters", "(", "self", ")", ":", "params", "=", "self", ".", "context", "[", "'request'", "]", ".", "query_params", "times", "=", "parse_query_time_range", "(", "params", ")", "if", "'duration'", "in", "params", ":", "try", ":", "times", "...
[ 306, 4 ]
[ 327, 38 ]
python
en
['en', 'error', 'th']
False
payment_provider
(provider_base_config)
When it doesn't matter if request is contained within provider the fixture can still be used
When it doesn't matter if request is contained within provider the fixture can still be used
def payment_provider(provider_base_config): """When it doesn't matter if request is contained within provider the fixture can still be used""" return BamboraPayformProvider(config=provider_base_config)
[ "def", "payment_provider", "(", "provider_base_config", ")", ":", "return", "BamboraPayformProvider", "(", "config", "=", "provider_base_config", ")" ]
[ 38, 0 ]
[ 40, 62 ]
python
en
['en', 'en', 'en']
True
create_bambora_provider
(provider_base_config, request, return_url=None)
Helper for creating a new instance of provider with request and optional return_url contained within
Helper for creating a new instance of provider with request and optional return_url contained within
def create_bambora_provider(provider_base_config, request, return_url=None): """Helper for creating a new instance of provider with request and optional return_url contained within""" return BamboraPayformProvider(config=provider_base_config, request=request, ...
[ "def", "create_bambora_provider", "(", "provider_base_config", ",", "request", ",", "return_url", "=", "None", ")", ":", "return", "BamboraPayformProvider", "(", "config", "=", "provider_base_config", ",", "request", "=", "request", ",", "return_url", "=", "return_u...
[ 43, 0 ]
[ 47, 56 ]
python
en
['en', 'en', 'en']
True
mocked_response_create
(*args, **kwargs)
Mock Bambora auth token responses based on provider url
Mock Bambora auth token responses based on provider url
def mocked_response_create(*args, **kwargs): """Mock Bambora auth token responses based on provider url""" class MockResponse: def __init__(self, data, status_code=200): self.json_data = data self.status_code = status_code def json(self): return self.json_dat...
[ "def", "mocked_response_create", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "class", "MockResponse", ":", "def", "__init__", "(", "self", ",", "data", ",", "status_code", "=", "200", ")", ":", "self", ".", "json_data", "=", "data", "self", "....
[ 50, 0 ]
[ 72, 10 ]
python
en
['en', 'no', 'en']
True
test_initiate_payment_success
(provider_base_config, order_with_products)
Test the request creator constructs the payload base and returns a url that contains a token
Test the request creator constructs the payload base and returns a url that contains a token
def test_initiate_payment_success(provider_base_config, order_with_products): """Test the request creator constructs the payload base and returns a url that contains a token""" rf = RequestFactory() request = rf.post(RESERVATION_LIST_URL) payment_provider = create_bambora_provider(provider_base_config,...
[ "def", "test_initiate_payment_success", "(", "provider_base_config", ",", "order_with_products", ")", ":", "rf", "=", "RequestFactory", "(", ")", "request", "=", "rf", ".", "post", "(", "RESERVATION_LIST_URL", ")", "payment_provider", "=", "create_bambora_provider", "...
[ 75, 0 ]
[ 85, 30 ]
python
en
['en', 'en', 'en']
True
test_initiate_payment_error_unavailable
(provider_base_config, order_with_products)
Test the request creator raises service unavailable if request doesn't go through
Test the request creator raises service unavailable if request doesn't go through
def test_initiate_payment_error_unavailable(provider_base_config, order_with_products): """Test the request creator raises service unavailable if request doesn't go through""" rf = RequestFactory() request = rf.post(RESERVATION_LIST_URL) provider_base_config['RESPA_PAYMENTS_BAMBORA_API_URL'] = FAKE_BAM...
[ "def", "test_initiate_payment_error_unavailable", "(", "provider_base_config", ",", "order_with_products", ")", ":", "rf", "=", "RequestFactory", "(", ")", "request", "=", "rf", ".", "post", "(", "RESERVATION_LIST_URL", ")", "provider_base_config", "[", "'RESPA_PAYMENTS...
[ 88, 0 ]
[ 99, 78 ]
python
en
['en', 'en', 'en']
True
test_handle_initiate_payment_success
(payment_provider)
Test the response handler recognizes success and adds token as part of the returned url
Test the response handler recognizes success and adds token as part of the returned url
def test_handle_initiate_payment_success(payment_provider): """Test the response handler recognizes success and adds token as part of the returned url""" r = json.loads("""{ "result": 0, "token": "abc123", "type": "e-payment" }""") return_value = payment_provider.handle_initiate_...
[ "def", "test_handle_initiate_payment_success", "(", "payment_provider", ")", ":", "r", "=", "json", ".", "loads", "(", "\"\"\"{\n \"result\": 0,\n \"token\": \"abc123\",\n \"type\": \"e-payment\"\n }\"\"\"", ")", "return_value", "=", "payment_provider", ".",...
[ 102, 0 ]
[ 110, 37 ]
python
en
['en', 'en', 'en']
True
test_handle_initiate_payment_error_validation
(payment_provider)
Test the response handler raises PayloadValidationError as expected
Test the response handler raises PayloadValidationError as expected
def test_handle_initiate_payment_error_validation(payment_provider): """Test the response handler raises PayloadValidationError as expected""" r = json.loads("""{ "result": 1, "type": "e-payment", "errors": ["Invalid auth code"] }""") with pytest.raises(PayloadValidationError): ...
[ "def", "test_handle_initiate_payment_error_validation", "(", "payment_provider", ")", ":", "r", "=", "json", ".", "loads", "(", "\"\"\"{\n \"result\": 1,\n \"type\": \"e-payment\",\n \"errors\": [\"Invalid auth code\"]\n }\"\"\"", ")", "with", "pytest", ".", ...
[ 113, 0 ]
[ 121, 51 ]
python
en
['en', 'en', 'en']
True
test_handle_initiate_payment_error_duplicate
(payment_provider)
Test the response handler raises DuplicateOrderError as expected
Test the response handler raises DuplicateOrderError as expected
def test_handle_initiate_payment_error_duplicate(payment_provider): """Test the response handler raises DuplicateOrderError as expected""" r = json.loads("""{ "result": 2, "type": "e-payment" }""") with pytest.raises(DuplicateOrderError): payment_provider.handle_initiate_payment(...
[ "def", "test_handle_initiate_payment_error_duplicate", "(", "payment_provider", ")", ":", "r", "=", "json", ".", "loads", "(", "\"\"\"{\n \"result\": 2,\n \"type\": \"e-payment\"\n }\"\"\"", ")", "with", "pytest", ".", "raises", "(", "DuplicateOrderError", ")...
[ 124, 0 ]
[ 131, 51 ]
python
en
['en', 'en', 'en']
True
test_handle_initiate_payment_error_unavailable
(payment_provider)
Test the response handler raises ServiceUnavailableError as expected
Test the response handler raises ServiceUnavailableError as expected
def test_handle_initiate_payment_error_unavailable(payment_provider): """Test the response handler raises ServiceUnavailableError as expected""" r = json.loads("""{ "result": 10, "type": "e-payment" }""") with pytest.raises(ServiceUnavailableError): payment_provider.handle_initia...
[ "def", "test_handle_initiate_payment_error_unavailable", "(", "payment_provider", ")", ":", "r", "=", "json", ".", "loads", "(", "\"\"\"{\n \"result\": 10,\n \"type\": \"e-payment\"\n }\"\"\"", ")", "with", "pytest", ".", "raises", "(", "ServiceUnavailableError...
[ 134, 0 ]
[ 141, 51 ]
python
en
['en', 'lb', 'en']
True
test_handle_initiate_payment_error_unknown_code
(payment_provider)
Test the response handler raises UnknownReturnCodeError as expected
Test the response handler raises UnknownReturnCodeError as expected
def test_handle_initiate_payment_error_unknown_code(payment_provider): """Test the response handler raises UnknownReturnCodeError as expected""" r = json.loads("""{ "result": 15, "type": "e-payment", "test": "unrecognized extra stuff" }""") with pytest.raises(UnknownReturnCodeErr...
[ "def", "test_handle_initiate_payment_error_unknown_code", "(", "payment_provider", ")", ":", "r", "=", "json", ".", "loads", "(", "\"\"\"{\n \"result\": 15,\n \"type\": \"e-payment\",\n \"test\": \"unrecognized extra stuff\"\n }\"\"\"", ")", "with", "pytest", ...
[ 144, 0 ]
[ 152, 51 ]
python
en
['en', 'en', 'en']
True
test_payload_add_products_success
(payment_provider, order_with_products)
Test the products and total order price data is added correctly into payload
Test the products and total order price data is added correctly into payload
def test_payload_add_products_success(payment_provider, order_with_products): """Test the products and total order price data is added correctly into payload""" payload = {} payment_provider.payload_add_products(payload, order_with_products) assert 'amount' in payload assert payload.get('amount') ==...
[ "def", "test_payload_add_products_success", "(", "payment_provider", ",", "order_with_products", ")", ":", "payload", "=", "{", "}", "payment_provider", ".", "payload_add_products", "(", "payload", ",", "order_with_products", ")", "assert", "'amount'", "in", "payload", ...
[ 155, 0 ]
[ 174, 32 ]
python
en
['en', 'en', 'en']
True
test_payload_add_customer_success
(payment_provider, order_with_products)
Test the customer data from order is added correctly into payload
Test the customer data from order is added correctly into payload
def test_payload_add_customer_success(payment_provider, order_with_products): """Test the customer data from order is added correctly into payload""" payload = {} payment_provider.payload_add_customer(payload, order_with_products) assert 'email' in payload assert payload.get('email') == 'test@examp...
[ "def", "test_payload_add_customer_success", "(", "payment_provider", ",", "order_with_products", ")", ":", "payload", "=", "{", "}", "payment_provider", ".", "payload_add_customer", "(", "payload", ",", "order_with_products", ")", "assert", "'email'", "in", "payload", ...
[ 177, 0 ]
[ 192, 53 ]
python
en
['en', 'en', 'en']
True
test_payload_add_auth_code_success
(payment_provider, order_with_products)
Test the auth code is added correctly into the payload
Test the auth code is added correctly into the payload
def test_payload_add_auth_code_success(payment_provider, order_with_products): """Test the auth code is added correctly into the payload""" payload = { 'api_key': payment_provider.config.get(RESPA_PAYMENTS_BAMBORA_API_KEY), 'order_number': order_with_products.order_number } payment_provi...
[ "def", "test_payload_add_auth_code_success", "(", "payment_provider", ",", "order_with_products", ")", ":", "payload", "=", "{", "'api_key'", ":", "payment_provider", ".", "config", ".", "get", "(", "RESPA_PAYMENTS_BAMBORA_API_KEY", ")", ",", "'order_number'", ":", "o...
[ 195, 0 ]
[ 202, 32 ]
python
en
['en', 'en', 'en']
True
test_calculate_auth_code_success
(payment_provider)
Test the auth code calculation returns a correct hash
Test the auth code calculation returns a correct hash
def test_calculate_auth_code_success(payment_provider): """Test the auth code calculation returns a correct hash""" data = 'dummy-key|abc123' calculated_code = payment_provider.calculate_auth_code(data) assert hmac.compare_digest(calculated_code, 'A8894068C4E17BFD55E68B2148CF555800773C673D19FA0648101C1E...
[ "def", "test_calculate_auth_code_success", "(", "payment_provider", ")", ":", "data", "=", "'dummy-key|abc123'", "calculated_code", "=", "payment_provider", ".", "calculate_auth_code", "(", "data", ")", "assert", "hmac", ".", "compare_digest", "(", "calculated_code", ",...
[ 205, 0 ]
[ 209, 115 ]
python
en
['en', 'en', 'en']
True
test_check_new_payment_authcode_success
(payment_provider)
Test the helper is able to extract necessary values from a request and compare authcodes
Test the helper is able to extract necessary values from a request and compare authcodes
def test_check_new_payment_authcode_success(payment_provider): """Test the helper is able to extract necessary values from a request and compare authcodes""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D...
[ "def", "test_check_new_payment_authcode_success", "(", "payment_provider", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D2372234D462'", ",", "'RETURN...
[ 212, 0 ]
[ 223, 63 ]
python
en
['en', 'en', 'en']
True
test_check_new_payment_authcode_invalid
(payment_provider)
Test the helper fails when params do not match the auth code
Test the helper fails when params do not match the auth code
def test_check_new_payment_authcode_invalid(payment_provider): """Test the helper fails when params do not match the auth code""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D2372234D462', 'RETUR...
[ "def", "test_check_new_payment_authcode_invalid", "(", "payment_provider", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D2372234D462'", ",", "'RETURN...
[ 226, 0 ]
[ 237, 67 ]
python
en
['en', 'en', 'en']
True
test_handle_success_request_return_url_missing
(provider_base_config, order_with_products)
Test the handler returns a bad request object if return URL is missing from params
Test the handler returns a bad request object if return URL is missing from params
def test_handle_success_request_return_url_missing(provider_base_config, order_with_products): """Test the handler returns a bad request object if return URL is missing from params""" params = { 'AUTHCODE': '905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D2372234D462', 'RETURN_CODE': '0', ...
[ "def", "test_handle_success_request_return_url_missing", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'AUTHCODE'", ":", "'905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D2372234D462'", ",", "'RETURN_CODE'", ":", "'0'", ",", "'ORDE...
[ 240, 0 ]
[ 254, 38 ]
python
en
['en', 'en', 'en']
True
test_handle_success_request_order_not_found
(provider_base_config, order_with_products)
Test request helper returns a failure url when order can't be found
Test request helper returns a failure url when order can't be found
def test_handle_success_request_order_not_found(provider_base_config, order_with_products): """Test request helper returns a failure url when order can't be found""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '83F6C12E8D894B433CB2B6A2A56709CF0AE26665768ED...
[ "def", "test_handle_success_request_order_not_found", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'83F6C12E8D894B433CB2B6A2A56709CF0AE26665768ED...
[ 257, 0 ]
[ 271, 51 ]
python
en
['en', 'co', 'en']
True
test_handle_success_request_success
(provider_base_config, order_with_products)
Test request helper changes the order status to confirmed Also check it returns a success url with order number
Test request helper changes the order status to confirmed
def test_handle_success_request_success(provider_base_config, order_with_products): """Test request helper changes the order status to confirmed Also check it returns a success url with order number""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '905E...
[ "def", "test_handle_success_request_success", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'905EDAC01C9E6921250C21BE23CDC53633A4D66BE7241A3B5DA1D...
[ 274, 0 ]
[ 293, 81 ]
python
en
['en', 'en', 'en']
True
test_handle_success_request_payment_failed
(provider_base_config, order_with_products)
Test request helper changes the order status to rejected and returns a failure url
Test request helper changes the order status to rejected and returns a failure url
def test_handle_success_request_payment_failed(provider_base_config, order_with_products): """Test request helper changes the order status to rejected and returns a failure url""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': 'ED754E8F2E7FE0CC269B9F6A1C197F1...
[ "def", "test_handle_success_request_payment_failed", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'ED754E8F2E7FE0CC269B9F6A1C197F19B8393F37A1B63B...
[ 296, 0 ]
[ 312, 51 ]
python
en
['en', 'en', 'en']
True
test_handle_success_request_status_not_updated
(provider_base_config, order_with_products)
Test request helper reacts to transaction status update error by returning a failure url
Test request helper reacts to transaction status update error by returning a failure url
def test_handle_success_request_status_not_updated(provider_base_config, order_with_products): """Test request helper reacts to transaction status update error by returning a failure url""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': 'D9170B2C0C0F36E467517...
[ "def", "test_handle_success_request_status_not_updated", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'D9170B2C0C0F36E467517E0DF2FC7D89BBC7237597...
[ 315, 0 ]
[ 330, 51 ]
python
en
['en', 'en', 'en']
True
test_handle_success_request_maintenance_break
(provider_base_config, order_with_products)
Test request helper reacts to maintenance break error by returning a failure url
Test request helper reacts to maintenance break error by returning a failure url
def test_handle_success_request_maintenance_break(provider_base_config, order_with_products): """Test request helper reacts to maintenance break error by returning a failure url""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '144662CEBD9861D4526C4147D10FB6...
[ "def", "test_handle_success_request_maintenance_break", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'144662CEBD9861D4526C4147D10FB6C50FE1E024537...
[ 333, 0 ]
[ 348, 51 ]
python
en
['en', 'de', 'en']
True
test_handle_success_request_unknown_error
(provider_base_config, order_with_products)
Test request helper returns a failure url when status code is unknown
Test request helper returns a failure url when status code is unknown
def test_handle_success_request_unknown_error(provider_base_config, order_with_products): """Test request helper returns a failure url when status code is unknown""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '3CD17A51E89C0A6DDDCA743AFCBD5DC40E8FF8AB97756...
[ "def", "test_handle_success_request_unknown_error", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'3CD17A51E89C0A6DDDCA743AFCBD5DC40E8FF8AB9775608...
[ 351, 0 ]
[ 365, 51 ]
python
en
['en', 'de', 'en']
True
test_handle_notify_request_order_not_found
(provider_base_config, order_with_products)
Test request notify helper returns http 204 when order can't be found
Test request notify helper returns http 204 when order can't be found
def test_handle_notify_request_order_not_found(provider_base_config, order_with_products): """Test request notify helper returns http 204 when order can't be found""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '83F6C12E8D894B433CB2B6A2A56709CF0AE26665768E...
[ "def", "test_handle_notify_request_order_not_found", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'83F6C12E8D894B433CB2B6A2A56709CF0AE26665768ED7...
[ 368, 0 ]
[ 382, 38 ]
python
en
['en', 'en', 'en']
True
test_handle_notify_request_success
(provider_base_config, order_with_products, order_state, expected_order_state)
Test request notify helper returns http 204 and order status is correct when successful
Test request notify helper returns http 204 and order status is correct when successful
def test_handle_notify_request_success(provider_base_config, order_with_products, order_state, expected_order_state): """Test request notify helper returns http 204 and order status is correct when successful""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': ...
[ "def", "test_handle_notify_request_success", "(", "provider_base_config", ",", "order_with_products", ",", "order_state", ",", "expected_order_state", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", ...
[ 391, 0 ]
[ 409, 38 ]
python
en
['en', 'en', 'en']
True
test_handle_notify_request_payment_failed
(provider_base_config, order_with_products, order_state, expected_order_state)
Test request notify helper returns http 204 and order status is correct when payment fails
Test request notify helper returns http 204 and order status is correct when payment fails
def test_handle_notify_request_payment_failed(provider_base_config, order_with_products, order_state, expected_order_state): """Test request notify helper returns http 204 and order status is correct when payment fails""" params = { 'RESPA_UI_RETURN_URL': 'h...
[ "def", "test_handle_notify_request_payment_failed", "(", "provider_base_config", ",", "order_with_products", ",", "order_state", ",", "expected_order_state", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ...
[ 418, 0 ]
[ 437, 38 ]
python
en
['en', 'en', 'en']
True
test_handle_notify_request_unknown_error
(provider_base_config, order_with_products)
Test request notify helper returns http 204 when status code is unknown
Test request notify helper returns http 204 when status code is unknown
def test_handle_notify_request_unknown_error(provider_base_config, order_with_products): """Test request notify helper returns http 204 when status code is unknown""" params = { 'RESPA_UI_RETURN_URL': 'http%3A%2F%2F127.0.0.1%3A8000%2Fv1', 'AUTHCODE': '3CD17A51E89C0A6DDDCA743AFCBD5DC40E8FF8AB9775...
[ "def", "test_handle_notify_request_unknown_error", "(", "provider_base_config", ",", "order_with_products", ")", ":", "params", "=", "{", "'RESPA_UI_RETURN_URL'", ":", "'http%3A%2F%2F127.0.0.1%3A8000%2Fv1'", ",", "'AUTHCODE'", ":", "'3CD17A51E89C0A6DDDCA743AFCBD5DC40E8FF8AB97756089...
[ 440, 0 ]
[ 454, 38 ]
python
en
['en', 'de', 'en']
True
factorial
(n)
Return the factorial of n, an exact integer >= 0. >>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0 Factorials of floats are OK, but ...
Return the factorial of n, an exact integer >= 0.
def factorial(n): """Return the factorial of n, an exact integer >= 0. >>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0 Factoria...
[ "def", "factorial", "(", "n", ")", ":", "import", "math", "if", "not", "n", ">=", "0", ":", "raise", "ValueError", "(", "\"n must be >= 0\"", ")", "if", "math", ".", "floor", "(", "n", ")", "!=", "n", ":", "raise", "ValueError", "(", "\"n must be exact...
[ 6, 0 ]
[ 45, 17 ]
python
en
['en', 'lb', 'en']
True
login
(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None)
Displays the login form and handles the login action.
Displays the login form and handles the login action.
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None): """ Displays the login form and handles the login action. """ redirect_to = request.POST.get(r...
[ "def", "login", "(", "request", ",", "template_name", "=", "'registration/login.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "authentication_form", "=", "AuthenticationForm", ",", "current_app", "=", "None", ",", "extra_context", "=", "None", "...
[ 27, 0 ]
[ 63, 52 ]
python
en
['en', 'error', 'th']
False
logout
(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None)
Logs out the user and displays 'You are logged out' message.
Logs out the user and displays 'You are logged out' message.
def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None): """ Logs out the user and displays 'You are logged out' message. """ auth_logout(request) if next_page i...
[ "def", "logout", "(", "request", ",", "next_page", "=", "None", ",", "template_name", "=", "'registration/logged_out.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "current_app", "=", "None", ",", "extra_context", "=", "None", ")", ":", "auth...
[ 66, 0 ]
[ 99, 32 ]
python
en
['en', 'error', 'th']
False
logout_then_login
(request, login_url=None, current_app=None, extra_context=None)
Logs out the user if they are logged in. Then redirects to the log-in page.
Logs out the user if they are logged in. Then redirects to the log-in page.
def logout_then_login(request, login_url=None, current_app=None, extra_context=None): """ Logs out the user if they are logged in. Then redirects to the log-in page. """ if not login_url: login_url = settings.LOGIN_URL login_url = resolve_url(login_url) return logout(request, login_url, ...
[ "def", "logout_then_login", "(", "request", ",", "login_url", "=", "None", ",", "current_app", "=", "None", ",", "extra_context", "=", "None", ")", ":", "if", "not", "login_url", ":", "login_url", "=", "settings", ".", "LOGIN_URL", "login_url", "=", "resolve...
[ 102, 0 ]
[ 109, 91 ]
python
en
['en', 'error', 'th']
False
redirect_to_login
(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME)
Redirects the user to the login page, passing the given 'next' page
Redirects the user to the login page, passing the given 'next' page
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Redirects the user to the login page, passing the given 'next' page """ resolved_url = resolve_url(login_url or settings.LOGIN_URL) login_url_parts = list(urlparse(resolved_url)) if r...
[ "def", "redirect_to_login", "(", "next", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "resolved_url", "=", "resolve_url", "(", "login_url", "or", "settings", ".", "LOGIN_URL", ")", "login_url_parts", "=", "list",...
[ 112, 0 ]
[ 125, 60 ]
python
en
['en', 'error', 'th']
False
password_reset_confirm
(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redirect=None, ...
View that checks the hash in a password reset link and presents a form for entering a new password.
View that checks the hash in a password reset link and presents a form for entering a new password.
def password_reset_confirm(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redire...
[ "def", "password_reset_confirm", "(", "request", ",", "uidb64", "=", "None", ",", "token", "=", "None", ",", "template_name", "=", "'registration/password_reset_confirm.html'", ",", "token_generator", "=", "default_token_generator", ",", "set_password_form", "=", "SetPa...
[ 200, 0 ]
[ 244, 52 ]
python
en
['en', 'error', 'th']
False
NoFastDeleteCollector.can_fast_delete
(self, *args, **kwargs)
Always load related objects to display them when showing confirmation.
Always load related objects to display them when showing confirmation.
def can_fast_delete(self, *args, **kwargs): """ Always load related objects to display them when showing confirmation. """ return False
[ "def", "can_fast_delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "False" ]
[ 75, 4 ]
[ 79, 20 ]
python
en
['en', 'error', 'th']
False
SourceMap._index_for
(self, minified_src: str)
Return the source map index for minified_src, loading it if not already loaded.
Return the source map index for minified_src, loading it if not already loaded.
def _index_for(self, minified_src: str) -> Optional[sourcemap.SourceMapDecoder]: """Return the source map index for minified_src, loading it if not already loaded.""" # Prevent path traversal assert ".." not in minified_src and "/" not in minified_src if minified_src not in sel...
[ "def", "_index_for", "(", "self", ",", "minified_src", ":", "str", ")", "->", "Optional", "[", "sourcemap", ".", "SourceMapDecoder", "]", ":", "# Prevent path traversal", "assert", "\"..\"", "not", "in", "minified_src", "and", "\"/\"", "not", "in", "minified_src...
[ 16, 4 ]
[ 41, 46 ]
python
en
['en', 'en', 'en']
True
Wheel.__init__
(self, filename)
:raises InvalidWheelFilename: when the filename is invalid for a wheel
:raises InvalidWheelFilename: when the filename is invalid for a wheel
def __init__(self, filename): # type: (str) -> None """ :raises InvalidWheelFilename: when the filename is invalid for a wheel """ wheel_info = self.wheel_file_re.match(filename) if not wheel_info: raise InvalidWheelFilename( "{} is not a valid...
[ "def", "__init__", "(", "self", ",", "filename", ")", ":", "# type: (str) -> None", "wheel_info", "=", "self", ".", "wheel_file_re", ".", "match", "(", "filename", ")", "if", "not", "wheel_info", ":", "raise", "InvalidWheelFilename", "(", "\"{} is not a valid whee...
[ 24, 4 ]
[ 48, 9 ]
python
en
['en', 'error', 'th']
False
Wheel.get_formatted_file_tags
(self)
Return the wheel's tags as a sorted list of strings.
Return the wheel's tags as a sorted list of strings.
def get_formatted_file_tags(self): # type: () -> List[str] """Return the wheel's tags as a sorted list of strings.""" return sorted(str(tag) for tag in self.file_tags)
[ "def", "get_formatted_file_tags", "(", "self", ")", ":", "# type: () -> List[str]", "return", "sorted", "(", "str", "(", "tag", ")", "for", "tag", "in", "self", ".", "file_tags", ")" ]
[ 50, 4 ]
[ 53, 57 ]
python
en
['en', 'en', 'en']
True
Wheel.support_index_min
(self, tags)
Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags. For example, if there are 8 supported tags and one of the file tags is first in the list, then return 0. :param tags: the PEP 425 tags to check the wheel against, in orde...
Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags.
def support_index_min(self, tags): # type: (List[Tag]) -> int """Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags. For example, if there are 8 supported tags and one of the file tags is first in the list, then ret...
[ "def", "support_index_min", "(", "self", ",", "tags", ")", ":", "# type: (List[Tag]) -> int", "return", "min", "(", "tags", ".", "index", "(", "tag", ")", "for", "tag", "in", "self", ".", "file_tags", "if", "tag", "in", "tags", ")" ]
[ 55, 4 ]
[ 69, 76 ]
python
en
['en', 'en', 'en']
True
Wheel.supported
(self, tags)
Return whether the wheel is compatible with one of the given tags. :param tags: the PEP 425 tags to check the wheel against.
Return whether the wheel is compatible with one of the given tags.
def supported(self, tags): # type: (List[Tag]) -> bool """Return whether the wheel is compatible with one of the given tags. :param tags: the PEP 425 tags to check the wheel against. """ return not self.file_tags.isdisjoint(tags)
[ "def", "supported", "(", "self", ",", "tags", ")", ":", "# type: (List[Tag]) -> bool", "return", "not", "self", ".", "file_tags", ".", "isdisjoint", "(", "tags", ")" ]
[ 71, 4 ]
[ 77, 50 ]
python
en
['en', 'en', 'en']
True
is_discoverable
(label)
Check if a test label points to a python package or file directory. Relative labels like "." and ".." are seen as directories.
Check if a test label points to a python package or file directory.
def is_discoverable(label): """ Check if a test label points to a python package or file directory. Relative labels like "." and ".." are seen as directories. """ try: mod = import_module(label) except (ImportError, TypeError): pass else: return hasattr(mod, '__path_...
[ "def", "is_discoverable", "(", "label", ")", ":", "try", ":", "mod", "=", "import_module", "(", "label", ")", "except", "(", "ImportError", ",", "TypeError", ")", ":", "pass", "else", ":", "return", "hasattr", "(", "mod", ",", "'__path__'", ")", "return"...
[ 157, 0 ]
[ 170, 48 ]
python
en
['en', 'error', 'th']
False
dependency_ordered
(test_databases, dependencies)
Reorder test_databases into an order that honors the dependencies described in TEST[DEPENDENCIES].
Reorder test_databases into an order that honors the dependencies described in TEST[DEPENDENCIES].
def dependency_ordered(test_databases, dependencies): """ Reorder test_databases into an order that honors the dependencies described in TEST[DEPENDENCIES]. """ ordered_test_databases = [] resolved_databases = set() # Maps db signature to dependencies of all it's aliases dependencies_ma...
[ "def", "dependency_ordered", "(", "test_databases", ",", "dependencies", ")", ":", "ordered_test_databases", "=", "[", "]", "resolved_databases", "=", "set", "(", ")", "# Maps db signature to dependencies of all it's aliases", "dependencies_map", "=", "{", "}", "# sanity ...
[ 173, 0 ]
[ 212, 33 ]
python
en
['en', 'error', 'th']
False
reorder_suite
(suite, classes)
Reorders a test suite by test type. `classes` is a sequence of types All tests of type classes[0] are placed first, then tests of type classes[1], etc. Tests with no match in classes are placed last.
Reorders a test suite by test type.
def reorder_suite(suite, classes): """ Reorders a test suite by test type. `classes` is a sequence of types All tests of type classes[0] are placed first, then tests of type classes[1], etc. Tests with no match in classes are placed last. """ class_count = len(classes) suite_class = ty...
[ "def", "reorder_suite", "(", "suite", ",", "classes", ")", ":", "class_count", "=", "len", "(", "classes", ")", "suite_class", "=", "type", "(", "suite", ")", "bins", "=", "[", "suite_class", "(", ")", "for", "i", "in", "range", "(", "class_count", "+"...
[ 215, 0 ]
[ 230, 18 ]
python
en
['en', 'error', 'th']
False
partition_suite
(suite, classes, bins)
Partitions a test suite by test type. classes is a sequence of types bins is a sequence of TestSuites, one more than classes Tests of type classes[i] are added to bins[i], tests with no match found in classes are place in bins[-1]
Partitions a test suite by test type.
def partition_suite(suite, classes, bins): """ Partitions a test suite by test type. classes is a sequence of types bins is a sequence of TestSuites, one more than classes Tests of type classes[i] are added to bins[i], tests with no match found in classes are place in bins[-1] """ suit...
[ "def", "partition_suite", "(", "suite", ",", "classes", ",", "bins", ")", ":", "suite_class", "=", "type", "(", "suite", ")", "for", "test", "in", "suite", ":", "if", "isinstance", "(", "test", ",", "suite_class", ")", ":", "partition_suite", "(", "test"...
[ 233, 0 ]
[ 253, 38 ]
python
en
['en', 'error', 'th']
False
DiscoverRunner.teardown_databases
(self, old_config, **kwargs)
Destroys all the non-mirror databases.
Destroys all the non-mirror databases.
def teardown_databases(self, old_config, **kwargs): """ Destroys all the non-mirror databases. """ old_names, mirrors = old_config for connection, old_name, destroy in old_names: if destroy: connection.creation.destroy_test_db(old_name, self.verbosity,...
[ "def", "teardown_databases", "(", "self", ",", "old_config", ",", "*", "*", "kwargs", ")", ":", "old_names", ",", "mirrors", "=", "old_config", "for", "connection", ",", "old_name", ",", "destroy", "in", "old_names", ":", "if", "destroy", ":", "connection", ...
[ 120, 4 ]
[ 127, 90 ]
python
en
['en', 'error', 'th']
False
DiscoverRunner.run_tests
(self, test_labels, extra_tests=None, **kwargs)
Run the unit tests for all the test labels in the provided list. Test labels should be dotted Python paths to test modules, test classes, or test methods. A list of 'extra' tests may also be provided; these tests will be added to the test suite. Returns the number of ...
Run the unit tests for all the test labels in the provided list.
def run_tests(self, test_labels, extra_tests=None, **kwargs): """ Run the unit tests for all the test labels in the provided list. Test labels should be dotted Python paths to test modules, test classes, or test methods. A list of 'extra' tests may also be provided; these tests...
[ "def", "run_tests", "(", "self", ",", "test_labels", ",", "extra_tests", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "setup_test_environment", "(", ")", "suite", "=", "self", ".", "build_suite", "(", "test_labels", ",", "extra_tests", ")",...
[ 136, 4 ]
[ 154, 47 ]
python
en
['en', 'error', 'th']
False
XViewMiddleware.process_view
(self, request, view_func, view_args, view_kwargs)
If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, return a responsewith an x-view header indicating the view function. This is used to lookup the view function for an arbitrary page.
If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, return a responsewith an x-view header indicating the view function. This is used to lookup the view function for an arbitrary page.
def process_view(self, request, view_func, view_args, view_kwargs): """ If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, return a responsewith an x-view header indicating the view function. This is used to lookup the view functi...
[ "def", "process_view", "(", "self", ",", "request", ",", "view_func", ",", "view_args", ",", "view_kwargs", ")", ":", "assert", "hasattr", "(", "request", ",", "'user'", ")", ",", "(", "\"The XView middleware requires authentication middleware to be \"", "\"installed....
[ 11, 4 ]
[ 29, 27 ]
python
en
['en', 'error', 'th']
False
ArticleAdmin.changelist_view
(self, request)
Test that extra_context works
Test that extra_context works
def changelist_view(self, request): "Test that extra_context works" return super(ArticleAdmin, self).changelist_view( request, extra_context={ 'extra_var': 'Hello!' } )
[ "def", "changelist_view", "(", "self", ",", "request", ")", ":", "return", "super", "(", "ArticleAdmin", ",", "self", ")", ".", "changelist_view", "(", "request", ",", "extra_context", "=", "{", "'extra_var'", ":", "'Hello!'", "}", ")" ]
[ 96, 4 ]
[ 102, 9 ]
python
en
['en', 'en', 'en']
True
RowLevelChangePermissionModelAdmin.has_change_permission
(self, request, obj=None)
Only allow changing objects with even id number
Only allow changing objects with even id number
def has_change_permission(self, request, obj=None): """ Only allow changing objects with even id number """ return request.user.is_staff and (obj is not None) and (obj.id % 2 == 0)
[ "def", "has_change_permission", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "request", ".", "user", ".", "is_staff", "and", "(", "obj", "is", "not", "None", ")", "and", "(", "obj", ".", "id", "%", "2", "==", "0", ")" ]
[ 135, 4 ]
[ 137, 80 ]
python
en
['en', 'en', 'en']
True
CustomArticleAdmin.changelist_view
(self, request)
Test that extra_context works
Test that extra_context works
def changelist_view(self, request): "Test that extra_context works" return super(CustomArticleAdmin, self).changelist_view( request, extra_context={ 'extra_var': 'Hello!' } )
[ "def", "changelist_view", "(", "self", ",", "request", ")", ":", "return", "super", "(", "CustomArticleAdmin", ",", "self", ")", ".", "changelist_view", "(", "request", ",", "extra_context", "=", "{", "'extra_var'", ":", "'Hello!'", "}", ")" ]
[ 151, 4 ]
[ 157, 9 ]
python
en
['en', 'en', 'en']
True
get_path_info
(environ)
Return the HTTP request's PATH_INFO as a string.
Return the HTTP request's PATH_INFO as a string.
def get_path_info(environ): """Return the HTTP request's PATH_INFO as a string.""" path_info = get_bytes_from_wsgi(environ, 'PATH_INFO', '/') return repercent_broken_unicode(path_info).decode()
[ "def", "get_path_info", "(", "environ", ")", ":", "path_info", "=", "get_bytes_from_wsgi", "(", "environ", ",", "'PATH_INFO'", ",", "'/'", ")", "return", "repercent_broken_unicode", "(", "path_info", ")", ".", "decode", "(", ")" ]
[ 151, 0 ]
[ 155, 55 ]
python
en
['en', 'en', 'en']
True
get_script_name
(environ)
Return the equivalent of the HTTP request's SCRIPT_NAME environment variable. If Apache mod_rewrite is used, return what would have been the script name prior to any rewriting (so it's the script name as seen from the client's perspective), unless the FORCE_SCRIPT_NAME setting is set (to anything)....
Return the equivalent of the HTTP request's SCRIPT_NAME environment variable. If Apache mod_rewrite is used, return what would have been the script name prior to any rewriting (so it's the script name as seen from the client's perspective), unless the FORCE_SCRIPT_NAME setting is set (to anything)....
def get_script_name(environ): """ Return the equivalent of the HTTP request's SCRIPT_NAME environment variable. If Apache mod_rewrite is used, return what would have been the script name prior to any rewriting (so it's the script name as seen from the client's perspective), unless the FORCE_SCRIPT_N...
[ "def", "get_script_name", "(", "environ", ")", ":", "if", "settings", ".", "FORCE_SCRIPT_NAME", "is", "not", "None", ":", "return", "settings", ".", "FORCE_SCRIPT_NAME", "# If Apache's mod_rewrite had a whack at the URL, Apache set either", "# SCRIPT_URL or REDIRECT_URL to the ...
[ 158, 0 ]
[ 186, 31 ]
python
en
['en', 'error', 'th']
False
get_bytes_from_wsgi
(environ, key, default)
Get a value from the WSGI environ dictionary as bytes. key and default should be strings.
Get a value from the WSGI environ dictionary as bytes.
def get_bytes_from_wsgi(environ, key, default): """ Get a value from the WSGI environ dictionary as bytes. key and default should be strings. """ value = environ.get(key, default) # Non-ASCII values in the WSGI environ are arbitrarily decoded with # ISO-8859-1. This is wrong for Django webs...
[ "def", "get_bytes_from_wsgi", "(", "environ", ",", "key", ",", "default", ")", ":", "value", "=", "environ", ".", "get", "(", "key", ",", "default", ")", "# Non-ASCII values in the WSGI environ are arbitrarily decoded with", "# ISO-8859-1. This is wrong for Django websites ...
[ 189, 0 ]
[ 199, 37 ]
python
en
['en', 'error', 'th']
False
get_str_from_wsgi
(environ, key, default)
Get a value from the WSGI environ dictionary as str. key and default should be str objects.
Get a value from the WSGI environ dictionary as str.
def get_str_from_wsgi(environ, key, default): """ Get a value from the WSGI environ dictionary as str. key and default should be str objects. """ value = get_bytes_from_wsgi(environ, key, default) return value.decode(errors='replace')
[ "def", "get_str_from_wsgi", "(", "environ", ",", "key", ",", "default", ")", ":", "value", "=", "get_bytes_from_wsgi", "(", "environ", ",", "key", ",", "default", ")", "return", "value", ".", "decode", "(", "errors", "=", "'replace'", ")" ]
[ 202, 0 ]
[ 209, 41 ]
python
en
['en', 'error', 'th']
False
identify_best_dialect
(dialects, compiler)
Returns the first C++ dialect accepted by the compiler in the sequence, assuming the "best" dialects appear first. If no dialects are accepted, the result is the last dialect in the sequence (we assume that this error will be displayed to the user - during compile time - in an informative way).
Returns the first C++ dialect accepted by the compiler in the sequence, assuming the "best" dialects appear first.
def identify_best_dialect(dialects, compiler): """Returns the first C++ dialect accepted by the compiler in the sequence, assuming the "best" dialects appear first. If no dialects are accepted, the result is the last dialect in the sequence (we assume that this error will be displayed to the user - dur...
[ "def", "identify_best_dialect", "(", "dialects", ",", "compiler", ")", ":", "for", "d", "in", "dialects", ":", "if", "dialect_supported", "(", "d", ",", "compiler", ")", ":", "return", "d", "return", "d" ]
[ 118, 0 ]
[ 131, 12 ]
python
en
['en', 'en', 'en']
True
infer_dpdk_machine
(user_cflags)
Infer the DPDK machine identifier (e.g., 'ivb') from the space-separated string of user cflags by scraping the value of `-march` if it is present. The default if no architecture is indicated is 'native'.
Infer the DPDK machine identifier (e.g., 'ivb') from the space-separated string of user cflags by scraping the value of `-march` if it is present.
def infer_dpdk_machine(user_cflags): """Infer the DPDK machine identifier (e.g., 'ivb') from the space-separated string of user cflags by scraping the value of `-march` if it is present. The default if no architecture is indicated is 'native'. """ arch = 'native' # `-march` may be repeated, an...
[ "def", "infer_dpdk_machine", "(", "user_cflags", ")", ":", "arch", "=", "'native'", "# `-march` may be repeated, and we want the last one.", "# strip features, leave only the arch: armv8-a+crc+crypto -> armv8-a", "for", "flag", "in", "user_cflags", ".", "split", "(", ")", ":", ...
[ 137, 0 ]
[ 160, 38 ]
python
en
['en', 'en', 'en']
True
GetStorageClassTests.test_get_filesystem_storage
(self)
get_storage_class returns the class for a storage backend name/path.
get_storage_class returns the class for a storage backend name/path.
def test_get_filesystem_storage(self): """ get_storage_class returns the class for a storage backend name/path. """ self.assertEqual( get_storage_class('django.core.files.storage.FileSystemStorage'), FileSystemStorage)
[ "def", "test_get_filesystem_storage", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "get_storage_class", "(", "'django.core.files.storage.FileSystemStorage'", ")", ",", "FileSystemStorage", ")" ]
[ 37, 4 ]
[ 43, 30 ]
python
en
['en', 'error', 'th']
False
GetStorageClassTests.test_get_invalid_storage_module
(self)
get_storage_class raises an error if the requested import don't exist.
get_storage_class raises an error if the requested import don't exist.
def test_get_invalid_storage_module(self): """ get_storage_class raises an error if the requested import don't exist. """ with six.assertRaisesRegex(self, ImportError, "No module named '?storage'?"): get_storage_class('storage.NonExistingStorage')
[ "def", "test_get_invalid_storage_module", "(", "self", ")", ":", "with", "six", ".", "assertRaisesRegex", "(", "self", ",", "ImportError", ",", "\"No module named '?storage'?\"", ")", ":", "get_storage_class", "(", "'storage.NonExistingStorage'", ")" ]
[ 45, 4 ]
[ 50, 59 ]
python
en
['en', 'error', 'th']
False
GetStorageClassTests.test_get_nonexisting_storage_class
(self)
get_storage_class raises an error if the requested class don't exist.
get_storage_class raises an error if the requested class don't exist.
def test_get_nonexisting_storage_class(self): """ get_storage_class raises an error if the requested class don't exist. """ self.assertRaises(ImportError, get_storage_class, 'django.core.files.storage.NonExistingStorage')
[ "def", "test_get_nonexisting_storage_class", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "ImportError", ",", "get_storage_class", ",", "'django.core.files.storage.NonExistingStorage'", ")" ]
[ 52, 4 ]
[ 57, 73 ]
python
en
['en', 'error', 'th']
False
GetStorageClassTests.test_get_nonexisting_storage_module
(self)
get_storage_class raises an error if the requested module don't exist.
get_storage_class raises an error if the requested module don't exist.
def test_get_nonexisting_storage_module(self): """ get_storage_class raises an error if the requested module don't exist. """ # Error message may or may not be the fully qualified path. with six.assertRaisesRegex(self, ImportError, "No module named '?(django.core....
[ "def", "test_get_nonexisting_storage_module", "(", "self", ")", ":", "# Error message may or may not be the fully qualified path.", "with", "six", ".", "assertRaisesRegex", "(", "self", ",", "ImportError", ",", "\"No module named '?(django.core.files.)?non_existing_storage'?\"", ")...
[ 59, 4 ]
[ 67, 76 ]
python
en
['en', 'error', 'th']
False
FileStorageTests.test_empty_location
(self)
Makes sure an exception is raised if the location is empty
Makes sure an exception is raised if the location is empty
def test_empty_location(self): """ Makes sure an exception is raised if the location is empty """ storage = self.storage_class(location='') self.assertEqual(storage.base_location, '') self.assertEqual(storage.location, upath(os.getcwd()))
[ "def", "test_empty_location", "(", "self", ")", ":", "storage", "=", "self", ".", "storage_class", "(", "location", "=", "''", ")", "self", ".", "assertEqual", "(", "storage", ".", "base_location", ",", "''", ")", "self", ".", "assertEqual", "(", "storage"...
[ 102, 4 ]
[ 108, 62 ]
python
en
['en', 'error', 'th']
False
FileStorageTests.test_file_access_options
(self)
Standard file access options are available, and work as expected.
Standard file access options are available, and work as expected.
def test_file_access_options(self): """ Standard file access options are available, and work as expected. """ self.assertFalse(self.storage.exists('storage_test')) f = self.storage.open('storage_test', 'w') f.write('storage contents') f.close() self.assert...
[ "def", "test_file_access_options", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "self", ".", "storage", ".", "exists", "(", "'storage_test'", ")", ")", "f", "=", "self", ".", "storage", ".", "open", "(", "'storage_test'", ",", "'w'", ")", "f",...
[ 110, 4 ]
[ 125, 61 ]
python
en
['en', 'error', 'th']
False
FileStorageTests.test_file_accessed_time
(self)
File storage returns a Datetime object for the last accessed time of a file.
File storage returns a Datetime object for the last accessed time of a file.
def test_file_accessed_time(self): """ File storage returns a Datetime object for the last accessed time of a file. """ self.assertFalse(self.storage.exists('test.file')) f = ContentFile('custom contents') f_name = self.storage.save('test.file', f) atime ...
[ "def", "test_file_accessed_time", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "self", ".", "storage", ".", "exists", "(", "'test.file'", ")", ")", "f", "=", "ContentFile", "(", "'custom contents'", ")", "f_name", "=", "self", ".", "storage", "....
[ 127, 4 ]
[ 141, 35 ]
python
en
['en', 'error', 'th']
False
FileStorageTests.test_file_created_time
(self)
File storage returns a Datetime object for the creation time of a file.
File storage returns a Datetime object for the creation time of a file.
def test_file_created_time(self): """ File storage returns a Datetime object for the creation time of a file. """ self.assertFalse(self.storage.exists('test.file')) f = ContentFile('custom contents') f_name = self.storage.save('test.file', f) ctime = self...
[ "def", "test_file_created_time", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "self", ".", "storage", ".", "exists", "(", "'test.file'", ")", ")", "f", "=", "ContentFile", "(", "'custom contents'", ")", "f_name", "=", "self", ".", "storage", "."...
[ 143, 4 ]
[ 158, 35 ]
python
en
['en', 'error', 'th']
False
FileStorageTests.test_file_modified_time
(self)
File storage returns a Datetime object for the last modified time of a file.
File storage returns a Datetime object for the last modified time of a file.
def test_file_modified_time(self): """ File storage returns a Datetime object for the last modified time of a file. """ self.assertFalse(self.storage.exists('test.file')) f = ContentFile('custom contents') f_name = self.storage.save('test.file', f) mtime ...
[ "def", "test_file_modified_time", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "self", ".", "storage", ".", "exists", "(", "'test.file'", ")", ")", "f", "=", "ContentFile", "(", "'custom contents'", ")", "f_name", "=", "self", ".", "storage", "....
[ 160, 4 ]
[ 175, 35 ]
python
en
['en', 'error', 'th']
False