api_client = <rest_framework.test.APIClient object at 0x7fd36376fc50>
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7fd362c39f98>
content = {'blake2s256': '9b668f5083d78d2e32211fb9f4cc33d689a88332627858f39aa80d43e5f40b13', 'data': '# highlightjs-line-numbers...ions);\n```\n\n---\n© 2018 Yauheni Pakala | MIT License\n', 'encoding': 'utf-8', 'hljs_language': 'markdown', ...}
def test_api_raw_content(api_client, archive_data, content):
> _test_api_raw_hash(api_client, archive_data, content, "cnt")
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_raw.py:44:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_raw.py:30: in _test_api_raw_hash
url_args={"swhid": f"swh:1:{object_ty}:{object_id}"},
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:95: in reverse
viewname, urlconf=urlconf, kwargs=url_args, current_app=current_app
.tox/py3/lib/python3.7/site-packages/django/urls/base.py:90: in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <URLResolver 'swh.web.urls' (None:None) '^/'>
lookup_view = 'api-1-raw-object', _prefix = '/', args = ()
kwargs = {'swhid': "swh:1:cnt:{'sha256': 'a448e5e2bb8e20979c893a44581164aa3a0c6843dc1bf1607f9df34b4a71dbf8', 'sha1': 'b950e0254...```js\\nhljs.lineNumbersBlock(myCodeBlock, myOptions);\\n```\\n\\n---\\n© 2018 Yauheni Pakala | MIT License\\n'}"}
possibilities = [([('api/1/raw/%(swhid)s/', ['swhid'])], 'api/1/raw/(?P<swhid>swh:1:[a-z]{3}:[0-9a-z]{40})/$', {}, {})]
possibility = [('api/1/raw/%(swhid)s/', ['swhid'])]
pattern = 'api/1/raw/(?P<swhid>swh:1:[a-z]{3}:[0-9a-z]{40})/$', defaults = {}
converters = {}, result = 'api/1/raw/%(swhid)s/', params = ['swhid']
candidate_subs = {'swhid': "swh:1:cnt:{'sha256': 'a448e5e2bb8e20979c893a44581164aa3a0c6843dc1bf1607f9df34b4a71dbf8', 'sha1': 'b950e0254...```js\\nhljs.lineNumbersBlock(myCodeBlock, myOptions);\\n```\\n\\n---\\n© 2018 Yauheni Pakala | MIT License\\n'}"}
text_candidate_subs = {'swhid': "swh:1:cnt:{'sha256': 'a448e5e2bb8e20979c893a44581164aa3a0c6843dc1bf1607f9df34b4a71dbf8', 'sha1': 'b950e0254...```js\\nhljs.lineNumbersBlock(myCodeBlock, myOptions);\\n```\\n\\n---\\n© 2018 Yauheni Pakala | MIT License\\n'}"}
k = 'swhid'
def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs):
if args and kwargs:
raise ValueError("Don't mix *args and **kwargs in call to reverse()!")
if not self._populated:
self._populate()
possibilities = self.reverse_dict.getlist(lookup_view)
for possibility, pattern, defaults, converters in possibilities:
for result, params in possibility:
if args:
if len(args) != len(params):
continue
candidate_subs = dict(zip(params, args))
else:
if set(kwargs).symmetric_difference(params).difference(defaults):
continue
if any(kwargs.get(k, v) != v for k, v in defaults.items()):
continue
candidate_subs = kwargs
# Convert the candidate subs to text using Converter.to_url().
text_candidate_subs = {}
for k, v in candidate_subs.items():
if k in converters:
text_candidate_subs[k] = converters[k].to_url(v)
else:
text_candidate_subs[k] = str(v)
# WSGI provides decoded URLs, without %xx escapes, and the URL
# resolver operates on such URLs. First substitute arguments
# without quoting to build a decoded URL and look for a match.
# Then, if we have a match, redo the substitution with quoted
# arguments in order to return a properly encoded URL.
candidate_pat = _prefix.replace('%', '%%') + result
if re.search('^%s%s' % (re.escape(_prefix), pattern), candidate_pat % text_candidate_subs):
# safe characters from `pchar` definition of RFC 3986
url = quote(candidate_pat % text_candidate_subs, safe=RFC3986_SUBDELIMS + '/~:@')
# Don't allow construction of scheme relative urls.
return escape_leading_slashes(url)
# lookup_view can be URL name or callable, but callables are not
# friendly in error messages.
m = getattr(lookup_view, '__module__', None)
n = getattr(lookup_view, '__name__', None)
if m is not None and n is not None:
lookup_view_s = "%s.%s" % (m, n)
else:
lookup_view_s = lookup_view
patterns = [pattern for (_, pattern, _, _) in possibilities]
if patterns:
if args:
arg_msg = "arguments '%s'" % (args,)
elif kwargs:
arg_msg = "keyword arguments '%s'" % (kwargs,)
else:
arg_msg = "no arguments"
msg = (
"Reverse for '%s' with %s not found. %d pattern(s) tried: %s" %
(lookup_view_s, arg_msg, len(patterns), patterns)
)
else:
msg = (
"Reverse for '%(view)s' not found. '%(view)s' is not "
"a valid view function or pattern name." % {'view': lookup_view_s}
)
> raise NoReverseMatch(msg)
E django.urls.exceptions.NoReverseMatch: Reverse for 'api-1-raw-object' with keyword arguments '{'swhid': 'swh:1:cnt:{\'sha256\': \'a448e5e2bb8e20979c893a44581164aa3a0c6843dc1bf1607f9df34b4a71dbf8\', \'sha1\': \'b950e0254ec88a55690ae752092ef7545f749100\', \'sha1_git\': \'1f7ff5ee8e7ccfa3ebefedcaad8ae448f14306be\', \'blake2s256\': \'9b668f5083d78d2e32211fb9f4cc33d689a88332627858f39aa80d43e5f40b13\', \'path\': \'651cd61acbf442c4da93970b11c0a6ad3f6c1bda/README.md\', \'mimetype\': \'text/html\', \'encoding\': \'utf-8\', \'hljs_language\': \'markdown\', \'raw_data\': b\'# highlightjs-line-numbers.js [![npm](https://img.shields.io/npm/v/highlightjs-line-numbers.js.png)](https://www.npmjs.com/package/highlightjs-line-numbers.js) ![npm](https://img.shields.io/npm/dw/highlightjs-line-numbers.js.png)\\n\\nHighlight.js line numbers plugin.\\n\\n[DEMO](http://wcoder.github.io/highlightjs-line-numbers.js/) | [S\\xd0\\xa1REENSHOTS](https://github.com/wcoder/highlightjs-line-numbers.js/issues/5)\\n\\n## Install\\n\\n#### Bower\\n```\\nbower install highlightjs-line-numbers.js\\n```\\n\\n#### Npm\\n```\\nnpm install highlightjs-line-numbers.js\\n```\\n\\n#### Getting the library from CDN\\n```html\\n<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.3.0/highlightjs-line-numbers.min.js"></script>\\n```\\n```html\\n<script src="//cdn.jsdelivr.net/npm/highlightjs-line-numbers.js@2.3.0/dist/highlightjs-line-numbers.min.js"></script>\\n```\\n\\n## Usage\\n\\nDownload plugin and include file after highlight.js:\\n```html\\n<script src="path/to/highlight.min.js"></script>\\n\\n<script src="path/to/highlightjs-line-numbers.min.js"></script>\\n```\\n\\nInitialize plugin after highlight.js:\\n```js\\nhljs.initHighlightingOnLoad();\\n\\nhljs.initLineNumbersOnLoad();\\n```\\n\\nHere\\xe2\\x80\\x99s an equivalent way to calling `initLineNumbersOnLoad` using jQuery:\\n```js\\n$(document).ready(function() {\\n $(\\\'code.hljs\\\').each(function(i, block) {\\n hljs.lineNumbersBlock(block);\\n });\\n});\\n```\\n\\nIf your needs cool style, add styles by taste:\\n```css\\n/* for block of numbers */\\ntd.hljs-ln-numbers {\\n -webkit-touch-callout: none;\\n -webkit-user-select: none;\\n -khtml-user-select: none;\\n -moz-user-select: none;\\n -ms-user-select: none;\\n user-select: none;\\n\\n text-align: center;\\n color: #ccc;\\n border-right: 1px solid #CCC;\\n vertical-align: top;\\n padding-right: 5px;\\n\\n /* your custom style here */\\n}\\n\\n/* for block of code */\\ntd.hljs-ln-code {\\n padding-left: 10px;\\n}\\n```\\n\\n## Options\\n\\nAfter version 2.1 plugin has optional parameter `options` - for custom setup.\\n\\nname | type | default value | description\\n-----------|---------|---------------|-----------------------\\nsingleLine | boolean | false | enable plugin for code block with one line\\n\\n#### Examples of using\\n\\n```js\\nhljs.initLineNumbersOnLoad({\\n singleLine: true\\n});\\n```\\n\\n```js\\nhljs.lineNumbersBlock(myCodeBlock, myOptions);\\n```\\n\\n---\\n© 2018 Yauheni Pakala | MIT License\\n\', \'data\': \'# highlightjs-line-numbers.js [![npm](https://img.shields.io/npm/v/highlightjs-line-numbers.js.png)](https://www.npmjs.com/package/highlightjs-line-numbers.js) ![npm](https://img.shields.io/npm/dw/highlightjs-line-numbers.js.png)\\n\\nHighlight.js line numbers plugin.\\n\\n[DEMO](http://wcoder.github.io/highlightjs-line-numbers.js/) | [SСREENSHOTS](https://github.com/wcoder/highlightjs-line-numbers.js/issues/5)\\n\\n## Install\\n\\n#### Bower\\n```\\nbower install highlightjs-line-numbers.js\\n```\\n\\n#### Npm\\n```\\nnpm install highlightjs-line-numbers.js\\n```\\n\\n#### Getting the library from CDN\\n```html\\n<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.3.0/highlightjs-line-numbers.min.js"></script>\\n```\\n```html\\n<script src="//cdn.jsdelivr.net/npm/highlightjs-line-numbers.js@2.3.0/dist/highlightjs-line-numbers.min.js"></script>\\n```\\n\\n## Usage\\n\\nDownload plugin and include file after highlight.js:\\n```html\\n<script src="path/to/highlight.min.js"></script>\\n\\n<script src="path/to/highlightjs-line-numbers.min.js"></script>\\n```\\n\\nInitialize plugin after highlight.js:\\n```js\\nhljs.initHighlightingOnLoad();\\n\\nhljs.initLineNumbersOnLoad();\\n```\\n\\nHere’s an equivalent way to calling `initLineNumbersOnLoad` using jQuery:\\n```js\\n$(document).ready(function() {\\n $(\\\'code.hljs\\\').each(function(i, block) {\\n hljs.lineNumbersBlock(block);\\n });\\n});\\n```\\n\\nIf your needs cool style, add styles by taste:\\n```css\\n/* for block of numbers */\\ntd.hljs-ln-numbers {\\n -webkit-touch-callout: none;\\n -webkit-user-select: none;\\n -khtml-user-select: none;\\n -moz-user-select: none;\\n -ms-user-select: none;\\n user-select: none;\\n\\n text-align: center;\\n color: #ccc;\\n border-right: 1px solid #CCC;\\n vertical-align: top;\\n padding-right: 5px;\\n\\n /* your custom style here */\\n}\\n\\n/* for block of code */\\ntd.hljs-ln-code {\\n padding-left: 10px;\\n}\\n```\\n\\n## Options\\n\\nAfter version 2.1 plugin has optional parameter `options` - for custom setup.\\n\\nname | type | default value | description\\n-----------|---------|---------------|-----------------------\\nsingleLine | boolean | false | enable plugin for code block with one line\\n\\n#### Examples of using\\n\\n```js\\nhljs.initLineNumbersOnLoad({\\n singleLine: true\\n});\\n```\\n\\n```js\\nhljs.lineNumbersBlock(myCodeBlock, myOptions);\\n```\\n\\n---\\n© 2018 Yauheni Pakala | MIT License\\n\'}'}' not found. 1 pattern(s) tried: ['api/1/raw/(?P<swhid>swh:1:[a-z]{3}:[0-9a-z]{40})/$']
.tox/py3/lib/python3.7/site-packages/django/urls/resolvers.py:677: NoReverseMatch
TEST RESULT
TEST RESULT
- Run At
- Apr 27 2022, 10:36 PM