예제 #1
0
def test_object_type():
    """Test object type."""
    types = ['publication', 'poster', 'presentation', 'software', 'dataset',
             'image', 'video']

    def _assert_obj(obj):
        assert '$schema' in obj
        assert 'id' in obj
        assert 'internal_id' in obj
        assert 'title' in obj
        assert 'en' in obj['title']
        assert 'title_plural' in obj
        assert 'en' in obj['title_plural']
        assert 'schema.org' in obj
        for c in obj.get('children', []):
            _assert_obj(c)

    for t in types:
        _assert_obj(ObjectType.get(t))

    assert ObjectType.get('invalid') is None
예제 #2
0
def test_object_type(app):
    """Test object type."""
    types = ["publication", "poster", "presentation", "software", "dataset", "image", "video"]

    def _assert_obj(obj):
        assert "$schema" in obj
        assert "id" in obj
        assert "internal_id" in obj
        assert "title" in obj
        assert "en" in obj["title"]
        assert "title_plural" in obj
        assert "en" in obj["title_plural"]
        assert "schema.org" in obj
        for c in obj.get("children", []):
            _assert_obj(c)

    for t in types:
        _assert_obj(ObjectType.get(t))
예제 #3
0
파일: ext.py 프로젝트: xbee/zenodo
 def resource_types(self):
     """Create an object list with the available resource types."""
     resource_list = []
     for item in itervalues(ObjectType.index_id):
         internal_id = item['internal_id']
         parent = item.get('parent')
         if parent:
             resolved_parent = ObjectType.get(item['internal_id'])['parent']
             parent_type_title = resolved_parent['title']['en']
         elif item.get('children'):
             continue
         else:
             parent_type_title = ''
         resource_list.append({
             'type': parent_type_title,
             'title': item['title']['en'],
             'id': internal_id
         })
     resource_list.sort(key=lambda x: x['title'])
     return resource_list