def test_should_return_correct_domain_for_spring_2019(self): filename = "spring_2019.txt" student = Student(filename) courses_offered = CoursesOffered(student) csp = CSP(courses_offered) domains = csp.domains self.assertEqual( { 'S1C1': ['CS400'], 'S1C2': ['CS404'], 'S1C3': [ 'CS327', 'CS331', 'CS335', 'CS355', 'CS400', 'CS401', 'CS404', 'CS413', 'CS415', 'CS417', 'CS419', 'CS442', 'CS490' ], 'S2C1': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S2C2': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S2C3': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S3C1': ['CS331', 'CS345', 'CS460'], 'S3C2': ['CS401', 'CS413'], 'S3C3': ['CS335', 'CS415', 'CS419'], 'S4C1': [ 'CS327', 'CS331', 'CS335', 'CS355', 'CS400', 'CS404', 'CS408', 'CS411', 'CS412', 'CS417', 'CS420', 'CS442', 'CS490' ], 'S4C2': ['CS420'], 'S4C3': ['CS490'] }, domains, "test that should get the correct domain for spring 2019")
def test_should_return_correct_domain_for_fall_2008(self): filename = "fall_2008.txt" student = Student(filename) courses_offered = CoursesOffered(student) csp = CSP(courses_offered) domains = csp.domains self.assertEqual( { 'S1C1': ['CS400'], 'S1C2': ['CS404'], 'S1C3': [ 'CS325', 'CS331', 'CS335', 'CS345', 'CS400', 'CS404', 'CS412', 'CS416', 'CS420', 'CS440', 'CS460', 'MATH305', 'ECON401', 'CS490' ], 'S2C1': ['CS331', 'CS355', 'CS442'], 'S2C2': ['CS401', 'CS413'], 'S2C3': ['CS335', 'CS415', 'CS419'], 'S3C1': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S3C2': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S3C3': ['CS331', 'CS412', 'CS420', 'CS440', 'CS490'], 'S4C1': [ 'CS325', 'CS331', 'CS335', 'CS345', 'CS400', 'CS401', 'CS404', 'CS413', 'CS415', 'CS419', 'CS460', 'CS490' ], 'S4C2': ['CS420'], 'S4C3': ['CS490'] }, domains, "test that should get the correct domain for fall 2008")
def test_should_return_correct_domain_for_summer_2019(self): filename = "summer_2019.txt" student = Student(filename) courses_offered = CoursesOffered(student) domains = courses_offered.get_domain_for_variables() self.assertEqual( { 'S1C1': ['CS400'], 'S1C2': ['CS404'], 'S1C3': [ 'CS325', 'CS331', 'CS335', 'CS345', 'CS400', 'CS401', 'CS404', 'CS413', 'CS415', 'CS419', 'CS460', 'CS490' ], 'S2C1': ['CS331', 'CS355', 'CS442'], 'S2C2': ['CS411', 'CS412'], 'S2C3': ['CS335'], 'S3C1': ['CS331', 'CS401', 'CS413', 'CS415', 'CS419', 'CS490'], 'S3C2': ['CS331', 'CS401', 'CS413', 'CS415', 'CS419', 'CS490'], 'S3C3': ['CS331', 'CS401', 'CS413', 'CS415', 'CS419', 'CS490'], 'S4C1': [ 'CS325', 'CS331', 'CS335', 'CS345', 'CS400', 'CS404', 'CS412', 'CS416', 'CS420', 'CS440', 'CS460', 'MATH305', 'ECON401', 'CS490' ], 'S4C2': ['CS420'], 'S4C3': ['CS490'] }, domains, "test that should get the correct domain for summer 2019")
def test_should_return_true_for_consistency(self): assignment = { 'S1C1': 'CS400', 'S1C2': 'CS404', 'S2C3': 'CS335', 'S4C2': 'CS420', 'S4C3': 'CS490', 'S2C2': 'CS411', 'S2C1': 'CS331' } candidate = "S3C2" val = "419" filename = "fall_2021.txt" student = Student(filename) courses_offered = CoursesOffered(student) csp = CSP(courses_offered) test_consistency = csp.is_assign_consistent(candidate, val, assignment) self.assertEqual(True, test_consistency, "consistency test epic fail :D ")
def __init__(self, filename): self.student = Student(filename) self.csp = CSP(self.student) self.solutions = [] self.__compute_student_plans() self.__show_results()