# Path: inspire_schemas/api.py

# 
# Path: inspire_schemas/readers/conference.py
# class ConferenceReader(object):
#     """Conference record reader."""
# 
#     def __init__(self, record):
#         self.record = record
# 
#     @property
#     def city(self):
#         """Return the first city of a Conference record.
# 
#         Returns:
#             string: the first city of the Conference record.
# 
#         Examples:
#             >>> record = {'addresses': [{'cities': ['Tokyo']}]}
#             >>> ConferenceReader(record).city
#             'Tokyo'
# 
#         """
#         return get_value(self.record, 'addresses.cities[0][0]', default='')
# 
#     @property
#     def country(self):
#         """Return the first country of a Conference record.
# 
#         Returns:
#             string: the first country of the Conference record.
# 
#         Examples:
#             >>> record = {'address': [{'country_code': 'JP'}]}
#             >>> ConferenceReader(record).country
#             'jp'
# 
#         """
#         return get_value(
#             self.record,
#             'addresses.country_code[0]',
#             default=''
#         ).lower()
# 
#     @property
#     def end_date(self):
#         """Return the closing date of a conference record.
# 
#         Returns:
#             string: the closing date of the Conference record.
# 
#         Examples:
#             >>> record = {'closing_date': '1999-11-19'}
#             >>> ConferenceReader(record).end_date
#             '1999-11-19'
# 
#         """
#         return self.record.get('closing_date', '')
# 
#     @property
#     def start_date(self):
#         """Return the opening date of a conference record.
# 
#         Returns:
#             string: the opening date of the Conference record.
# 
#         Examples:
#             >>> record = {'opening_date': '1999-11-16'}
#             >>> ConferenceReader(record).start_date
#             '1999-11-16'
# 
#         """
#         return self.record.get('opening_date', '')


from inspire_schemas.api import load_schema, validate
from inspire_schemas.readers.conference import ConferenceReader

    record = {
        'addresses': [
            {
                'place_name': 'Lido di Venezia',
            },
            {
                'cities': [
                    'Venice',
                ],
            },
        ],
    }
    assert validate(record['addresses'], subschema) is None

    expected = 'Venice'
    result = ConferenceReader(record).city

    assert expected == result


def test_country():
    schema = load_schema('conferences')
    subschema = schema['properties']['addresses']

    record = {
        'addresses': [
            {'country_code': 'JP'},
        ],
    }

# Path: inspire_schemas/api.py

# 
# Path: inspire_schemas/readers/conference.py
# class ConferenceReader(object):
#     """Conference record reader."""
# 
#     def __init__(self, record):
#         self.record = record
# 
#     @property
#     def city(self):
#         """Return the first city of a Conference record.
# 
#         Returns:
#             string: the first city of the Conference record.
# 
#         Examples:
#             >>> record = {'addresses': [{'cities': ['Tokyo']}]}
#             >>> ConferenceReader(record).city
#             'Tokyo'
# 
#         """
#         return get_value(self.record, 'addresses.cities[0][0]', default='')
# 
#     @property
#     def country(self):
#         """Return the first country of a Conference record.
# 
#         Returns:
#             string: the first country of the Conference record.
# 
#         Examples:
#             >>> record = {'address': [{'country_code': 'JP'}]}
#             >>> ConferenceReader(record).country
#             'jp'
# 
#         """
#         return get_value(
#             self.record,
#             'addresses.country_code[0]',
#             default=''
#         ).lower()
# 
#     @property
#     def end_date(self):
#         """Return the closing date of a conference record.
# 
#         Returns:
#             string: the closing date of the Conference record.
# 
#         Examples:
#             >>> record = {'closing_date': '1999-11-19'}
#             >>> ConferenceReader(record).end_date
#             '1999-11-19'
# 
#         """
#         return self.record.get('closing_date', '')
# 
#     @property
#     def start_date(self):
#         """Return the opening date of a conference record.
# 
#         Returns:
#             string: the opening date of the Conference record.
# 
#         Examples:
#             >>> record = {'opening_date': '1999-11-16'}
#             >>> ConferenceReader(record).start_date
#             '1999-11-16'
# 
#         """
#         return self.record.get('opening_date', '')


# Path: tests/unit/test_conference_reader.py
from inspire_schemas.api import load_schema, validate
from inspire_schemas.readers.conference import ConferenceReader


    record = {
        'addresses': [
            {
                'place_name': 'Lido di Venezia',
            },
            {
                'cities': [
                    'Venice',
                ],
            },
        ],
    }
    assert validate(record['addresses'], subschema) is None

    expected = 'Venice'
    result = ConferenceReader(record).city

    assert expected == result


def test_country():
    schema = load_schema('conferences')
    subschema = schema['properties']['addresses']

    record = {
        'addresses': [
            {'country_code': 'JP'},
        ],
    }

    assert validate(record['addresses'], subschema) is None