seng499-company2 / algorithm1

MIT License
1 stars 1 forks source link

Implement validator with tests and update mock input data to support maxCapacity field #41

Closed sfaigan closed 1 year ago

sfaigan commented 1 year ago

This PR introduces schemas for all algorithm 1 objects defined in the algorithm specification found here. That is, all the objects that make up Schedule and Professor. Note that there is an optional field in CourseSection, maxCapacity, that is not in the spec because it is used by our system but not the other company's. Our algorithms are backwards compatible.

Additionally, this PR implements three functions to validate dicts against these schemas:

If the input is valid according to the spec, these functions will return True. If there is a spec violation, a SchemaError will be raised and the stack trace will include where the violation occurred in the input data.

A second parameter can be passed to all three validate functions called print_output, which is set to True by default. If print_output is True and the input is valid, a message will be printed to the console.

This PR also adjusts the mock input data to include the maxCapacity field, set to None for all courses. I kept the old input for testing backwards compatibility.

There are two tests:

Note: This PR introduces a dependency (schema==0.7.5), so a requirements.txt file has been added and the setup.py script has been updated to require the package.

Completes #42

Ckoelewyn commented 1 year ago

Hey we got Soft Constraints and Error handling PR's merged into main tonight. You're going to want to rebase this branch.