Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/service.py
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | for match in matches: | ||||
match['from_revision'] = hashutil.hash_to_hex(match['from_revision']) | match['from_revision'] = hashutil.hash_to_hex(match['from_revision']) | ||||
result = converters.from_origin( | result = converters.from_origin( | ||||
storage.origin_get({'id': match.pop('id')})) | storage.origin_get({'id': match.pop('id')})) | ||||
result['metadata'] = match | result['metadata'] = match | ||||
results.append(result) | results.append(result) | ||||
return results | return results | ||||
def lookup_origin_intrinsic_metadata(origin_dict): | |||||
"""Return intrinsic metadata for origin whose origin_id matches given | |||||
origin_id. | |||||
Args: | |||||
origin_dict: origin's dict with keys ('type' AND 'url') | |||||
Returns: | |||||
origin metadata. | |||||
""" | |||||
twitu: I am still making this call to convert url and type information to id of origin, because… | |||||
origin_info = storage.origin_get(origin_dict) | |||||
if not origin_info: | |||||
msg = 'Origin with type %s and url %s not found!' % \ | |||||
(origin_dict['type'], origin_dict['url']) | |||||
raise NotFoundExc(msg) | |||||
Done Inline ActionsThe test is successful when I change this line to origin_ids = [1]. Otherwise I receive a KeyError for id. This indicates that storage.origin_get is not being mocked and is not returning the correct values. The expected value is a dictionary containing key id. I am unable to figure out why this is not behaving as expected. twitu: The test is successful when I change this line to `origin_ids = [1]`. Otherwise I receive a… | |||||
Done Inline ActionsI added print(origin_info) here to record to log the contents of origin_info. .tox/py3/lib/python3.5/site-packages/swh/web/tests/api/views/test_origin.py {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'repo_with_submodules', 'type': 'git'} {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} {'url': 'https://github.com/memononen/libtess2', 'type': 'git'} <-- removed repeated value for clarity --> What I got back does not contain the any key for id, though it should be part of the returned values according to API docs. twitu: I added `print(origin_info)` here to record to log the contents of origin_info.
```
. | |||||
origin_ids = [origin_info['id']] | |||||
match = idx_storage.origin_intrinsic_metadata_get(origin_ids)[0] | |||||
return match['metadata'] | |||||
def lookup_person(person_id): | def lookup_person(person_id): | ||||
"""Return information about the person with id person_id. | """Return information about the person with id person_id. | ||||
Args: | Args: | ||||
person_id as string | person_id as string | ||||
Returns: | Returns: | ||||
person information as dict. | person information as dict. | ||||
▲ Show 20 Lines • Show All 756 Lines • Show Last 20 Lines |
I am still making this call to convert url and type information to id of origin, because intrinsic metadata is only searchable by id