예제 #1
0
def validate(verbosity, input_dir, solution_dir, reload):
    logging.setup(verbosity)
    if solution_dir:
        session.folders['solution'] = Path(solution_dir)

    solution = io.import_solution(session.folders['solution'])

    if reload:
        resources = defn.resources()
        events, slots = events_and_slots(resources)
        original_solution = io.import_solution(session.folders['solution'])
        solution = [
            item for item in original_solution
            if item[0] < len(events)]
    else:
        solution = io.import_solution(session.folders['solution'])
        definition = io.import_schedule_definition(session.folders['solution'])
        events = definition['events']
        slots = definition['slots']

    logger.info('Validating schedule...')
    if is_valid_solution(solution, events, slots):
        logger.info('Imported solution is valid')
    else:
        for v in solution_violations(
                solution, definition['events'], definition['slots']):
            logger.error(v)
예제 #2
0
def test_valid_solution_passes(valid_solution, events, slots):
    assert validator.is_valid_solution(valid_solution, events, slots)
예제 #3
0
def test_empty_solution_fails(events, slots):
    assert not validator.is_valid_solution([], events, slots)