<commit_before>from __future__ import print_function
import unittest
import random
from genetic import *
import genetic.interface

filename = "tests/schedules/morning_class_test.xml"
sample_scheduler = interface.create_scheduler_from_file_test(filename)
sample_courses = interface.create_course_list_from_file_test(filename)

class TestScheduler(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        sample_scheduler.clear_constraints()

    def test_init(self):
        pass

    def test_clear_constraints(self):
        self.assertEquals(len(sample_scheduler.constraints), 0)
        self.assertEquals(sample_scheduler.max_fitness, 0)
        sample_scheduler.add_constraint("morning_classes", 30, 
                constraint.morning_class, [sample_scheduler.courses[0]]) 
        sample_scheduler.clear_constraints()
        self.assertEquals(len(sample_scheduler.constraints), 0)
        self.assertEquals(sample_scheduler.max_fitness, 0)

    def test_add_contsraint(self):
        sample_scheduler.add_constraint("morning_classes", 30, 
                constraint.morning_class, [sample_scheduler.courses[0]]) 
        sample_scheduler.add_constraint("morning_classes_2", 30, 
                constraint.morning_class, [sample_scheduler.courses[1]]) 
        self.assertEquals(len(sample_scheduler.constraints), 2)
        self.assertEquals(sample_scheduler.max_fitness, 60)

    def test_calc_fitness(self):
        sample_scheduler.add_constraint("lab_on_tr", 30, 
                constraint.lab_on_tr, [sample_scheduler.courses[1]])
        sample_scheduler.calc_fitness(sample_scheduler.weeks[0])
        self.assertEquals(sample_scheduler.weeks[0].fitness, 30)

    def test_find_respective_time_slot(self):
        pass
        """week = sample_scheduler.weeks[0]
        room = week.days[0].rooms[0]
        new_time_slot = scheduler.TimeSlot((10, 00), (11, 00), room)
        time_slot = sample_scheduler.find_respective_time_slot(new_time_slot, week)
        #The two time slots should have the same following attr's:
        self.assertEquals(new_time_slot.start_time, time_slot.start_time)
        self.assertEquals(new_time_slot.end_time, time_slot.end_time)
        self.assertEquals(new_time_slot.day, time_slot.day)
        self.assertEquals(new_time_slot.room, time_slot.room)
        #Make sure not exact same time slot obj"""

    def test_separate_by_credit(self):
        self.assertEquals(len(sample_scheduler.separated[1]), 2)
        self.assertEquals(len(sample_scheduler.separated[3]), 3)
        self.assertEquals(sample_scheduler.separated[1][0].code, "CSC 131 001")
        self.assertEquals(sample_scheduler.separated[3][0].code, "CSC 130 A")

    def test_replace_time_slots(self):
        pass

    def test_assess_inconsistences(self):
        #generic unit tests based on pre defined seeds<commit_msg>updates test to account for consolidated lab constraint<commit_after>from __future__ import print_function
import unittest
import random
from genetic import *
import genetic.interface

filename = "tests/schedules/morning_class_test.xml"
sample_scheduler = interface.create_scheduler_from_file_test(filename)
sample_courses = interface.create_course_list_from_file_test(filename)

class TestScheduler(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        sample_scheduler.clear_constraints()

    def test_init(self):
        pass

    def test_clear_constraints(self):
        self.assertEquals(len(sample_scheduler.constraints), 0)
        self.assertEquals(sample_scheduler.max_fitness, 0)
        sample_scheduler.add_constraint("morning_classes", 30, 
                constraint.morning_class, [sample_scheduler.courses[0]]) 
        sample_scheduler.clear_constraints()
        self.assertEquals(len(sample_scheduler.constraints), 0)
        self.assertEquals(sample_scheduler.max_fitness, 0)

    def test_add_contsraint(self):
        sample_scheduler.add_constraint("morning_classes", 30, 
                constraint.morning_class, [sample_scheduler.courses[0]]) 
        sample_scheduler.add_constraint("morning_classes_2", 30, 
                constraint.morning_class, [sample_scheduler.courses[1]]) 
        self.assertEquals(len(sample_scheduler.constraints), 2)
        self.assertEquals(sample_scheduler.max_fitness, 60)

    def test_calc_fitness(self):
        labs = []
        for each_course in sample_scheduler.courses:
            if each_course.is_lab:
                labs.append(each_course)
        sample_scheduler.add_constraint("lab_on_tr", 30, 
                constraint.lab_on_tr, [labs])
        sample_scheduler.calc_fitness(sample_scheduler.weeks[0])
        self.assertEquals(sample_scheduler.weeks[0].fitness, 30)

    def test_find_respective_time_slot(self):
        pass
        """week = sample_scheduler.weeks[0]
        room = week.days[0].rooms[0]
        new_time_slot = scheduler.TimeSlot((10, 00), (11, 00), room)
        time_slot = sample_scheduler.find_respective_time_slot(new_time_slot, week)
        #The two time slots should have the same following attr's:
        self.assertEquals(new_time_slot.start_time, time_slot.start_time)
        self.assertEquals(new_time_slot.end_time, time_slot.end_time)
        self.assertEquals(new_time_slot.day, time_slot.day)
        self.assertEquals(new_time_slot.room, time_slot.room)
        #Make sure not exact same time slot obj"""

    def test_separate_by_credit(self):
        self.assertEquals(len(sample_scheduler.separated[1]), 2)
        self.assertEquals(len(sample_scheduler.separated[3]), 3)
        self.assertEquals(sample_scheduler.separated[1][0].code, "CSC 131 001")
        self.assertEquals(sample_scheduler.separated[3][0].code, "CSC 130 A")

    def test_replace_time_slots(self):
        pass

    def test_assess_inconsistences(self):
        #generic unit tests based on pre defined seeds
{'fraction_non_alphanumeric': 0.09246112237998648, 'fraction_numerical': 0.017410412440838404, 'mean_word_length': 3.7109872611464967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '627101', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1765, 'n_words': 288}