def test_schedule_from_standards_dict():
    """Test the ScheduleRuleset from_standards_dict method."""
    filename = './tests/standards/OpenStudio_Standards_schedule.json'
    if filename:
        with open(filename, 'r') as f:
            data_store = json.load(f)
    office_sch = ScheduleRuleset.from_standards_dict(
        data_store['Large Office Bldg Occ'])

    assert office_sch.name == "Large Office Bldg Occ"
    assert office_sch.default_day_schedule.name == "Large Office Bldg Occ_Default"
    assert len(office_sch.default_day_schedule) == 10
    assert len(office_sch.schedule_rules) == 2
    assert office_sch.summer_designday_schedule.name == 'Large Office Bldg Occ_SmrDsn'
    assert len(office_sch.summer_designday_schedule) == 3
    assert office_sch.winter_designday_schedule.name == 'Large Office Bldg Occ_WntrDsn'
    assert len(office_sch.winter_designday_schedule) == 1
    assert office_sch.schedule_type_limit == schedule_types.fractional
def schedule_by_name(schedule_name):
    """Get a schedule from the library given its name.

    Args:
        schedule_name: A text string for the name of the schedule.
    """
    try:
        return _schedules[schedule_name]
    except KeyError:
        try:
            _sched_dict = _schedule_standards_dict[schedule_name]
        except KeyError:
            raise ValueError(
                '"{}" was not found in the schedule library.'.format(
                    schedule_name))

    # create the Python object from the standards gem dictionary
    _sched_obj = ScheduleRuleset.from_standards_dict(_sched_dict)
    _sched_obj.lock()
    _schedules[schedule_name] = _sched_obj  # load faster next time
    return _sched_obj