def conference_title(self): """Get record's conference title.""" try: conference_record = get_conference_record(self.record) return get_conference_title(conference_record) except TypeError: pass
def test_get_conference_record(replace_refs): schema = load_schema('hep') control_number_schema = schema['properties']['control_number'] publication_info_schema = schema['properties']['publication_info'] conference_record = {'control_number': 972464} assert validate(conference_record['control_number'], control_number_schema) is None record = { 'publication_info': [ { 'conference_record': { '$ref': '/api/conferences/972464', }, }, ], } assert validate(record['publication_info'], publication_info_schema) is None replace_refs.return_value = conference_record expected = 972464 result = get_conference_record(record) assert expected == result['control_number']
def test_get_conference_record(replace_refs): schema = load_schema('hep') control_number_schema = schema['properties']['control_number'] publication_info_schema = schema['properties']['publication_info'] conference_record = {'control_number': 972464} assert validate(conference_record['control_number'], control_number_schema) is None record = { 'publication_info': [ { 'conference_record': { '$ref': 'http://localhost:5000/api/conferences/972464', }, }, ], } assert validate(record['publication_info'], publication_info_schema) is None replace_refs.return_value = conference_record expected = 972464 result = get_conference_record(record) assert expected == result['control_number']
def get_address(data, doc_type): conference = get_conference_record(data, default={}) pubinfo_city = get_value(conference, 'address[0].cities[0]') pubinfo_country_code = get_value(conference, 'address[0].country_code') if pubinfo_city and pubinfo_country_code: return pubinfo_city + ', ' + get_country_name_by_code(pubinfo_country_code, default=pubinfo_country_code) return get_value(data, 'imprints[0].place')
def get_address(data, doc_type): conference = get_conference_record(data, default={}) pubinfo_city = get_value(conference, 'address[0].cities[0]') pubinfo_country_code = get_value(conference, 'address[0].country_code') if pubinfo_city and pubinfo_country_code: return pubinfo_city + ', ' + get_country_name_by_code( pubinfo_country_code, default=pubinfo_country_code) return get_value(data, 'imprints[0].place')
def get_booktitle(data, doc_type): book_series_title = get_value(data, 'book_series.title[0]') conference_record = get_conference_record(data, default={}) return book_series_title or get_conference_title(conference_record, default=None)